B2024-060-Adding-a-picture-PROMS-crashes

This commit is contained in:
Paul Larsen 2024-08-26 11:11:03 -04:00
parent 516b479c0c
commit 7a3748f7e0
2 changed files with 11 additions and 53 deletions

View File

@ -111,12 +111,6 @@ namespace Volian.Controls.Library
get { return tbFSHt.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
#region Constructor
@ -423,14 +417,14 @@ namespace Volian.Controls.Library
tbFSWd.Text = wd.ToString();
tbFSHt.Text = ht.ToString();
trBarFS.Maximum = Math.Max((int)wd2, trBarFS.Maximum);
if (wd > trBarFS.Maximum) trBarFS.Maximum = wd + 1;
trBarFS.Minimum = Math.Min(wd, 72);
trBarFS.Value = (int)wd;
ImageItem ii = MyEditItem as ImageItem;
_origFigureSizeWidth = ii.MyPictureBox.Width;
tbFSWd.Text = ii.MyPictureBox.Width.ToString();
tbFSHt.Text = ii.MyPictureBox.Height.ToString();
//trBarFS.Maximum = Math.Max((int)wd2, trBarFS.Maximum);
//if (wd > trBarFS.Maximum) trBarFS.Maximum = wd + 1;
//trBarFS.Minimum = Math.Min(wd, 72);
//trBarFS.Value = (int)wd;
//ImageItem ii = MyEditItem as ImageItem;
//_origFigureSizeWidth = ii.MyPictureBox.Width;
//tbFSWd.Text = ii.MyPictureBox.Width.ToString();
//tbFSHt.Text = ii.MyPictureBox.Height.ToString();
}
else
{
@ -573,8 +567,8 @@ namespace Volian.Controls.Library
trBarFS.Minimum = Math.Min((int)wd, 72);
trBarFS.Value = (int)wd;
_origFigureSizeWidth = ii.MyPictureBox.Width;
tbFSWd.Text = ii.MyPictureBox.Width.ToString();
tbFSHt.Text = ii.MyPictureBox.Height.ToString();
//tbFSWd.Text = ii.MyPictureBox.Width.ToString();
//tbFSHt.Text = ii.MyPictureBox.Height.ToString();
}
private int DoListStepTypes(FormatData fmtdata, StepData topType, string curType)

View File

@ -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 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.
{
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
@ -333,16 +329,12 @@ namespace Volian.Controls.Library
{
wd = ic.Image_Width * 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.Width = wd;
MyPictureBox.Height = (int)ht;
MyPictureBox.Height = ht;
MyPictureBox.SizeMode = PictureBoxSizeMode.Zoom; // as resize matches width/height.
this.Width = MyPictureBox.Width + ImageMargin;
this.Height = MyPictureBox.Height + 10;
@ -353,35 +345,7 @@ namespace Volian.Controls.Library
_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
private E_ImageSource InsType = E_ImageSource.None;