B2024-060-Adding-a-picture-PROMS-crashes
This commit is contained in:
parent
7713f0cd63
commit
c06744b3bb
@ -111,6 +111,12 @@ 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
|
||||||
@ -417,14 +423,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
|
||||||
{
|
{
|
||||||
@ -567,8 +573,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)
|
||||||
|
@ -256,7 +256,8 @@ namespace Volian.Controls.Library
|
|||||||
private int _origCfgHt = 0; // keep track if original size was stored in cfg
|
private int _origCfgHt = 0; // keep track if original size was stored in cfg
|
||||||
private int _origCfgWd = 0;
|
private int _origCfgWd = 0;
|
||||||
private bool _pastedNew = false; // need this for flagging newly pasted image (may need to clear cfg)
|
private bool _pastedNew = false; // need this for flagging newly pasted image (may need to clear cfg)
|
||||||
private DisplayTags _displayTags;
|
private DisplayTags _displayTags = new DisplayTags();
|
||||||
|
//House myhouse = new House();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@ -316,21 +317,26 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
private void SetWidthsAndHeights(System.Drawing.Image img)
|
private void SetWidthsAndHeights(System.Drawing.Image img)
|
||||||
{
|
{
|
||||||
int wd = img.Width * MyStepPanel.DPI / 72; // converts from screen resolution's DPI to image's points (72/inch)
|
int wd = adjustimage(img.Width); // * MyStepPanel.DPI / 72; // converts from screen resolution's DPI to image's points (72/inch)
|
||||||
int ht = img.Height * MyStepPanel.DPI / 72;
|
|
||||||
|
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);
|
||||||
if (!_pastedNew && ic != null && ic.Image_Height != 0)
|
if (!_pastedNew && ic != null && ic.Image_Height != 0)
|
||||||
{
|
{
|
||||||
wd = ic.Image_Width * MyStepPanel.DPI / 72;
|
wd = adjustimage(ic.Image_Width); // * MyStepPanel.DPI / 72;
|
||||||
ht = ic.Image_Height * 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 = ht;
|
MyPictureBox.Height = (int)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;
|
||||||
@ -340,9 +346,37 @@ namespace Volian.Controls.Library
|
|||||||
_displayTags.TbFSwd = wd.ToString();
|
_displayTags.TbFSwd = wd.ToString();
|
||||||
_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;
|
||||||
public ImageItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem, ImageItem.E_ImageSource insType, DisplayTags displayTags)
|
public ImageItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem, ImageItem.E_ImageSource insType, DisplayTags displayTags)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user