B2024-060-Adding-a-picture-PROMS-crashes
This commit is contained in:
parent
516b479c0c
commit
7a3748f7e0
@ -111,12 +111,6 @@ namespace Volian.Controls.Library
|
|||||||
get { return tbFSHt.Text; }
|
get { return tbFSHt.Text; }
|
||||||
set { tbFSHt.Text = value; tbFSHt.Refresh(); _origFigureSizeRatio = float.Parse(value) / float.Parse(tbFSWd.Text); }
|
set { tbFSHt.Text = value; tbFSHt.Refresh(); _origFigureSizeRatio = float.Parse(value) / float.Parse(tbFSWd.Text); }
|
||||||
}
|
}
|
||||||
// B2024-060 needed for resizing image.
|
|
||||||
public TrackBar TrBarFS
|
|
||||||
{
|
|
||||||
get { return trBarFS; }
|
|
||||||
//set { trBarFS.Value = Convert.ToInt32(value);}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Constructor
|
#region Constructor
|
||||||
@ -423,14 +417,14 @@ namespace Volian.Controls.Library
|
|||||||
tbFSWd.Text = wd.ToString();
|
tbFSWd.Text = wd.ToString();
|
||||||
tbFSHt.Text = ht.ToString();
|
tbFSHt.Text = ht.ToString();
|
||||||
|
|
||||||
trBarFS.Maximum = Math.Max((int)wd2, trBarFS.Maximum);
|
//trBarFS.Maximum = Math.Max((int)wd2, trBarFS.Maximum);
|
||||||
if (wd > trBarFS.Maximum) trBarFS.Maximum = wd + 1;
|
//if (wd > trBarFS.Maximum) trBarFS.Maximum = wd + 1;
|
||||||
trBarFS.Minimum = Math.Min(wd, 72);
|
//trBarFS.Minimum = Math.Min(wd, 72);
|
||||||
trBarFS.Value = (int)wd;
|
//trBarFS.Value = (int)wd;
|
||||||
ImageItem ii = MyEditItem as ImageItem;
|
//ImageItem ii = MyEditItem as ImageItem;
|
||||||
_origFigureSizeWidth = ii.MyPictureBox.Width;
|
//_origFigureSizeWidth = ii.MyPictureBox.Width;
|
||||||
tbFSWd.Text = ii.MyPictureBox.Width.ToString();
|
//tbFSWd.Text = ii.MyPictureBox.Width.ToString();
|
||||||
tbFSHt.Text = ii.MyPictureBox.Height.ToString();
|
//tbFSHt.Text = ii.MyPictureBox.Height.ToString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -573,8 +567,8 @@ namespace Volian.Controls.Library
|
|||||||
trBarFS.Minimum = Math.Min((int)wd, 72);
|
trBarFS.Minimum = Math.Min((int)wd, 72);
|
||||||
trBarFS.Value = (int)wd;
|
trBarFS.Value = (int)wd;
|
||||||
_origFigureSizeWidth = ii.MyPictureBox.Width;
|
_origFigureSizeWidth = ii.MyPictureBox.Width;
|
||||||
tbFSWd.Text = ii.MyPictureBox.Width.ToString();
|
//tbFSWd.Text = ii.MyPictureBox.Width.ToString();
|
||||||
tbFSHt.Text = ii.MyPictureBox.Height.ToString();
|
//tbFSHt.Text = ii.MyPictureBox.Height.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int DoListStepTypes(FormatData fmtdata, StepData topType, string curType)
|
private int DoListStepTypes(FormatData fmtdata, StepData topType, string curType)
|
||||||
|
@ -321,11 +321,7 @@ namespace Volian.Controls.Library
|
|||||||
int wd = img.Width * MyStepPanel.DPI / 72; // converts from screen resolution's DPI to image's points (72/inch)
|
int wd = img.Width * MyStepPanel.DPI / 72; // converts from screen resolution's DPI to image's points (72/inch)
|
||||||
int ht = img.Height * MyStepPanel.DPI / 72;
|
int ht = img.Height * MyStepPanel.DPI / 72;
|
||||||
|
|
||||||
//int wd = adjustimage(img.Width); // * MyStepPanel.DPI / 72; // converts from screen resolution's DPI to image's points (72/inch)
|
|
||||||
|
|
||||||
//double ht = (double)wd * aspectratio(img.Width, img.Height);
|
|
||||||
|
|
||||||
//int ht = adjustimage(img.Height); // * MyStepPanel.DPI / 72;
|
|
||||||
if (MyItemInfo.MyContent.MyImage != null) // image is null if creating new.
|
if (MyItemInfo.MyContent.MyImage != null) // image is null if creating new.
|
||||||
{
|
{
|
||||||
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
|
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
|
||||||
@ -333,16 +329,12 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
wd = ic.Image_Width * MyStepPanel.DPI / 72;
|
wd = ic.Image_Width * MyStepPanel.DPI / 72;
|
||||||
ht = ic.Image_Height * MyStepPanel.DPI / 72;
|
ht = ic.Image_Height * MyStepPanel.DPI / 72;
|
||||||
//wd = adjustimage(ic.Image_Width); // * MyStepPanel.DPI / 72;
|
|
||||||
//ht = (double)wd * aspectratio(img.Width, img.Height);
|
|
||||||
//ht = wd * (int)aspectratio(img.Width, img.Height);
|
|
||||||
//ht = adjustimage(ic.Image_Height); // * MyStepPanel.DPI / 72;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MyPictureBox.Visible = true;
|
MyPictureBox.Visible = true;
|
||||||
MyPictureBox.Width = wd;
|
MyPictureBox.Width = wd;
|
||||||
MyPictureBox.Height = (int)ht;
|
MyPictureBox.Height = ht;
|
||||||
MyPictureBox.SizeMode = PictureBoxSizeMode.Zoom; // as resize matches width/height.
|
MyPictureBox.SizeMode = PictureBoxSizeMode.Zoom; // as resize matches width/height.
|
||||||
this.Width = MyPictureBox.Width + ImageMargin;
|
this.Width = MyPictureBox.Width + ImageMargin;
|
||||||
this.Height = MyPictureBox.Height + 10;
|
this.Height = MyPictureBox.Height + 10;
|
||||||
@ -353,35 +345,7 @@ namespace Volian.Controls.Library
|
|||||||
_displayTags.TbFSht = ht.ToString();
|
_displayTags.TbFSht = ht.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// B2024-060 adjust pasted image if too large. If the image is too large PROMS crashes.
|
|
||||||
private int adjustimage(int dim)
|
|
||||||
{
|
|
||||||
int dim2 = dim * MyStepPanel.DPI / 72;
|
|
||||||
if (dim2 > _displayTags.TrBarFS.Maximum)
|
|
||||||
{
|
|
||||||
//int y = dim2 - _displayTags.TrBarFS.Maximum;
|
|
||||||
////int a = y * 72 / MyStepPanel.DPI;
|
|
||||||
//int a = y * MyStepPanel.DPI / 72;
|
|
||||||
//dim = dim - a;
|
|
||||||
//dim2 = dim * MyStepPanel.DPI / 72;
|
|
||||||
|
|
||||||
dim2 = _displayTags.TrBarFS.Maximum * 72 / MyStepPanel.DPI;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return dim2;
|
|
||||||
}
|
|
||||||
return dim2;
|
|
||||||
}
|
|
||||||
// B2024-060 Get aspect ratio to resize pasted image.
|
|
||||||
private double aspectratio(int w, int h)
|
|
||||||
{
|
|
||||||
//double ratio = Math.Max((double)image.width / (double)box.width, (double)image.height / (double)box.height);
|
|
||||||
//image.width = (int) (image.width / ratio);
|
|
||||||
//image.height = (int) (image.height / ratio);
|
|
||||||
double ratio = (double)h / (double)w;
|
|
||||||
return ratio;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the following gets called for 'NEW' images
|
// the following gets called for 'NEW' images
|
||||||
private E_ImageSource InsType = E_ImageSource.None;
|
private E_ImageSource InsType = E_ImageSource.None;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user