Embedded images

This commit is contained in:
2016-10-17 14:25:30 +00:00
parent 187dd5be25
commit e689dc2ba0
20 changed files with 2298 additions and 463 deletions

View File

@@ -231,6 +231,7 @@ namespace Volian.Controls.Library
myRTB.Clear();
//myRTB.LastRtf = string.Empty;
myVFG.Clear();
myPicBox.Image = null;
tvAudits.Nodes.Clear();
if (MyItemInfo == null)
{
@@ -316,6 +317,22 @@ namespace Volian.Controls.Library
}
break;
}
// handle figures (images):
else if (cai.Type == 20036 || cai.Type == 20037 || cai.Type == 20038 || cai.Type == 20039)
{
ImageAuditInfoList imail = ImageAuditInfoList.Get(cai.ContentID);
foreach (ImageAuditInfo imai in imail)
{
if (imai.DeleteStatus == 0)
{
if (contentHistory == null)
contentHistory = tvAudits.Nodes.Add("Content Changes");
TreeNode tn = contentHistory.Nodes.Add(imai.ToString());
tn.Tag = imai;
}
}
break;
}
else if (cai.DTS != ci.DTS)
{
if (contentHistory == null)
@@ -761,6 +778,19 @@ namespace Volian.Controls.Library
myVFG.Clear();
}
}
if (tn.Tag is ImageAuditInfo)
{
ImageAuditInfo iai = tn.Tag as ImageAuditInfo;
if (MessageBox.Show(this, "Do you want to restore this image?", "Confirm Image Restore", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
{
ContentInfo ci = ContentInfo.RestoreImage(iai);
RefreshRequired = true;
UpdateHistory();
myRTB.Clear();
myVFG.Clear();
myPicBox.Image = null; // myPicBox is the PictureBox that shows the selected figure
}
}
}
List<string> myRoFst_ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)
@@ -784,6 +814,7 @@ namespace Volian.Controls.Library
{
btnRestore.Enabled = UserInfo.CanEdit(MyUserInfo, MyProcedureInfo.MyDocVersion);//CanRestore();
GridAuditInfo gai = tn.Tag as GridAuditInfo;
myPicBox.Visible = false;
myVFG.Visible = true;
myVFG.BringToFront();
panel1.Invalidate(new Rectangle(0, 0, myVFG.Width + 4, 4));
@@ -798,6 +829,30 @@ namespace Volian.Controls.Library
panel1.Visible = true;
return;
}
if (tn.Tag is ImageAuditInfo)
{
btnRestore.Enabled = UserInfo.CanEdit(MyUserInfo, MyProcedureInfo.MyDocVersion);
ImageAuditInfo iai = tn.Tag as ImageAuditInfo;
myVFG.Visible = false;
myRTB.Visible = false;
myPicBox.Visible = true;
myPicBox.BringToFront();
panel1.Invalidate(new Rectangle(0, 0, myPicBox.Width + 4, 4));
panel1.Invalidate(new Rectangle(0, 0, 4, myPicBox.Height + 4));
panel1.Visible = false;
ImageInfo imgin = ImageInfo.Get(iai.ContentID);
// check if image data was compressed, i.e. config stores original size:
ImageConfig imgCfg = new ImageConfig(imgin);
byte[] imgData = iai.Data;
if (imgCfg.Image_DataSize > 0) imgData = ROImageInfo.Decompress(imgData, imgCfg.Image_DataSize);
MemoryStream ms = new MemoryStream(imgData);
myPicBox.Image = System.Drawing.Image.FromStream(ms);
myPicBox.Width = Math.Max(myPicBox.Image.Width, panel1.Width);
myPicBox.Height = Math.Max(myPicBox.Image.Height, 200);
panel1.Visible = true;
return;
}
if (tn.Tag is ContentAuditInfo)
{
btnRestore.Enabled = UserInfo.CanEdit(MyUserInfo, MyProcedureInfo.MyDocVersion);//CanRestore();

View File

@@ -48,12 +48,22 @@ namespace Volian.Controls.Library
this.groupPanelIncludeOn = new DevComponents.DotNetBar.Controls.GroupPanel();
this.groupPanelWcnTrnResp = new DevComponents.DotNetBar.Controls.GroupPanel();
this.tbRespons = new System.Windows.Forms.TextBox();
this.groupPanelFigSize = new DevComponents.DotNetBar.Controls.GroupPanel();
this.trBarFS = new System.Windows.Forms.TrackBar();
this.btnFsSav = new System.Windows.Forms.Button();
this.tbFSHt = new System.Windows.Forms.TextBox();
this.tbFSWd = new System.Windows.Forms.TextBox();
this.lblFSHt = new System.Windows.Forms.Label();
this.lblFSWidth = new System.Windows.Forms.Label();
this.btnFSrestore = new System.Windows.Forms.Button();
this.groupPanelPaginate.SuspendLayout();
this.groupPanelCheckoff.SuspendLayout();
this.groupPanelChgBar.SuspendLayout();
this.groupPanelChgStepType.SuspendLayout();
this.groupPanelIncludeOn.SuspendLayout();
this.groupPanelWcnTrnResp.SuspendLayout();
this.groupPanelFigSize.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trBarFS)).BeginInit();
this.SuspendLayout();
//
// groupPanelPaginate
@@ -64,10 +74,10 @@ namespace Volian.Controls.Library
this.groupPanelPaginate.Controls.Add(this.cbPageBreak);
this.groupPanelPaginate.DisabledBackColor = System.Drawing.Color.Empty;
this.groupPanelPaginate.Dock = System.Windows.Forms.DockStyle.Top;
this.groupPanelPaginate.Location = new System.Drawing.Point(0, 330);
this.groupPanelPaginate.Margin = new System.Windows.Forms.Padding(2);
this.groupPanelPaginate.Location = new System.Drawing.Point(0, 406);
this.groupPanelPaginate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupPanelPaginate.Name = "groupPanelPaginate";
this.groupPanelPaginate.Size = new System.Drawing.Size(202, 58);
this.groupPanelPaginate.Size = new System.Drawing.Size(269, 71);
//
//
//
@@ -106,10 +116,10 @@ namespace Volian.Controls.Library
//
//
this.cbPageBreak.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.cbPageBreak.Location = new System.Drawing.Point(3, 11);
this.cbPageBreak.Margin = new System.Windows.Forms.Padding(2);
this.cbPageBreak.Location = new System.Drawing.Point(4, 14);
this.cbPageBreak.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.cbPageBreak.Name = "cbPageBreak";
this.cbPageBreak.Size = new System.Drawing.Size(122, 15);
this.cbPageBreak.Size = new System.Drawing.Size(140, 17);
this.superTooltipTags.SetSuperTooltip(this.cbPageBreak, new DevComponents.DotNetBar.SuperTooltipInfo("Manual Page Break", "", "When set, starts this step at the top of a page.\r\n\r\nkeyboard command: <Ctrl><Ente" +
"r>", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
this.cbPageBreak.TabIndex = 0;
@@ -124,10 +134,10 @@ namespace Volian.Controls.Library
//
//
this.cbCAS.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.cbCAS.Location = new System.Drawing.Point(3, 9);
this.cbCAS.Margin = new System.Windows.Forms.Padding(2);
this.cbCAS.Location = new System.Drawing.Point(4, 11);
this.cbCAS.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.cbCAS.Name = "cbCAS";
this.cbCAS.Size = new System.Drawing.Size(162, 15);
this.cbCAS.Size = new System.Drawing.Size(187, 17);
this.superTooltipTags.SetSuperTooltip(this.cbCAS, new DevComponents.DotNetBar.SuperTooltipInfo("Continuous Action Summary", "", "Include this in the Continuous Action Summary section\r\n\r\nkeyboard command: <Shift" +
"><F7>", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
this.cbCAS.TabIndex = 1;
@@ -143,10 +153,10 @@ namespace Volian.Controls.Library
this.cmbCheckoff.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCheckoff.FormattingEnabled = true;
this.cmbCheckoff.ItemHeight = 17;
this.cmbCheckoff.Location = new System.Drawing.Point(3, 17);
this.cmbCheckoff.Margin = new System.Windows.Forms.Padding(2);
this.cmbCheckoff.Location = new System.Drawing.Point(4, 21);
this.cmbCheckoff.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.cmbCheckoff.Name = "cmbCheckoff";
this.cmbCheckoff.Size = new System.Drawing.Size(194, 23);
this.cmbCheckoff.Size = new System.Drawing.Size(257, 23);
this.cmbCheckoff.TabIndex = 0;
this.cmbCheckoff.WatermarkFont = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cmbCheckoff.WatermarkText = "select signoff / checkoff";
@@ -159,10 +169,10 @@ namespace Volian.Controls.Library
this.groupPanelCheckoff.Controls.Add(this.cmbCheckoff);
this.groupPanelCheckoff.DisabledBackColor = System.Drawing.Color.Empty;
this.groupPanelCheckoff.Dock = System.Windows.Forms.DockStyle.Top;
this.groupPanelCheckoff.Location = new System.Drawing.Point(0, 145);
this.groupPanelCheckoff.Margin = new System.Windows.Forms.Padding(2);
this.groupPanelCheckoff.Location = new System.Drawing.Point(0, 178);
this.groupPanelCheckoff.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupPanelCheckoff.Name = "groupPanelCheckoff";
this.groupPanelCheckoff.Size = new System.Drawing.Size(202, 77);
this.groupPanelCheckoff.Size = new System.Drawing.Size(269, 95);
//
//
//
@@ -206,10 +216,10 @@ namespace Volian.Controls.Library
this.groupPanelChgBar.Controls.Add(this.rbChgBarOn);
this.groupPanelChgBar.DisabledBackColor = System.Drawing.Color.Empty;
this.groupPanelChgBar.Dock = System.Windows.Forms.DockStyle.Top;
this.groupPanelChgBar.Location = new System.Drawing.Point(0, 222);
this.groupPanelChgBar.Margin = new System.Windows.Forms.Padding(2);
this.groupPanelChgBar.Location = new System.Drawing.Point(0, 273);
this.groupPanelChgBar.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupPanelChgBar.Name = "groupPanelChgBar";
this.groupPanelChgBar.Size = new System.Drawing.Size(202, 108);
this.groupPanelChgBar.Size = new System.Drawing.Size(269, 133);
//
//
//
@@ -244,30 +254,29 @@ namespace Volian.Controls.Library
//
// tbChgID
//
this.tbChgID.Location = new System.Drawing.Point(0, 67);
this.tbChgID.Margin = new System.Windows.Forms.Padding(2);
this.tbChgID.Location = new System.Drawing.Point(0, 82);
this.tbChgID.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.tbChgID.Name = "tbChgID";
this.tbChgID.Size = new System.Drawing.Size(81, 20);
this.tbChgID.Size = new System.Drawing.Size(107, 22);
this.tbChgID.TabIndex = 4;
this.tbChgID.TextChanged += new System.EventHandler(this.tbChgID_TextChanged);
//
// lblChgId
//
this.lblChgId.AutoSize = true;
this.lblChgId.Location = new System.Drawing.Point(0, 52);
this.lblChgId.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblChgId.Location = new System.Drawing.Point(0, 64);
this.lblChgId.Name = "lblChgId";
this.lblChgId.Size = new System.Drawing.Size(58, 13);
this.lblChgId.Size = new System.Drawing.Size(74, 17);
this.lblChgId.TabIndex = 3;
this.lblChgId.Text = "Change ID";
//
// rbChgBarOff
//
this.rbChgBarOff.AutoSize = true;
this.rbChgBarOff.Location = new System.Drawing.Point(0, 26);
this.rbChgBarOff.Margin = new System.Windows.Forms.Padding(2);
this.rbChgBarOff.Location = new System.Drawing.Point(0, 32);
this.rbChgBarOff.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.rbChgBarOff.Name = "rbChgBarOff";
this.rbChgBarOff.Size = new System.Drawing.Size(45, 17);
this.rbChgBarOff.Size = new System.Drawing.Size(56, 21);
this.superTooltipTags.SetSuperTooltip(this.rbChgBarOff, new DevComponents.DotNetBar.SuperTooltipInfo("Change Bar OFF", "", "Turn change bar off. Note that \'OVERRIDE\' will turn off a change bar even though" +
" text is changed.\r\n\r\nkeyboard command: <Alt><F2>", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
this.rbChgBarOff.TabIndex = 2;
@@ -279,10 +288,10 @@ namespace Volian.Controls.Library
// rbChgBarOn
//
this.rbChgBarOn.AutoSize = true;
this.rbChgBarOn.Location = new System.Drawing.Point(0, 4);
this.rbChgBarOn.Margin = new System.Windows.Forms.Padding(2);
this.rbChgBarOn.Location = new System.Drawing.Point(0, 5);
this.rbChgBarOn.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.rbChgBarOn.Name = "rbChgBarOn";
this.rbChgBarOn.Size = new System.Drawing.Size(41, 17);
this.rbChgBarOn.Size = new System.Drawing.Size(50, 21);
this.superTooltipTags.SetSuperTooltip(this.rbChgBarOn, new DevComponents.DotNetBar.SuperTooltipInfo("Change Bar ON", "", "Add a change bar on this step\r\n\r\nkeyboard command: <Alt><F2>", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
this.rbChgBarOn.TabIndex = 1;
this.rbChgBarOn.TabStop = true;
@@ -301,9 +310,9 @@ namespace Volian.Controls.Library
this.groupPanelChgStepType.DisabledBackColor = System.Drawing.Color.Empty;
this.groupPanelChgStepType.Dock = System.Windows.Forms.DockStyle.Top;
this.groupPanelChgStepType.Location = new System.Drawing.Point(0, 0);
this.groupPanelChgStepType.Margin = new System.Windows.Forms.Padding(2);
this.groupPanelChgStepType.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupPanelChgStepType.Name = "groupPanelChgStepType";
this.groupPanelChgStepType.Size = new System.Drawing.Size(202, 145);
this.groupPanelChgStepType.Size = new System.Drawing.Size(269, 178);
//
//
//
@@ -345,20 +354,20 @@ namespace Volian.Controls.Library
//
this.lblNoTypeChgReason.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.lblNoTypeChgReason.ForeColor = System.Drawing.Color.Red;
this.lblNoTypeChgReason.Location = new System.Drawing.Point(2, 28);
this.lblNoTypeChgReason.Margin = new System.Windows.Forms.Padding(2);
this.lblNoTypeChgReason.Location = new System.Drawing.Point(3, 34);
this.lblNoTypeChgReason.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.lblNoTypeChgReason.Name = "lblNoTypeChgReason";
this.lblNoTypeChgReason.Size = new System.Drawing.Size(194, 96);
this.lblNoTypeChgReason.Size = new System.Drawing.Size(259, 118);
this.lblNoTypeChgReason.TabIndex = 5;
//
// cbChgAll
//
this.cbChgAll.AutoSize = true;
this.cbChgAll.BackColor = System.Drawing.Color.Transparent;
this.cbChgAll.Location = new System.Drawing.Point(2, 6);
this.cbChgAll.Margin = new System.Windows.Forms.Padding(2);
this.cbChgAll.Location = new System.Drawing.Point(3, 7);
this.cbChgAll.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.cbChgAll.Name = "cbChgAll";
this.cbChgAll.Size = new System.Drawing.Size(119, 17);
this.cbChgAll.Size = new System.Drawing.Size(153, 21);
this.superTooltipTags.SetSuperTooltip(this.cbChgAll, new DevComponents.DotNetBar.SuperTooltipInfo("Change Step Type - All At Level", "", "When checked, all steps at the level of current step will have their step type ch" +
"anged to the selected type in list below...", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
this.cbChgAll.TabIndex = 4;
@@ -370,10 +379,11 @@ namespace Volian.Controls.Library
this.listBoxStepTypes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listBoxStepTypes.FormattingEnabled = true;
this.listBoxStepTypes.Location = new System.Drawing.Point(2, 28);
this.listBoxStepTypes.Margin = new System.Windows.Forms.Padding(2);
this.listBoxStepTypes.ItemHeight = 16;
this.listBoxStepTypes.Location = new System.Drawing.Point(3, 34);
this.listBoxStepTypes.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.listBoxStepTypes.Name = "listBoxStepTypes";
this.listBoxStepTypes.Size = new System.Drawing.Size(194, 95);
this.listBoxStepTypes.Size = new System.Drawing.Size(257, 116);
this.superTooltipTags.SetSuperTooltip(this.listBoxStepTypes, new DevComponents.DotNetBar.SuperTooltipInfo("Possible Step Types", "", "This list allows change of type showing all selections of any possible step type " +
"for the current step.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
this.listBoxStepTypes.TabIndex = 3;
@@ -392,10 +402,10 @@ namespace Volian.Controls.Library
//
//
this.cbPlaceKeeperCont.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.cbPlaceKeeperCont.Location = new System.Drawing.Point(3, 47);
this.cbPlaceKeeperCont.Margin = new System.Windows.Forms.Padding(2);
this.cbPlaceKeeperCont.Location = new System.Drawing.Point(4, 58);
this.cbPlaceKeeperCont.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.cbPlaceKeeperCont.Name = "cbPlaceKeeperCont";
this.cbPlaceKeeperCont.Size = new System.Drawing.Size(158, 15);
this.cbPlaceKeeperCont.Size = new System.Drawing.Size(183, 17);
this.superTooltipTags.SetSuperTooltip(this.cbPlaceKeeperCont, new DevComponents.DotNetBar.SuperTooltipInfo("Placekeeper Continuous Action", "", "Include this on the Placekeeper marked as a Continuous Action\r\n\r\nkeyboard command" +
": <Shift><Ctrl><F7>", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
this.cbPlaceKeeperCont.TabIndex = 1;
@@ -410,10 +420,10 @@ namespace Volian.Controls.Library
//
//
this.cbPlaceKeeper.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.cbPlaceKeeper.Location = new System.Drawing.Point(3, 28);
this.cbPlaceKeeper.Margin = new System.Windows.Forms.Padding(2);
this.cbPlaceKeeper.Location = new System.Drawing.Point(4, 34);
this.cbPlaceKeeper.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.cbPlaceKeeper.Name = "cbPlaceKeeper";
this.cbPlaceKeeper.Size = new System.Drawing.Size(84, 15);
this.cbPlaceKeeper.Size = new System.Drawing.Size(95, 17);
this.superTooltipTags.SetSuperTooltip(this.cbPlaceKeeper, new DevComponents.DotNetBar.SuperTooltipInfo("Placekeeper", "", "Include this on the Placekeeper\r\n\r\nkeyboard command: <Ctrl><F7>", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
this.cbPlaceKeeper.TabIndex = 1;
this.cbPlaceKeeper.Text = "Placekeeper";
@@ -429,10 +439,10 @@ namespace Volian.Controls.Library
this.groupPanelIncludeOn.Controls.Add(this.cbCAS);
this.groupPanelIncludeOn.DisabledBackColor = System.Drawing.Color.Empty;
this.groupPanelIncludeOn.Dock = System.Windows.Forms.DockStyle.Top;
this.groupPanelIncludeOn.Location = new System.Drawing.Point(0, 388);
this.groupPanelIncludeOn.Margin = new System.Windows.Forms.Padding(2);
this.groupPanelIncludeOn.Location = new System.Drawing.Point(0, 477);
this.groupPanelIncludeOn.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupPanelIncludeOn.Name = "groupPanelIncludeOn";
this.groupPanelIncludeOn.Size = new System.Drawing.Size(202, 94);
this.groupPanelIncludeOn.Size = new System.Drawing.Size(269, 116);
//
//
//
@@ -472,10 +482,10 @@ namespace Volian.Controls.Library
this.groupPanelWcnTrnResp.Controls.Add(this.tbRespons);
this.groupPanelWcnTrnResp.DisabledBackColor = System.Drawing.Color.Empty;
this.groupPanelWcnTrnResp.Dock = System.Windows.Forms.DockStyle.Top;
this.groupPanelWcnTrnResp.Location = new System.Drawing.Point(0, 482);
this.groupPanelWcnTrnResp.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupPanelWcnTrnResp.Location = new System.Drawing.Point(0, 593);
this.groupPanelWcnTrnResp.Margin = new System.Windows.Forms.Padding(4, 2, 4, 2);
this.groupPanelWcnTrnResp.Name = "groupPanelWcnTrnResp";
this.groupPanelWcnTrnResp.Size = new System.Drawing.Size(202, 138);
this.groupPanelWcnTrnResp.Size = new System.Drawing.Size(269, 170);
//
//
//
@@ -509,27 +519,142 @@ namespace Volian.Controls.Library
//
// tbRespons
//
this.tbRespons.Location = new System.Drawing.Point(27, 16);
this.tbRespons.Location = new System.Drawing.Point(36, 20);
this.tbRespons.Margin = new System.Windows.Forms.Padding(4);
this.tbRespons.Multiline = true;
this.tbRespons.Name = "tbRespons";
this.tbRespons.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.tbRespons.Size = new System.Drawing.Size(164, 81);
this.tbRespons.Size = new System.Drawing.Size(217, 99);
this.tbRespons.TabIndex = 0;
this.tbRespons.Leave += new System.EventHandler(this.tbRespons_Leave);
//
// groupPanelFigSize
//
this.groupPanelFigSize.BackColor = System.Drawing.Color.Transparent;
this.groupPanelFigSize.CanvasColor = System.Drawing.SystemColors.Control;
this.groupPanelFigSize.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007;
this.groupPanelFigSize.Controls.Add(this.btnFSrestore);
this.groupPanelFigSize.Controls.Add(this.trBarFS);
this.groupPanelFigSize.Controls.Add(this.btnFsSav);
this.groupPanelFigSize.Controls.Add(this.tbFSHt);
this.groupPanelFigSize.Controls.Add(this.tbFSWd);
this.groupPanelFigSize.Controls.Add(this.lblFSHt);
this.groupPanelFigSize.Controls.Add(this.lblFSWidth);
this.groupPanelFigSize.DisabledBackColor = System.Drawing.Color.Empty;
this.groupPanelFigSize.Dock = System.Windows.Forms.DockStyle.Top;
this.groupPanelFigSize.Location = new System.Drawing.Point(0, 763);
this.groupPanelFigSize.Name = "groupPanelFigSize";
this.groupPanelFigSize.Size = new System.Drawing.Size(269, 166);
//
//
//
this.groupPanelFigSize.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2;
this.groupPanelFigSize.Style.BackColorGradientAngle = 90;
this.groupPanelFigSize.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground;
this.groupPanelFigSize.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid;
this.groupPanelFigSize.Style.BorderBottomWidth = 1;
this.groupPanelFigSize.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
this.groupPanelFigSize.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid;
this.groupPanelFigSize.Style.BorderLeftWidth = 1;
this.groupPanelFigSize.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid;
this.groupPanelFigSize.Style.BorderRightWidth = 1;
this.groupPanelFigSize.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid;
this.groupPanelFigSize.Style.BorderTopWidth = 1;
this.groupPanelFigSize.Style.CornerDiameter = 4;
this.groupPanelFigSize.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
this.groupPanelFigSize.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center;
this.groupPanelFigSize.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
this.groupPanelFigSize.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near;
//
//
//
this.groupPanelFigSize.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square;
//
//
//
this.groupPanelFigSize.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.groupPanelFigSize.TabIndex = 21;
this.groupPanelFigSize.Text = "Image Size";
//
// trBarFS
//
this.trBarFS.Location = new System.Drawing.Point(15, 71);
this.trBarFS.Maximum = 700;
this.trBarFS.Minimum = 50;
this.trBarFS.Name = "trBarFS";
this.trBarFS.Size = new System.Drawing.Size(172, 56);
this.trBarFS.TabIndex = 5;
this.trBarFS.Value = 50;
this.trBarFS.Scroll += new System.EventHandler(this.trBarFS_Scroll);
//
// btnFsSav
//
this.btnFsSav.Location = new System.Drawing.Point(150, 3);
this.btnFsSav.Name = "btnFsSav";
this.btnFsSav.Size = new System.Drawing.Size(62, 24);
this.btnFsSav.TabIndex = 4;
this.btnFsSav.Text = "Set";
this.btnFsSav.UseVisualStyleBackColor = true;
this.btnFsSav.Click += new System.EventHandler(this.btnFsSav_Click);
//
// tbFSHt
//
this.tbFSHt.Enabled = false;
this.tbFSHt.Location = new System.Drawing.Point(56, 33);
this.tbFSHt.Name = "tbFSHt";
this.tbFSHt.Size = new System.Drawing.Size(78, 22);
this.tbFSHt.TabIndex = 3;
//
// tbFSWd
//
this.tbFSWd.Location = new System.Drawing.Point(56, 5);
this.tbFSWd.Name = "tbFSWd";
this.tbFSWd.Size = new System.Drawing.Size(78, 22);
this.tbFSWd.TabIndex = 2;
this.tbFSWd.Leave += new System.EventHandler(this.tbFSWd_Leave);
//
// lblFSHt
//
this.lblFSHt.AutoSize = true;
this.lblFSHt.Location = new System.Drawing.Point(5, 34);
this.lblFSHt.Name = "lblFSHt";
this.lblFSHt.Size = new System.Drawing.Size(49, 17);
this.lblFSHt.TabIndex = 1;
this.lblFSHt.Text = "Height";
//
// lblFSWidth
//
this.lblFSWidth.AutoSize = true;
this.lblFSWidth.Location = new System.Drawing.Point(6, 7);
this.lblFSWidth.Name = "lblFSWidth";
this.lblFSWidth.Size = new System.Drawing.Size(44, 17);
this.lblFSWidth.TabIndex = 0;
this.lblFSWidth.Text = "Width";
//
// btnFSrestore
//
this.btnFSrestore.Location = new System.Drawing.Point(150, 33);
this.btnFSrestore.Name = "btnFSrestore";
this.btnFSrestore.Size = new System.Drawing.Size(72, 32);
this.btnFSrestore.TabIndex = 6;
this.btnFSrestore.Text = "Restore";
this.btnFSrestore.UseVisualStyleBackColor = true;
this.btnFSrestore.Click += new System.EventHandler(this.btnFSrestore_Click);
//
// DisplayTags
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.groupPanelFigSize);
this.Controls.Add(this.groupPanelWcnTrnResp);
this.Controls.Add(this.groupPanelIncludeOn);
this.Controls.Add(this.groupPanelPaginate);
this.Controls.Add(this.groupPanelChgBar);
this.Controls.Add(this.groupPanelCheckoff);
this.Controls.Add(this.groupPanelChgStepType);
this.Margin = new System.Windows.Forms.Padding(2);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "DisplayTags";
this.Size = new System.Drawing.Size(202, 802);
this.Size = new System.Drawing.Size(269, 987);
this.groupPanelPaginate.ResumeLayout(false);
this.groupPanelPaginate.PerformLayout();
this.groupPanelCheckoff.ResumeLayout(false);
@@ -541,6 +666,9 @@ namespace Volian.Controls.Library
this.groupPanelIncludeOn.PerformLayout();
this.groupPanelWcnTrnResp.ResumeLayout(false);
this.groupPanelWcnTrnResp.PerformLayout();
this.groupPanelFigSize.ResumeLayout(false);
this.groupPanelFigSize.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.trBarFS)).EndInit();
this.ResumeLayout(false);
}
@@ -567,5 +695,13 @@ namespace Volian.Controls.Library
private System.Windows.Forms.Label lblChgId;
private DevComponents.DotNetBar.Controls.GroupPanel groupPanelWcnTrnResp;
private System.Windows.Forms.TextBox tbRespons;
private DevComponents.DotNetBar.Controls.GroupPanel groupPanelFigSize;
private System.Windows.Forms.TextBox tbFSHt;
private System.Windows.Forms.TextBox tbFSWd;
private System.Windows.Forms.Label lblFSHt;
private System.Windows.Forms.Label lblFSWidth;
private System.Windows.Forms.Button btnFsSav;
private System.Windows.Forms.TrackBar trBarFS;
private System.Windows.Forms.Button btnFSrestore;
}
}

View File

@@ -190,12 +190,20 @@ namespace Volian.Controls.Library
groupPanelCheckoff.Style.BackColor = Color.Cornsilk;
groupPanelIncludeOn.Style.BackColor = Color.Cornsilk;
groupPanelWcnTrnResp.Style.BackColor = Color.Cornsilk;
groupPanelFigSize.Style.BackColor = Color.Cornsilk;
cbPageBreak.Checked = false; // will be set below if HLS & config has it on
cbPlaceKeeper.Checked = false; // will be set below if HLS & config has this set
cbPlaceKeeperCont.Checked = false; // will be set below if substep & config has this set
cbPageBreak.Enabled = CurItemInfo.IsHigh;
cbPlaceKeeper.Enabled = (((SectionConfig)CurItemInfo.ActiveSection.MyConfig).Section_Placekeeper == "Y");
cbPlaceKeeperCont.Enabled = (cbPlaceKeeper.Enabled && !CurItemInfo.IsInRNO && !CurItemInfo.IsHigh);
if (!CurItemInfo.IsFigure)
{
cbPlaceKeeper.Enabled = (((SectionConfig)CurItemInfo.ActiveSection.MyConfig).Section_Placekeeper == "Y");
cbPlaceKeeperCont.Enabled = (cbPlaceKeeper.Enabled && !CurItemInfo.IsInRNO && !CurItemInfo.IsHigh);
}
else
{
cbPlaceKeeper.Enabled = cbPlaceKeeperCont.Enabled = false;
}
//cbCAS.Enabled = true;
rbChgBarOff.Enabled = true;
rbChgBarOn.Enabled = true;
@@ -217,7 +225,7 @@ namespace Volian.Controls.Library
//if ((fmtdata.ProcData.CheckOffData.CheckOffList == null || fmtdata.ProcData.CheckOffData.CheckOffList.Count == 0) ||
// fmtdata.ProcData.CheckOffData.Menu=="Signoff")
// cmbCheckoff.Enabled = false;
cbCAS.Enabled = true;
cbCAS.Enabled = !CurItemInfo.IsFigure;
if (((CurItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) ||
((CurItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations))
{
@@ -276,6 +284,30 @@ namespace Volian.Controls.Library
cmbCheckoff.Enabled = false;
}
// show the part of panel for resizing a figure (if figure already exists: MyImage is set for non-RO existing images & content.text has a link in it)
if (MyEditItem.MyItemInfo.IsFigure && (MyEditItem.MyItemInfo.MyContent.MyImage != null || MyEditItem.MyItemInfo.MyContent.Text.ToUpper().Contains("#LINK")))
{
groupPanelFigSize.Visible = true;
int ht = (MyEditItem as ImageItem).MyPictureBox.Height;
int wd = (MyEditItem as ImageItem).MyPictureBox.Width;
_origFigureSizeRatio = (float)ht / (float)wd; // use this to keep width/height ratio while changing size.
float wd1 = (float)MyEditItem.MyItemInfo.MyDocStyle.Layout.PageWidth - (float)MyEditItem.MyItemInfo.MyDocStyle.Layout.LeftMargin;
float ht1 = (float)MyEditItem.MyItemInfo.MyDocStyle.Layout.PageLength - (float)MyEditItem.MyItemInfo.MyDocStyle.Layout.TopMargin - 36; // 36 is to allow for end message
float wd2 = Math.Min(wd1, ht1 / _origFigureSizeRatio); // keep original ratio
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
{
groupPanelFigSize.Visible = false;
}
// change bar setting depends on whether step has changed (dts) as compared to date/time off the
// procedure that it's in.
// There is also an override flag in the config for the step, used to override the change bar to 'off'
@@ -376,7 +408,9 @@ namespace Volian.Controls.Library
_MyStepTypeInd.Clear();
foreach (StepDataRetval sdr in sdl)
{
listBoxStepTypes.Items.Add(sdr.Name);
// Figure menu titles have been changed from using the 'AER' in titles to 'Left'
string menutext = CurItemInfo.IsFigure && sdr.Name.Contains("AER")?sdr.Name.Replace("AER", "Left"):sdr.Name;
listBoxStepTypes.Items.Add(menutext);
_MyStepTypeInd.Add(sdr.Index);
}
}
@@ -597,6 +631,75 @@ namespace Volian.Controls.Library
}
#endregion
// The following supports the portion of displaytags that handles sizing of figures. there are 2 text
// boxes with width & height that are tied to the slider value:
// save data back to the ImageItem. If user enters data in text boxes, this is used. Slider automatically
// saves data to ImageItem.
private void btnFsSav_Click(object sender, EventArgs e)
{
if (MyEditItem is ImageItem)
{
int wd = 0;
int ht = 0;
try
{
wd = int.Parse(tbFSWd.Text);
ht = int.Parse(tbFSHt.Text);
}
catch (Exception ex)
{
wd = 0;
ht = 0;
}
if (wd != 0 && ht != 0) (MyEditItem as ImageItem).SizeImage(wd, ht);
}
}
private float _origFigureSizeRatio = 0; // keep original ratio & width in case of 'restore'
private int _origFigureSizeWidth = 0;
// support user changing size using slider. This saves change back to ImageItem and sets
// width/height text boxes to slider values.
private void trBarFS_Scroll(object sender, EventArgs e)
{
int wd = trBarFS.Value;
int ht = (int)(_origFigureSizeRatio * wd);
(MyEditItem as ImageItem).SizeImage(wd, ht);
tbFSWd.Text = wd.ToString();
tbFSHt.Text = ht.ToString();
}
// restore the orignal image size
private void btnFSrestore_Click(object sender, EventArgs e)
{
tbFSWd.Text = _origFigureSizeWidth.ToString();
int ht = (int)(_origFigureSizeRatio * _origFigureSizeWidth);
tbFSHt.Text = ht.ToString();
(MyEditItem as ImageItem).SizeImage(_origFigureSizeWidth, ht);
trBarFS.Value = _origFigureSizeWidth;
}
// user entered width in text box, this event gets called on leave of text box.
private void tbFSWd_Leave(object sender, EventArgs e)
{
// check that value input is between the slider values:
bool invaliddata = false;
int newHt = 0;
try
{
newHt = int.Parse(tbFSWd.Text);
}
catch (Exception ex)
{
invaliddata = true;
}
if (invaliddata || newHt < trBarFS.Minimum || newHt > trBarFS.Maximum)
{
string errormsg = string.Format("Invalid width, must be integer and greater than 72 (inch) and less than {0}", trBarFS.Maximum);
MessageBox.Show(errormsg, "Invalid Width data");
return;
}
tbFSHt.Text = ((int)(int.Parse(tbFSWd.Text) * _origFigureSizeRatio)).ToString();
trBarFS.Value = int.Parse(tbFSWd.Text);
}
//private void txbxAltConActSumText_Leave(object sender, EventArgs e)
//{
// // User left Atlernate Continuous Action Text field. If text changed, then prompt

View File

@@ -995,8 +995,9 @@ namespace Volian.Controls.Library
public EditItem AddChildAfter(ItemInfo MyItemInfo, bool expand, bool addFirstChld)
{
EditItem child = null;
//if (MyItemInfo.MyContent.ContentGridCount != 0)
if (MyItemInfo.MyContent.MyGrid != null)
if (MyItemInfo.IsFigure)
child = new ImageItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand);
else if (MyItemInfo.MyContent.MyGrid != null)
child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand);
else
child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand, addFirstChld);
@@ -1005,8 +1006,11 @@ namespace Volian.Controls.Library
public EditItem AddChildAfter(ItemInfo MyItemInfo, EditItem nextEditItem)
{
EditItem child = null;
//if (MyItemInfo.MyContent.ContentGridCount != 0)
if (MyItemInfo.MyContent.MyGrid != null)
if (MyItemInfo.IsFigure)
{
child = new ImageItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, true, nextEditItem, FigInsType);
}
else if (MyItemInfo.MyContent.MyGrid != null)
child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, true, nextEditItem);
else
child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, true, nextEditItem);
@@ -1015,7 +1019,8 @@ namespace Volian.Controls.Library
public EditItem AddChildBefore(ItemInfo MyItemInfo, EditItem nextEditItem)
{
EditItem child = null;
//if (MyItemInfo.MyContent.ContentGridCount != 0)
if (MyItemInfo.IsFigure)
child = new ImageItem(MyItemInfo, MyStepPanel, this, ChildRelation.Before, true, nextEditItem, FigInsType);
if(MyItemInfo.MyContent.MyGrid != null)
child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.Before, true, nextEditItem);
else
@@ -1045,6 +1050,7 @@ namespace Volian.Controls.Library
SaveContents();
ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter(text);
AddGridIfNeeded(newItemInfo);
AddImageIfNeeded(newItemInfo);
DoAddSiblingAfter(newItemInfo, updateStatus);
if (MyStepPanel.SelectedEditItem is RTBItem)
{
@@ -1079,11 +1085,21 @@ namespace Volian.Controls.Library
}
}
}
// This logic allows us to do an Insert Before and Insert After while on a Figure
// if allowed by the format. Note that Before/After for figures is only Clipboard (if
// image data exists in clipboard), or file. Doing RO images will be added later if needed -
// this decision was made because of scope.
private void AddImageIfNeeded(ItemInfo newItemInfo)
{
if (this is ImageItem) ImageItem.AddImageIfNeeded(newItemInfo);
}
public void AddSiblingAfter(int? type, bool updateStatus)
{
SaveContents();
ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter("", "", type);
AddGridIfNeeded(newItemInfo);
AddImageIfNeeded(newItemInfo);
DoAddSiblingAfter(newItemInfo, updateStatus);
if (MyStepPanel.SelectedEditItem is RTBItem)
{
@@ -1129,6 +1145,7 @@ namespace Volian.Controls.Library
SaveContents();
ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore("", "",type);
AddGridIfNeeded(newItemInfo);
AddImageIfNeeded(newItemInfo);
DoAddSiblingBefore(newItemInfo, updateStatus);
}
public void AddSiblingBefore(string text, bool updateSelection)
@@ -1142,6 +1159,7 @@ namespace Volian.Controls.Library
SaveContents();
ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore(text);
AddGridIfNeeded(newItemInfo);
AddImageIfNeeded(newItemInfo);
DoAddSiblingBefore(newItemInfo, updateSelection);
if (MyStepPanel.SelectedEditItem is RTBItem)
{
@@ -1207,6 +1225,13 @@ namespace Volian.Controls.Library
MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
specialAdd = false;
}
private ImageItem.E_ImageSource FigInsType = ImageItem.E_ImageSource.None;
public void AddChild(E_FromType fromType, int type, ImageItem.E_ImageSource newSource)
{
FigInsType = newSource;
AddChild("", fromType, type, null);
FigInsType = ImageItem.E_ImageSource.None;
}
public void AddChild(E_FromType fromType, int type)
{
AddChild("", fromType, type, null);
@@ -2511,6 +2536,10 @@ namespace Volian.Controls.Library
{
AdjustTableWidthAndLocation();
}
else if (MyStepData.Type.Contains("Figure"))
{
AdjustTableWidthAndLocation();
}
else
{
if (MyItemInfo.FormatStepData.StepLayoutData.AlignWithParentTab)
@@ -2696,7 +2725,9 @@ namespace Volian.Controls.Library
if (_MyPreviousEditItem != null)
{
_IgnoreResize = true;
if (MyStepData != null && (MyStepData.Type.ToLower().Contains("table") || MyStepData.ParentType.ToLower().Contains("table")))
// the table code goes through the following, rather than 'istablepart'
if (MyStepData != null && ((MyStepData.Type.ToLower().Contains("table") || MyStepData.ParentType.ToLower().Contains("table"))||
(MyStepData.Type.ToLower().Contains("figure") || MyStepData.ParentType.ToLower().Contains("figure"))))
{
ItemWidth = TableWidth;
Location = new Point(_MyPreviousEditItem.Left, FindTop(_MyPreviousEditItem.BottomMostEditItem.Bottom));
@@ -2868,6 +2899,11 @@ namespace Volian.Controls.Library
if (itemInfo.IsStep && itemInfo.FormatStepData.Type == "TitleWithTextBelow" &&
((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd))
ContentWidth = myParentEditItem.ContentWidth;
if (itemInfo.IsStep && itemInfo.MyParent.IsFigure)
{
ContentWidth = myParentEditItem.MyParentEditItem.ContentWidth;
Left = MyParentEditItem.MyParentEditItem.Left + MyParentEditItem.MyParentEditItem.TabLeft;
}
if (myChildRelation == ChildRelation.None)
{
@@ -3013,6 +3049,12 @@ namespace Volian.Controls.Library
X = gi.MyFlexGrid.Right+2;
H = gi.MyFlexGrid.Height;
}
else if (this is ImageItem)
{
ImageItem ii = this as ImageItem;
X = ii.MyPictureBox.Right + 4;
H = ii.MyPictureBox.Height;
}
else
{
RTBItem ri = this as RTBItem;

View File

@@ -0,0 +1,995 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;
using VEPROMS.CSLA.Library;
namespace Volian.Controls.Library
{
public partial class ImageItem : EditItem
{
#region IEditItem
// set this for the imageitem so that other code (menuing/ribbons/treeview, etc) will continue to work. Include the MyItemInfo
public override StepRTB MyStepRTB
{
get { return _MyStepRTB; }
}
public override int TableWidth
{
get
{
return (int)_MyPictureBox.Width + ImageMargin;
}
}
/// <summary>
/// The left edge of the Tab
/// </summary>
public override int ItemLeft
{
get { return Left + lblTab.Left; }
set { Left = value - lblTab.Left; }
}
/// <summary>
/// The Location of the Tab
/// </summary>
public override Point ItemLocation
{
get { return new Point(Location.X + lblTab.Left, Location.Y); }
set { Location = new Point(value.X - lblTab.Left, value.Y); }
}
/// <summary>
/// Width of the Tab and Image
/// </summary>
public override int ItemWidth
{
get { return Width - lblTab.Left; }
set
{
Width = ImageMargin + value + lblTab.Left;
}
}
/// <summary>
/// Width of the PictureBox
/// </summary>
public override int ContentWidth
{
get { return _MyPictureBox.Width; }
set
{
Width = value + lblTab.Left + lblTab.Width;
}
}
public override int BorderWidth { get { return (_MyPictureBox.Width - _MyPictureBox.ClientRectangle.Width); } }
/// <summary>
/// Location of the PictureBox
/// </summary>
public override Point ContentLocation
{
get { return new Point(Location.X + _MyPictureBox.Left, Location.Y); }
set { Location = new Point(value.X - _MyPictureBox.Left, value.Y); }
}
/// <summary>
/// Left edge of the PictureBox
/// </summary>
public override int ContentLeft
{
get { return Left + _MyPictureBox.Left; }
}
override public void AdjustTableWidthAndLocation()
{
Width = Width;
Height = Height;
ItemLocation = TableLocation(MyStepSectionLayoutData, ItemWidth);
}
override public void SetToolTip(string tip)
{
DevComponents.DotNetBar.SuperTooltipInfo tpi = new DevComponents.DotNetBar.SuperTooltipInfo("", "", tip, null, null, DevComponents.DotNetBar.eTooltipColor.Lemon);
_MyToolTip.MinimumTooltipSize = new Size(0, 24);
_MyToolTip.TooltipDuration = 3;
_MyToolTip.SetSuperTooltip(MyPictureBox, tpi);
}
public override void RefreshContent()
{
IdentifyMe(false);
Volian.Base.Library.vlnStackTrace.ShowStackLocal("refreshcontents", 2);
RefreshDisplay(false);
SetExpandAndExpander(MyItemInfo);
}
public override void RefreshOrdinal()
{
TabFormat = null;
}
public override void HandleResize() {}
public override void MatchExpanded() {}
/// <summary>
/// Sets the focus to this ImageItem
/// </summary>
public override void ItemSelect()
{
if (!_MyPictureBox.Disposing)
{
_MyPictureBox.Focus();
}
else
{
_MyLog.WarnFormat("Attempt to give Focus to Disposed Object {0}", MyID);
}
ScrollToCenter();
}
/// <summary>
/// Sets the focus to this ImageItem
/// </summary>
public override void ItemShow()
{
_MyPictureBox.Focus();
ScrollToCenter();
}
public override void SetActive()
{
this.BackColor = MyStepPanel.ActiveColor;
}
public override void SetText()
{
LastMethodsPush("SetText");
if (MyItemInfo != null)
{
IdentifyMe(false);
}
LastMethodsPop();
}
public override void SetExpandAndExpander(ItemInfo itemInfo)
{
CanExpand = false;
}
public override void SaveCurrentAndContents()
{
SaveContents();
}
public override void RefreshDisplay(bool activeMode)
{
if (MyItemInfo.MyContent.MyImage == null) return; // new figure
FileName = MyItemInfo.MyContent.MyImage.FileName;
InsType = FileName.ToUpper() == "PASTE.JPG" ? E_ImageSource.Clipboard : E_ImageSource.File;
System.Drawing.Image img = byteArrayToImage(MyItemInfo.MyContent.MyImage.Data);
MyPictureBox.Image = img;
MyPictureBox.Visible = true;
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
if (ic != null && ic.Image_Height != 0)
{
_origCfgWd = ic.Image_Width * MyStepPanel.DPI / 72;
_origCfgHt = ic.Image_Height * MyStepPanel.DPI / 72;
}
SetWidthsAndHeights(img);
//need this to trigger update of steptabribbonbuttons:
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetButtonAndMenuEnabling(true);
}
public override void ToggleEditView(E_ViewMode vwMode) {}
public override string TabFormat
{
get { return null; }
set { ;}
}
public override bool Expanded
{
get { return true; }
set { ; }
}
public override bool CanExpand
{
get { return false; }
set { ; }
}
public override int TabLeft { get { return lblTab.Left; } set { lblTab.Left = value; } } //taken from griditem
public override Font TabFont { get { return MyStepRTB.Font; } set { ; } }
public override string TabText { get { return lblTab.Text; } }
public override Point TabLocation { get { return lblTab.Location; } }
public override Font ContentFont { get { return MyStepRTB.Font; } set { /*MyStepRTB.Font = value*/; } }
public override float ContentTop { get { return MyPictureBox.Top; } }
public override DialogResult ReplaceText(string rpltxt, string fndstr, bool caseSensitive, bool matchWholeWord, bool reverse, bool prompt, IWin32Window fndrpldlg)
{
return DialogResult.OK;
}
public override bool FindText(string str, bool caseSensitive, bool matchWholeWord, bool reverse)
{
return false;
}
public override void PositionToEnd()
{
return;
}
public override void PositionToStart()
{
return;
}
public override string SelectedTextForFind
{
get { return null; }
}
public override bool SpellCheckNext()
{
return true;
}
public override bool Empty
{
get
{
return _MyPictureBox.Image == null;
}
set { _MyPictureBox.Image = null; }
}
public override void RefreshTab()
{
TabFormat = null;
}
public override void SetupHeader(ItemInfo itemInfo) { }
public override void ShowExpanded() { }
#endregion
#region Properties
public enum E_ImageSource : int
{
None = 0, Clipboard = 1, File = 2, RoFigure = 3
}
public System.Windows.Forms.PictureBox MyPictureBox
{
get { return _MyPictureBox; }
}
private string FileName = null;
private static int _ImageMargin = 18;
/// <summary>
/// Margin between the EditItem and the ImageItem. Appears on the Right.
/// Will allow space to draw a Change Bar on the right side of the EditItem.
/// </summary>
public static int ImageMargin
{
get { return _ImageMargin; }
set { _ImageMargin = value; }
}
private bool _IsDirty = false;
private int _origCfgHt = 0; // keep track if original size was stored in cfg
private int _origCfgWd = 0;
private bool _pastedNew = false; // need this for flagging newly pasted image (may need to clear cfg)
#endregion
#region Constructors
public ImageItem()
{
InitializeComponent();
}
// the following displays for existing images
public ImageItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand)
{
InitializeComponent();
MyItemInfo = itemInfo;
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null, false);
if (MyItemInfo.MyContent.MyImage != null && MyItemInfo.MyContent.MyImage.Data != null) // this is figure/image (not RO)
{
FileName = MyItemInfo.MyContent.MyImage.FileName;
InsType = FileName.ToUpper() == "PASTE.JPG" ? E_ImageSource.Clipboard : E_ImageSource.File;
System.Drawing.Image img = byteArrayToImage(MyItemInfo.MyContent.MyImage.Data);
MyPictureBox.Image = img;
MyPictureBox.Visible = true;
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
if (ic != null && ic.Image_Height != 0) // embedded image (not RO)
{
_origCfgWd = ic.Image_Width * MyStepPanel.DPI / 72;
_origCfgHt = ic.Image_Height * MyStepPanel.DPI / 72;
}
SetWidthsAndHeights(img);
}
else
{
// get ro image data from link within the steprtb:
HandleRoImage();
DisplayText vlntxt = new DisplayText(MyItemInfo, E_EditPrintMode.Edit, E_ViewMode.View, false, E_FieldToEdit.Text, true, null, null, false);
MyStepRTB.OrigDisplayText = vlntxt;
InsType = E_ImageSource.RoFigure;
}
AdjustTableWidthAndLocation();
AddEventHandlers();
MyStepRTB.RemoveEventHandlers();
MyStepRTB.Visible = false;
}
private int _newSizeWd = 0;
private int _newSizeHt = 0;
public void SizeImage(int wd, int ht)
{
MyPictureBox.Width = wd;
MyPictureBox.Height = ht;
MyPictureBox.SizeMode = PictureBoxSizeMode.Zoom;
this.Width = MyPictureBox.Width + ImageMargin;
this.Height = MyPictureBox.Height + 10;
_newSizeWd = wd / (MyStepPanel.DPI / 72);
_newSizeHt = ht / (MyStepPanel.DPI / 72);
if (!MyItemInfo.FormatStepData.StepEditData.TypeMenu.MenuItem.ToUpper().Contains("AER")) ItemLocation = TableLocation(MyStepSectionLayoutData, ItemWidth);
_IsDirty = true;
}
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 ht = img.Height * MyStepPanel.DPI / 72;
if (MyItemInfo.MyContent.MyImage != null) // image is null if creating new.
{
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
if (!_pastedNew && ic != null && ic.Image_Height != 0)
{
wd = ic.Image_Width * MyStepPanel.DPI / 72;
ht = ic.Image_Height * MyStepPanel.DPI / 72;
}
}
MyPictureBox.Visible = true;
MyPictureBox.Width = wd;
MyPictureBox.Height = ht;
MyPictureBox.SizeMode = PictureBoxSizeMode.Zoom; // as resize matches width/height.
this.Width = MyPictureBox.Width + ImageMargin;
this.Height = MyPictureBox.Height + 10;
}
// the following gets called for 'NEW' images
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)
{
InitializeComponent();
MyItemInfo = itemInfo;
if (MyItemInfo.MyContent.MyImage != null && MyItemInfo.MyContent.MyImage.Data != null) // this is figure/image (not RO)
{
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem, false);
FileName = MyItemInfo.MyContent.MyImage.FileName;
InsType = FileName.ToUpper() == "PASTE.JPG" ? E_ImageSource.Clipboard : E_ImageSource.File;
System.Drawing.Image img = byteArrayToImage(MyItemInfo.MyContent.MyImage.Data);
MyPictureBox.Image = img;
MyPictureBox.Visible = true;
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
if (ic != null && ic.Image_Height != 0) // embedded image (not RO)
{
_origCfgWd = ic.Image_Width * MyStepPanel.DPI / 72;
_origCfgHt = ic.Image_Height * MyStepPanel.DPI / 72;
}
SetWidthsAndHeights(img);
}
else if (MyItemInfo.MyContent.Text != null && MyItemInfo.MyContent.Text.ToUpper().Contains("RO"))
{
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem, false);
// get ro image data from link within the steprtb:
HandleRoImage();
DisplayText vlntxt = new DisplayText(MyItemInfo, E_EditPrintMode.Edit, E_ViewMode.View, false, E_FieldToEdit.Text, true, null, null, false);
MyStepRTB.OrigDisplayText = vlntxt;
InsType = E_ImageSource.RoFigure;
}
else
{
InsType = insType;
FileName = null;
//InitializeComponent();
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem, false);
MyPictureBox.Width = 100;
MyPictureBox.Height = 100;
this.Width = 100 + ImageMargin;
this.Height = 100;
if (insType == ImageItem.E_ImageSource.File)
{
ImageFileDialog();
}
else if (insType == ImageItem.E_ImageSource.Clipboard)
{
// see if there is an image in clipboard and if so, insert it:
System.Drawing.Image img = Clipboard.GetImage();
if (img != null)
{
MyPictureBox.Image = img;
SetWidthsAndHeights(img);
string ext = GetImageFormatExtension(img);
FileName = "paste." + ext;
_IsDirty = true;
}
}
else // this is an Ro image - use displaytext and steprtb to get image data
{
DisplayText vlntxt = new DisplayText(MyItemInfo, E_EditPrintMode.Edit, E_ViewMode.View, false, E_FieldToEdit.Text, true, null, null, false);
MyStepRTB.OrigDisplayText = vlntxt;
}
}
AdjustTableWidthAndLocation();
this.Controls.Add(this._MyPictureBox);
AddEventHandlers();
MyStepRTB.RemoveEventHandlers();
MyStepRTB.Visible = false;
}
private void ImageFileDialog()
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "Image files (*.jpg;*.tif;*.bmp;*.png)|*.jpg;*.tif;*.bmp;*.png|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 0;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
// check that it is an image
System.Drawing.Image img = System.Drawing.Image.FromFile(openFileDialog1.FileName);
if (img != null)
{
FileName = openFileDialog1.FileName;
MyPictureBox.Image = img;
SetWidthsAndHeights(img);
_IsDirty = true;
}
}
catch (Exception ex)
{
MessageBox.Show("Could not create image, check file type.", "Error on Image File Selection");
return;
}
}
}
//public static System.Drawing.Imaging.ImageFormat GetImageFormat(this System.Drawing.Image img)
//{
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Jpeg))
// return System.Drawing.Imaging.ImageFormat.Jpeg;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Bmp))
// return System.Drawing.Imaging.ImageFormat.Bmp;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Png))
// return System.Drawing.Imaging.ImageFormat.Png;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Emf))
// return System.Drawing.Imaging.ImageFormat.Emf;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Exif))
// return System.Drawing.Imaging.ImageFormat.Exif;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Gif))
// return System.Drawing.Imaging.ImageFormat.Gif;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Icon))
// return System.Drawing.Imaging.ImageFormat.Icon;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.MemoryBmp))
// return System.Drawing.Imaging.ImageFormat.MemoryBmp;
// if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Tiff))
// return System.Drawing.Imaging.ImageFormat.Tiff;
// else
// return System.Drawing.Imaging.ImageFormat.Wmf;
//}
private static string GetImageFormatExtension(System.Drawing.Image img)
{
return ("jpg"); // seems that this is the only one that works.
/*
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Jpeg))
return "jpg";
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Bmp))
return "bmp";
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Png))
return "png";
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Emf))
return "emf";
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Gif))
return "gif";
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Icon))
return "ico";
if (img.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Tiff))
return "tif";
else
return "wmf";
*/
}
#endregion
#region RO_Images
public void HandleRoImage()
{
string imageText = null;
ProcedureInfo proc = MyItemInfo.MyProcedure;
DocVersionInfo dvi = proc.MyDocVersion;
ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst;
ROFSTLookup lookup = rofst.GetROFSTLookup(dvi);
string linkInfoText = MyItemInfo.MyContent.Text.Replace(@"\u8209?", "-");
int ind = linkInfoText.IndexOf("[END>"); // found cases where the ro figure had 2 links stored within content->text (BGE data)
if (ind > 0)
{
int indx = linkInfoText.IndexOf("[END>", ind + 3);
if (indx > -1)
{
// link is duplicated (bad data), but handle it:
linkInfoText = linkInfoText.Substring(0, linkInfoText.IndexOf(@"\v ", ind + 3));
}
}
linkInfoText = linkInfoText.Replace(@"\v ", "");
Match m = Regex.Match(linkInfoText, @"(.*)[#]Link:([A-Za-z]*):(.*)");
string val = null;
if (m.Length > 0) // if m.lengh is zero, then no match was found - no RO was entered in the figure substep
{
if (m.Groups.Count < 4)
{
val = string.Format("{0}\n{1}\n{2}n{3}",
linkInfoText.Substring(0, linkInfoText.Length - 16),
linkInfoText.Substring(linkInfoText.Length - 16, 8),
linkInfoText.Substring(linkInfoText.Length - 8, 4),
linkInfoText.Substring(linkInfoText.Length - 4, 4));
val = val.Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); // replace dash and backslash symbols with dash and backslash characters
}
else
{
string[] subs = m.Groups[3].Value.Split(" ".ToCharArray());
val = lookup.GetRoValue(subs[1]);
if (val == null || val == "?") val = lookup.GetRoValue(subs[1].Substring(0, 12));
if (val == "?")
{
// Do 'empty' image box.
//_MyLog.WarnFormat("\r\nMissing Referenced Object {0} in {1}", subs[1], itemInfo.ShortPath);
}
}
}
GC.Collect(); // memory garbage collection (Regex memory bug)
if (val != null && val != "?")
{
string imgname = null;
int W = 0;
int H = 0;
string[] vals = val.Split("\n".ToCharArray());
W = (int)(Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips);
int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier);
H = lines * 12;
try
{
imgname = vals[0];
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]);
if (roImage != null)
imageText = val;
else
{
roImage = rofst.GetROImageByFilename(vals[0], MyItemInfo);// need code to go and get an ROImaage if it exists
if (roImage != null)
imageText = val;
}
AddROImageToScreen(W, H, imageText);
}
catch (Exception ex)
{
string msg = string.Format("Could not display image {0}.", imgname);
MessageBox.Show(msg);
}
}
}
public bool ThumbnailCallback()
{
return false;
}
public void AddROImageToScreen(int w, int h, string imageText)
{
string[] vals = imageText.Split("\n".ToCharArray());
ProcedureInfo proc = MyItemInfo.MyProcedure;
DocVersionInfo dvi = proc.ActiveParent as DocVersionInfo;
ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst;
ROImageInfo roImageInfo = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]);
if (roImageInfo == null) roImageInfo = rofst.GetROImageByFilename(vals[0], MyItemInfo);
if (roImageInfo != null)
{
System.Drawing.Image.GetThumbnailImageAbort myCallback =
new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
ROImageConfig rc = new ROImageConfig(roImageInfo);
int size = Convert.ToInt32(rc.Image_Size);
byte[] cnt = roImageInfo.Content;
byte[] dcnt = ROImageInfo.Decompress(cnt, size);
MemoryStream ms = new MemoryStream(dcnt);
System.Drawing.Image img2 = System.Drawing.Image.FromStream(ms);
// if there is config data that saves the resize of the image, use it, otherwise use what was passed in:
StepConfig sc = new StepConfig(MyItemInfo as StepInfo);
SizeF sizef = new Size(1, 1);
if (sc.Step_ImageHeight == null || sc.Step_ImageHeight == 0)
{
sizef = new SizeF((img2.Width / img2.HorizontalResolution),
(img2.Height / img2.VerticalResolution));
float fscale = Math.Min(w / sizef.Width, h / sizef.Height);
sizef.Width *= fscale;
sizef.Height *= fscale;
}
else
{
sizef = new Size(sc.Step_ImageWidth, sc.Step_ImageHeight);
}
System.Drawing.Image img = img2.GetThumbnailImage((int)sizef.Width, (int)sizef.Height, myCallback, IntPtr.Zero);
MyPictureBox.Image = img;
SetWidthsAndHeights(img);
}
}
#endregion
#region EventHandlers
private void ImageItem_Enter(object sender, EventArgs e)
{
if (MyStepPanel.DisplayItemChanging) return;
SetMenu("OpenContextMenu");
MyStepPanel.SelectedEditItem = this;
}
private void AddEventHandlers()
{
// Always be sure to add the same event handlers to RemoveEventHandlers
MyItemInfo.MyContent.Changed += new VEPROMS.CSLA.Library.ContentInfoEvent(MyContent_Changed);
this.Enter += new System.EventHandler(ImageItem_Enter);
this.MyPictureBox.Enter += new System.EventHandler(ImageItem_Enter);
this.Click += new EventHandler(ImageItem_Click);
this.MyPictureBox.Click += new EventHandler(ImageItem_Click);
this.MyPictureBox.PreviewKeyDown += new PreviewKeyDownEventHandler(ImageItem_PreviewKeyDown); //note that PictureBox does not have cursorkey events
this.MyPictureBox.KeyDown += new KeyEventHandler(ImageItem_KeyDown);
this.MyStepRTB.RoInsert += new StepRTBRoEvent(MyStepRTB_RoInsert);
this.MyStepRTB.DoSaveContents += new StepRTBEvent(MyStepRTB_DoSaveContents); // for storing RO data
this.MyPictureBox.Resize += MyPictureBox_Resize;
this.MyPictureBox.MouseDown += MyPictureBox_MouseDown;
}
void MyPictureBox_MouseDown(object sender, MouseEventArgs e)
{
SetMenu("OpenContextMenu");
}
void MyPictureBox_Resize(object sender, EventArgs e)
{
if (this.Height != _MyPictureBox.Height + _MyPictureBox.Top + 7) // add in 7 to make it look good // + 10)
{
LastMethodsPush(string.Format("MyPictureBox_Resize {0}", _MyPictureBox.Height));
this.Height = _MyPictureBox.Height + _MyPictureBox.Top + 7;
LastMethodsPop();
}
}
private void RemoveEventHandlers()
{
// Always be sure to add the same event handlers to RemoveEventHandlers
MyItemInfo.MyContent.Changed -= new VEPROMS.CSLA.Library.ContentInfoEvent(MyContent_Changed);
this.Enter -= new System.EventHandler(ImageItem_Enter);
this.MyPictureBox.Enter -= new System.EventHandler(ImageItem_Enter);
this.Click -= new EventHandler(ImageItem_Click);
this.MyPictureBox.Click -= new EventHandler(ImageItem_Click);
this.MyPictureBox.PreviewKeyDown -= new PreviewKeyDownEventHandler(ImageItem_PreviewKeyDown);
this.MyPictureBox.KeyDown -= new KeyEventHandler(ImageItem_KeyDown);
this.MyStepRTB.RoInsert -= new StepRTBRoEvent(MyStepRTB_RoInsert);
this.MyStepRTB.DoSaveContents -= new StepRTBEvent(MyStepRTB_DoSaveContents);
this.MyPictureBox.Resize -= MyPictureBox_Resize;
this.MyPictureBox.MouseDown -= MyPictureBox_MouseDown;
}
void ImageItem_Click(object sender, EventArgs e)
{
if (MyStepPanel.DisplayItemChanging) return;
MyStepPanel.SelectedEditItem = this;
}
// the PictureBox does not have cursor key event support - did this by previewing keydowns and
// if the key is arrow up/down, do associated cursormovement through the StepPanel
void ImageItem_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Up:
MyStepPanel.CursorMovement(this, new Point(0, 0), E_ArrowKeys.Up);
break;
case Keys.Down:
MyStepPanel.CursorMovement(this, new Point(0, 0), E_ArrowKeys.Down);
break;
}
}
void ImageItem_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control)
{
switch (e.KeyCode)
{
case Keys.V: // handle paste of an image
if (MyStepPanel.VwMode == E_ViewMode.View)
{
e.Handled = true;
return;
}
if (InsType == E_ImageSource.RoFigure && MyItemInfo.MyContent.MyImage == null) // on an RO image
{
MessageBox.Show("Cannot replace an existing RO figure/image. Use the Step Properties panel/RO tab.", "Warning, no paste/replace for RO images.");
e.Handled = true;
return;
}
PasteImage();
e.Handled = true;
return;
}
}
}
public void PasteImage()
{
bool setdata = false;
System.Drawing.Image img = Clipboard.GetImage();
if (img == null) // let user know there is no valid data in clipboard:
{
MessageBox.Show(this, "The clipboard does not contain image data.", "Cannot paste.", MessageBoxButtons.OK);
return;
}
if (MyItemInfo.MyContent.MyImage != null && img != null) // see if there already is an image and if so - ask if user wants to replace.
{
if (MessageBox.Show(this, "Do you want to replace the existing image?", "Confirm Image Replace", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
{
setdata = true;
}
}
else if (img != null) // no existing image, be sure there is valid data in clipboard
setdata = true;
if (setdata)
{
_IsDirty = true;
_pastedNew = true;
MyPictureBox.Image = img;
SetWidthsAndHeights(img);
string ext = GetImageFormatExtension(img);
FileName = "paste." + ext;
}
}
void MyStepRTB_RoInsert(object sender, StepRTBRoEventArgs args)
{
int sel = MyStepRTB.SelectionStart + args.ValText.Length;
_IsDirty = true;
InsType = E_ImageSource.RoFigure;
MyStepRTB.UpdateStepRtb(args.LinkText, args.ValText);
HandleRoImage();
}
void MyStepRTB_DoSaveContents(object sender, EventArgs args)
{
_IsDirty = true;
InsType = E_ImageSource.RoFigure;
SaveCurrentAndContents();
HandleRoImage();
}
#endregion
#region ContextMenu
void SetMenu(string contentMenu)
{
if (contentMenu == null)
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ClearContextMenu();
else if (contentMenu == "OpenContextMenu")
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetContextMenuImage(this);
}
#endregion
#region Methods
public override void SetFocus()
{
MyPictureBox.Focus();
}
public override void SaveContents()
{
MyStepRTB.Visible = false;
if (!_IsDirty) return;
if (InsType != E_ImageSource.None && InsType != E_ImageSource.RoFigure)
{
SaveImage();
}
else if (InsType == E_ImageSource.RoFigure)
{
if (MyStepRTB.OrigDisplayText == null)
{
DisplayText vlntxt = new DisplayText(MyItemInfo, E_EditPrintMode.Edit, E_ViewMode.View, false, E_FieldToEdit.Text, true, null, null, false);
MyStepRTB.OrigDisplayText = vlntxt;
}
bool success = MyStepRTB.OrigDisplayText.Save((RichTextBox)MyStepRTB);
if (success && _newSizeHt != 0)
{
StepConfig sc = new StepConfig(MyItemInfo as StepInfo);
sc.Step_ImageWidth = (int)(_newSizeWd / (MyStepPanel.DPI / 72f));
sc.Step_ImageHeight = (int)(_newSizeHt / (MyStepPanel.DPI / 72f));
using (Item item = MyItemInfo.Get())
{
item.MyContent.Config = sc.ToString();
item.Save();
}
}
}
_IsDirty = false;
}
public void SaveImage()
{
try
{
using (Item _MyItem = MyItemInfo.Get())
{
byte[] imgToByte = imageToByteArray(MyPictureBox.Image, FileName);
int origLen = imgToByte.Length;
bool compressed = false;
// if file is a tif or bmp see if compressing it saves space and if so, save the
// compressed data with a flag in config, the size needed to decompress, to show it is compressed.
if (FileName.ToUpper().EndsWith(".TIF") || FileName.ToUpper().EndsWith(".BMP"))
{
byte[] cmp = ROImageInfo.Compress(imgToByte);
if (origLen > cmp.Length)
{
imgToByte = cmp;
compressed = true;
}
}
ImageConfig imgCfg = null;
if (_pastedNew && compressed)
{
imgCfg = new ImageConfig();
imgCfg.Image_DataSize = origLen;
_MyItem.MyContent.MyImage.Config = imgCfg.ToString();
}
else if (_newSizeHt != 0)
{
if (MyItemInfo.MyContent.MyImage == null && imgCfg == null)
imgCfg = new ImageConfig();
else if (imgCfg == null)
imgCfg = new ImageConfig(MyItemInfo.MyContent.MyImage);
imgCfg.Image_Width = (int)(_newSizeWd / (MyStepPanel.DPI / 72f));
imgCfg.Image_Height = (int)(_newSizeHt / (MyStepPanel.DPI / 72f));
if (compressed) imgCfg.Image_DataSize = origLen;
_MyItem.MyContent.MyImage.Config = imgCfg.ToString();
}
else if (compressed)
{
if (MyItemInfo.MyContent.MyImage == null && imgCfg == null)
imgCfg = new ImageConfig();
else if (imgCfg == null)
imgCfg = new ImageConfig(MyItemInfo.MyContent.MyImage);
imgCfg.Image_DataSize = origLen;
_MyItem.MyContent.MyImage.Config = imgCfg.ToString();
}
_MyItem.MyContent.MyImage.Data = imgToByte;
_MyItem.MyContent.MyImage.FileName = FileName;
_MyItem.MyContent.MyImage.ImageType = 1;
_MyItem.MyContent.MyImage.DTS = DateTime.Now;
_MyItem.MyContent.MyImage.UserID = Volian.Base.Library.VlnSettings.UserID;
_MyItem.MyContent.DTS = DateTime.Now;
_MyItem.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
_MyItem.Save();
}
StepConfig sc = MyItemInfo.MyConfig as StepConfig;
// if the plant has the change id option, the change id was entered when the program started.
// this should be saved for every piece of edited data. Note that the set of config
// item Step_MultipleChangeID has the save built in to it.
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds
&& !this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.EditorialChange)
{
if (sc == null) sc = new StepConfig();
sc.Step_ChangeID = this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.ChgId;
}
// We saved changes. Reset the change bar override.
// IF there is a step config remove the change bar override by setting the CBOverride value to null
// This fixes a problem reported by Farly where if the change bar or overridden to be off, the next
// time a change was made, the change bar remained turned off.
if (sc != null)
sc.Step_CBOverride = null; // clear the change bar override
MyStepRTB.ClearUndo();
}
catch (Exception ex)
{
MessageBox.Show("The image could not be saved.", "Image Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
_newSizeHt = 0;
_newSizeWd = 0;
}
public static byte[] imageToByteArray(System.Drawing.Image imageIn, string fname)
{
// get filename's extension to map to imageformat:
string ext = fname.Substring(fname.IndexOf(".")+1).ToUpper();
System.Drawing.Imaging.ImageFormat ifmt = System.Drawing.Imaging.ImageFormat.Gif;
switch (ext)
{
case ("JPG"):
ifmt = System.Drawing.Imaging.ImageFormat.Jpeg;
break;
case ("TIF"):
ifmt = System.Drawing.Imaging.ImageFormat.Tiff;
break;
case ("WMF"):
ifmt = System.Drawing.Imaging.ImageFormat.Wmf;
break;
case ("BMP"):
ifmt = System.Drawing.Imaging.ImageFormat.Bmp;
break;
case ("EMF"):
ifmt = System.Drawing.Imaging.ImageFormat.Emf;
break;
case ("GIF"):
ifmt = System.Drawing.Imaging.ImageFormat.Gif;
break;
case ("ICO"):
ifmt = System.Drawing.Imaging.ImageFormat.Icon;
break;
case ("PNG"):
ifmt = System.Drawing.Imaging.ImageFormat.Png;
break;
default:
MessageBox.Show("Invalid File Type");
return null;
}
MemoryStream ms = new MemoryStream();
imageIn.Save(ms, ifmt);
return ms.ToArray();
}
public System.Drawing.Image byteArrayToImage(byte[] byteArrayIn)
{
// if there is config data, DataSize, then decompress the data:
ImageConfig imgCfg = new ImageConfig(MyItemInfo.MyContent.MyImage);
if (imgCfg.Image_DataSize > 0) byteArrayIn = ROImageInfo.Decompress(byteArrayIn, imgCfg.Image_DataSize);
MemoryStream ms = new MemoryStream(byteArrayIn);
System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
return returnImage;
}
// the following is used if an image is being inserted using Before/after from steptabribbon:
public static void AddImageIfNeeded(ItemInfo newItemInfo)
{
string filename = null;
System.Drawing.Image img = Clipboard.GetImage();
if (img != null)
{
// Ask user if they want to use the clipboard image.
DialogResult dr = MessageBox.Show("Clipboard has an image, use this (select Yes) or select a file (select No)?", "Insert Image Before/After", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
string ext = ImageItem.GetImageFormatExtension(img);
filename = "paste." + ext;
}
else
img = null;
}
if (img==null)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "Image files (*.jpg;*.tif;*.bmp;*.png)|*.jpg;*.tif;*.bmp;*.png|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 0;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
// check that it is an image
img = System.Drawing.Image.FromFile(openFileDialog1.FileName);
if (img != null) filename = openFileDialog1.FileName;
}
if (filename == null) return; // user must have existed out. How to handle??
}
byte[] imgToByte = imageToByteArray(img, filename);
int origLen = imgToByte.Length;
bool compressed = false;
// if file is a tif or bmp see if compressing it saves space and if so, save the
// compressed data with a flag in config, the size needed to decompress, to show it is compressed.
if (filename.ToUpper().EndsWith(".TIF") || filename.ToUpper().EndsWith(".BMP"))
{
byte[] cmp = ROImageInfo.Compress(imgToByte);
if (origLen > cmp.Length)
{
imgToByte = cmp;
compressed = true;
}
}
using (Item _MyItem = newItemInfo.Get())
{
ImageConfig imgCfg = null;
if (compressed)
{
imgCfg = new ImageConfig();
imgCfg.Image_DataSize = origLen;
_MyItem.MyContent.MyImage.Config = imgCfg.ToString();
}
_MyItem.MyContent.MyImage.Data = imgToByte;
_MyItem.MyContent.MyImage.FileName = filename;
_MyItem.MyContent.MyImage.ImageType = 1;
_MyItem.MyContent.MyImage.DTS = DateTime.Now;
_MyItem.MyContent.MyImage.UserID = Volian.Base.Library.VlnSettings.UserID;
_MyItem.MyContent.DTS = DateTime.Now;
_MyItem.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
_MyItem.Save();
}
}
public override void IdentifyMe(bool highlight)
{
if (highlight)
this.BackColor = Color.Gray;
else
{
if (MyPictureBox.Focused || this.Focused) // If active Set BackColor to the active color
this.BackColor = MyStepPanel.ActiveColor;
else // note that the 'inactive' color is actually MyStepPanel.PanelColor
this.BackColor = MyItemInfo.ItemAnnotationCount == 0 ? MyStepPanel.PanelColor : MyStepPanel.AnnotationColor;
}
}
#endregion
}
}

View File

@@ -0,0 +1,149 @@
namespace Volian.Controls.Library
{
partial class ImageItem
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this._MyPictureBox = new System.Windows.Forms.PictureBox();
this._MyStepRTB = new Volian.Controls.Library.StepRTB(this.components);
this._MyStepRTB.Location = new System.Drawing.Point(0, -20); // position richtextbox outside visible range
this.lblTab = new System.Windows.Forms.Label();
this._MyToolTip = new DevComponents.DotNetBar.SuperTooltip();
//this._MyvlnExpander = new Volian.Controls.Library.vlnExpander();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.SuspendLayout();
//
// _MyPictureBox
//
this._MyToolTip.SetSuperTooltip(this._MyPictureBox, new DevComponents.DotNetBar.SuperTooltipInfo("Figure", "", "The input image will be displayed here as a figure.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, true, new System.Drawing.Size(150, 80)));
this._MyPictureBox.Location = new System.Drawing.Point(7, 5);
this._MyPictureBox.Name = "_MyPictureBox";
//
// lblTab
//
this.lblTab.BackColor = System.Drawing.Color.Transparent;
this.lblTab.Location = new System.Drawing.Point(0, 0);
this.lblTab.Name = "lblTab";
this.lblTab.Size = new System.Drawing.Size(61, 23);
this.lblTab.TabIndex = 3;
this.lblTab.Visible = false;
//this.lblTab.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lblTab_MouseDown);
//
// _MyStepRTB
//
this._MyStepRTB.Visible = false;
//this._MyStepRTB.AdjustSize = new System.Drawing.Size(0, 0);
//this._MyStepRTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
// | System.Windows.Forms.AnchorStyles.Right)));
//this._MyStepRTB.BackColor = System.Drawing.Color.Linen;
//this._MyStepRTB.BorderStyle = System.Windows.Forms.BorderStyle.None;
////KBR this._MyStepRTB.CheckAbove = "|│└┬┼├┌┴┐┤";
////KBR this._MyStepRTB.CheckBelow = "|│";
////KBR this._MyStepRTB.CheckLeft = "-─┤┬├┼┌┐└‑";
////KBR this._MyStepRTB.CheckRight = "-─‑";
this._MyStepRTB.FieldToEdit = VEPROMS.CSLA.Library.E_FieldToEdit.Text; // was text, but would not process steptabribbon button enabling. .Text;
//this._MyStepRTB.Font = new System.Drawing.Font("Prestige Elite Tall", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(2)));
//this._MyStepRTB.Location = new System.Drawing.Point(107, 0);
//this._MyStepRTB.Margin = new System.Windows.Forms.Padding(4);
//this._MyStepRTB.MyClassName = "RichEdit20W";
//this._MyStepRTB.MyItemInfo = null;
//this._MyStepRTB.MyLinkText = null;
//this._MyStepRTB.Name = "_MyStepRTB";
//this._MyStepRTB.ProcessKeystrokes = true;
//this._MyStepRTB.RTBRangeStatus = Volian.Controls.Library.StepRTB.RangeStatus.NoContainedLinks;
//this._MyStepRTB.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
//this._MyStepRTB.ShowDebug = false;
//this._MyStepRTB.Size = new System.Drawing.Size(312, 25);
//this._MyStepRTB.TabIndex = 2;
//this._MyStepRTB.Text = "";
//this._MyStepRTB.VwMode = VEPROMS.CSLA.Library.E_ViewMode.Edit;
//KBR this._MyStepRTB.LinkGoTo += new Volian.Controls.Library.StepRTBLinkEvent(this._MyStepRTB_LinkGoTo);
//this._MyStepRTB.Enter += new System.EventHandler(this._StepRTB_Enter);
//this._MyStepRTB.HeightChanged += new Volian.Controls.Library.StepRTBEvent(this._MyStepRTB_HeightChanged);
//this._MyStepRTB.ModeChange += new Volian.Controls.Library.StepRTBModeChangeEvent(this._MyStepRTB_ModeChange);
//KBR this._MyStepRTB.LinkModifyTran += new Volian.Controls.Library.StepRTBLinkEvent(this._MyStepRTB_LinkModifyTran);
//this._MyPictureBox..CursorKeyPress += new Volian.Controls.Library.StepRTBCursorKeysEvent(this._MyStepRTB_CursorKeyPress);
//this._MyPictureBox.CursorMovement += new Volian.Controls.Library.StepRTBCursorMovementEvent(this._MyStepRTB_CursorMovement);
//KBR this._MyStepRTB.LinkModifyRO += new Volian.Controls.Library.StepRTBLinkEvent(this._MyStepRTB_LinkModifyRO);
//KBR this._MyStepRTB.SetMenu += new StepRTBMenuEvent(_MyStepRTB_SetMenu);
//this._MyStepRTB.AdjustTableWidth += new StepRTBTableWidthEvent(_MyStepRTB_AdjustTableWidth);
//KBR this._MyStepRTB.IsNotCurrentSelection += new StepRTBBooleanEvent(_MyStepRTB_IsNotCurrentSelection);
//KBR this._MyStepRTB.OpenAnnotations += new StepRTBEvent(_MyStepRTB_OpenAnnotations);
//KBR this._MyStepRTB.InsertPgBrk += new StepRTBEvent(_MyStepRTB_InsertPgBrk);
//KBR this._MyStepRTB.EnterKeyPressed += new StepRTBCursorKeysEvent(_MyStepRTB_EnterKeyPressed);
//KBR this._MyStepRTB.CheckClipboard += new StepRTBBooleanEvent(_MyStepRTB_CheckClipboard);
//KBR this._MyStepRTB.CopyStep += new StepRTBEvent(_MyStepRTB_CopyStep);
//KBR this._MyStepRTB.OpenContextMenu += new StepRTBLocationEvent(_MyStepRTB_OpenContextMenu);
//KBR this._MyStepRTB.DoMouseWheel += new StepRTBMouseEvent(_MyStepRTB_DoMouseWheel);
//this._MyStepRTB.DoSaveContents += new StepRTBEvent(_MyStepRTB_DoSaveContents);
//KBR this._MyStepRTB.RoInsert += new StepRTBRoEvent(_MyStepRTB_RoInsert);
//this._MyStepRTB.Resize += new System.EventHandler(_MyStepRTB_Resize);
//this._MyvlnExpander.Attachment = false;
//this._MyvlnExpander.BackColor = System.Drawing.Color.Transparent;
//this._MyvlnExpander.BorderColor = System.Drawing.Color.Silver;
//this._MyvlnExpander.Color1 = System.Drawing.Color.Aquamarine;
//this._MyvlnExpander.Color2 = System.Drawing.Color.Violet;
//this._MyvlnExpander.Expanded = false;
//this._MyvlnExpander.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
//this._MyvlnExpander.GradientAngle = 45;
//this._MyvlnExpander.Location = new System.Drawing.Point(4, 4);
//this._MyvlnExpander.Margin = new System.Windows.Forms.Padding(5);
//this._MyvlnExpander.MyExpanderStyle = Volian.Controls.Library.ExpanderStyle.Round;
//this._MyvlnExpander.Name = "_MyvlnExpander";
//this._MyvlnExpander.PenWidth = 0;
//this._MyvlnExpander.Size = new System.Drawing.Size(17, 17);
//this._MyvlnExpander.TabIndex = 0;
//this._MyvlnExpander.Trans1 = 128;
//this._MyvlnExpander.Trans2 = 128;
//this._MyvlnExpander.WidthFactor = 7;
//this._MyvlnExpander.BeforeColapse += new Volian.Controls.Library.vlnExpanderEvent(this.vlnExp_BeforeColapse);
//this._MyvlnExpander.BeforeExpand += new Volian.Controls.Library.vlnExpanderEvent(this.vlnExp_BeforeExpand);
//
// ImageItem
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ButtonFace;
this.Controls.Add(this._MyStepRTB);
//this.Controls.Add(this._MyvlnExpander);
this.Controls.Add(this._MyPictureBox);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "ImageItem";
this.Size = new System.Drawing.Size(419, 25);
//this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lblTab_MouseDown);
this.ResumeLayout(false);
}
private StepRTB _MyStepRTB;
private System.Windows.Forms.PictureBox _MyPictureBox;
private System.Windows.Forms.Label lblTab;
private DevComponents.DotNetBar.SuperTooltip _MyToolTip;
#endregion
}
}

View File

@@ -198,7 +198,10 @@ namespace Volian.Controls.Library
}
#endregion
#region Properties and Variables
public bool IsRoFigure
{
get { return (MyItemInfo.IsFigure && MyItemInfo.MyContent.MyImage == null); }
}
public bool IsRoTable
{
get { return (Parent is VlnFlexGrid && (Parent as VlnFlexGrid).IsRoTable); }
@@ -701,7 +704,7 @@ namespace Volian.Controls.Library
// When a border style is changed, the richtextbox's handle is 'destroyed', so that the handleDestroyed
// event is done. This was causing the event handlers to be removed (RemoveEventHandler) so that the
// keypress event handler was not run.
private void RemoveEventHandlers()
public void RemoveEventHandlers()
{
if (_EventHandlersForKeyPress==0) return;
ContentsResized -= new ContentsResizedEventHandler(StepRTB_ContentsResized);
@@ -2040,6 +2043,17 @@ namespace Volian.Controls.Library
ImageWidth = img.Width;
Width = ImageWidth + 2;
Paste();
e.Handled = true;
return;
}
else if (iData.GetDataPresent(DataFormats.Dib))
{
System.Drawing.Image img = Clipboard.GetImage();
ImageWidth = img.Width;
Width = ImageWidth + 2;
Paste();
e.Handled = true;
return;
}
else
{

View File

@@ -126,7 +126,28 @@ namespace Volian.Controls.Library
AddWROContext(btnCMRtfEdit);
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMRtfEdit);
}
public void SetContextMenuImage(ImageItem imgItem)
{
btnCMCut.Enabled = false;
btnCMCopy.Enabled = false;
btnCMPaste.Enabled = false;
btnCMPasteText.Enabled = false;
btnCMRO.Enabled = false;
bool isInBuff = false;
try // image in clipboard - for 'paste'
{
System.Drawing.Image img = Clipboard.GetImage();
isInBuff = img != null;
}
catch (Exception ex)
{
isInBuff = false;
}
btnCMPasteImage.Enabled = isInBuff;
btnCMEditMode1.Enabled = false; //View mode (irrelevant for images)
btnCMGoTo.Enabled = MyItemInfo!=null && MyItemInfo.MyContent != null && MyItemInfo.MyContent.ContentRoUsageCount > 0;
_ContextMenuBar.SetContextMenuEx(imgItem, btnCMRtfEdit);
}
private void AddEnhancedDocumentMenu(DevComponents.DotNetBar.ButtonItem myButtonItem, object sender)
{
DVEnhancedDocuments dveds = MyItemInfo.MyDocVersion.DocVersionConfig.MyEnhancedDocuments;
@@ -626,7 +647,7 @@ namespace Volian.Controls.Library
}
SetButtonAndMenuEnabling(true);
SetStepButtonAndMenuEnabling(true);
SetMenuEnablingForFigures();
_MyLastFormatID = MyItemInfo.ActiveFormat.FormatID;
}
}
@@ -935,7 +956,7 @@ namespace Volian.Controls.Library
if (insdata.Length < 2) return;
int fromtype = Convert.ToInt32(insdata[0]);
int contenttype = Convert.ToInt32(insdata[1]) + 20000;
string tabletype = (insdata.Length == 3)? insdata[2]:null;
string tabOrFigType = (insdata.Length == 3)? insdata[2]:null;
// if CautionNoteOrder format variable is set then use it to determine the placement of the
// Caution, Note, Warning, or Message (calvert format)
if (cautNoteOrder != null && (","+cautNoteOrder+",").Contains(","+(contenttype % 10000).ToString() + ",") && (_MyEditItem.MyItemInfo.Cautions != null || _MyEditItem.MyItemInfo.Notes != null))
@@ -962,7 +983,7 @@ namespace Volian.Controls.Library
}
else if (InsertingTable(contenttype))
{
if (tabletype.Contains("RO"))
if (tabOrFigType.Contains("RO"))
{
VlnFlexGrid grd = new VlnFlexGrid();
grd.Rows.Count = 1;
@@ -978,11 +999,30 @@ namespace Volian.Controls.Library
if (grd != null) _MyEditItem.AddChild((E_FromType)fromtype, contenttype, grd);
}
}
else if (InsertingFigure(contenttype))
{
if (tabOrFigType.Contains("RO"))
{
_MyEditItem.AddChild((E_FromType)fromtype, contenttype, ImageItem.E_ImageSource.RoFigure);
StepTabPanel tmp = Parent as StepTabPanel;
tmp.MyDisplayTabControl.OnLinkModifyRO(this, new StepPanelLinkEventArgs(null));
}
else
{
System.Drawing.Image img = Clipboard.GetImage();
if (img == null && tabOrFigType.Contains("CL"))
{
MessageBox.Show("Clipboard does not contain image data. Cannot create figure.", "Clipboard Error");
return;
}
_MyEditItem.AddChild((E_FromType)fromtype, contenttype, tabOrFigType.Contains("CL")?ImageItem.E_ImageSource.Clipboard:ImageItem.E_ImageSource.File);
}
if (_MyEditItem.MyItemInfo.IsFigure && tabOrFigType.Contains("RO"))
btnInsRO_Click(sender, e);
}
else
{
_MyEditItem.AddChild((E_FromType)fromtype, contenttype);
if (_MyEditItem.MyItemInfo.IsFigure)
btnInsRO_Click(sender, e); // open the step properties RO tab when a figure substep is added
}
}
@@ -1061,18 +1101,29 @@ namespace Volian.Controls.Library
}
return rtnval;
}
// Figure (embedded images)
private bool InsertingFigure(int contenttype)
{
bool rtnval = false;
switch (contenttype)
{
case 20036: // Centered
case 20037: // AER (left)
case 20038: // AER (left) without boarder
case 20039: // Centered without boarder
rtnval = true;
break;
}
return rtnval;
}
private void btnInsBefore_Click(object sender, EventArgs e)
{
_MyEditItem.AddSiblingBefore();
if (_MyEditItem.MyItemInfo.IsFigure)
btnInsRO_Click(sender, e); // open the step properties RO tab when a figure substep is added
}
private void btnInsAfter_Click(object sender, EventArgs e)
{
_MyEditItem.AddSiblingAfter();
if (_MyEditItem.MyItemInfo.IsFigure)
btnInsRO_Click(sender, e); // open the step properties RO tab when a figure substep is added
}
/// <summary>
/// Using style for step type, enable/disable formatting buttons
@@ -1105,6 +1156,7 @@ namespace Volian.Controls.Library
btnCMCopy.Enabled = btnCopy.Enabled = setting;
btnPasteAfter.Enabled = btnPasteBefore.Enabled = btnStepPaste.Enabled = btnPasteReplace.Enabled = setting;
btnCMGrid.Enabled = setting;
btnCMPasteImage.Enabled = setting;
}
private void SetButtonMenuEnabledDisabledOnStepType(bool setting)
{
@@ -1128,13 +1180,6 @@ namespace Volian.Controls.Library
btnInsNote.Enabled = true;
btnInsCaut.Enabled = true;
}
if (MyItemInfo.IsFigure)
{
btnInsTrans.Enabled = btnCMTransition.Enabled = false;
btnCMSymbol.Enabled = btnSymbols.Enabled = false;
btnCMHardSpace.Enabled = btnInsHrdSpc.Enabled = false;
btnIndent.Enabled = false;
}
// if in Calvert Alarms Condition/Response, disable insert of Cautions and Notes
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm)
btnInsCaut.Enabled = btnInsNote.Enabled = btnCMInsCaution.Enabled = btnCMInsNote.Enabled = setting && !MyItemInfo.IsInCalvertConditionResponse;
@@ -1142,7 +1187,7 @@ namespace Volian.Controls.Library
public void SetButtonAndMenuEnabling(bool docontextmenus)
{
if (_MyStepRTB == null) return;
if (_MyStepRTB.FieldToEdit != E_FieldToEdit.StepText)
if (_MyStepRTB.FieldToEdit != E_FieldToEdit.StepText && !MyItemInfo.IsFigure) // want menu enabling for figures
return; // No need to change menu that does not get used
DocVersionInfo dvi = MyEditItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
if (dvi == null) return;
@@ -1179,6 +1224,7 @@ namespace Volian.Controls.Library
btnCMRedo.Enabled = btnRedo.Enabled = _MyStepRTB.CanRedo;
// for paste, see if there is clipboard data, & if so, of a type we can use.
btnCMPasteImage.Enabled = false;
try // RHM20150506 Multiline ItemID TextBox
{
IDataObject iData = Clipboard.GetDataObject();
@@ -1216,6 +1262,31 @@ namespace Volian.Controls.Library
btnCMEditRO.Enabled = false;
}
// OLD: SetStepButtonAndMenuEnabling(docontextmenus);
SetMenuEnablingForFigures();
}
private void SetMenuEnablingForFigures()
{
if (MyItemInfo.IsFigure)
{
btnInsTrans.Enabled = btnCMTransition.Enabled = false;
btnInsRO.Enabled = btnCMRO.Enabled = false;
btnCMSymbol.Enabled = btnSymbols.Enabled = false;
btnCMHardSpace.Enabled = btnInsHrdSpc.Enabled = false;
btnIndent.Enabled = false;
btnCMBold.Enabled = btnBold.Enabled = false;
btnCMItalics.Enabled = btnItalics.Enabled = false;
btnCMUnderline.Enabled = btnUnderline.Enabled = false;
btnCMSubscript.Enabled = btnSubscript.Enabled = false;
btnCMSuperscript.Enabled = btnSuperscript.Enabled = false;
btnCMCut.Enabled = btnCut.Enabled = false;
btnCMUndo.Enabled = btnUndo.Enabled = false;
btnCMRedo.Enabled = btnRedo.Enabled = false;
btnChgCase.Enabled = false;
btnPaste.Enabled = false;
btnCMPaste.Enabled = false;
btnCMPasteText.Enabled = false;
}
}
private void SetButtonEnablingForEnhanced(bool setting)
@@ -1510,7 +1581,6 @@ namespace Volian.Controls.Library
actable = sd.StepEditData.AcTable;
if (actable == null) actable = 0;
btnInsHLS.Enabled = MyItemInfo.MyHLS != null;
btnInsCaut.Enabled = ((actable & E_AccStep.AddingCaution) > 0) && !MyItemInfo.IsEnhancedStep;
btnInsNote.Enabled = ((actable & E_AccStep.AddingNote) > 0) && !MyItemInfo.IsEnhancedStep;
btnInsRNO.Enabled = (actable & E_AccStep.AddingRNO) > 0;
@@ -1663,6 +1733,9 @@ namespace Volian.Controls.Library
btn.SubItems.Add(bi);
}
}
//handle various cases for figures:
if (btn.Name == "btnInsFig" && docontextmenus) DoFigureMenuing(btn, cmbtn, sdl);
// if this is a table, then need to add RO/Text table options
if (btn.Name == "btnInsTable" && docontextmenus)
{
@@ -1735,7 +1808,135 @@ namespace Volian.Controls.Library
}
rbnStepParts.Refresh();
}
// From Figure menuing, need to map those strings to the index in the StepdataList for setting item's content type:
//<Step Index="36" Type="Figure" ParentType="Base" />
//<Step Index="37" Type="AERFigure" ParentType="Figure" />
//<Step Index="38" Type="BorderlessFigure" ParentType="Figure" />
//<Step Index="39" Type="BorderlessAERFigure" ParentType="AERFigure" />
private int Centered = 36; // will always be top level.
private void DoFigureMenuing(ButtonItem btn, ButtonItem cmbtn, List<StepDataRetval> sdl)
{
// Figure menuing:
// Figure (from ribbon)
// If in AER Column:
// Centered
// Left
// From both Centered & Left:
// With Border
// Without Border
// From both w/wo Border:
// RO Figure
// Figure from Clipboard
// Figure From File
// If in RNO column or single column mode (see comment below for this menu):
// With Border
// Without Border
// From both w/wo Border:
// RO Figure
// Figure from Clipboard
// Figure From File
// This is done for single column mode, or if in the calvertconditionresponse table (dual column) and in the rno column. Note
// the '&&' in if check because when in the calvertconditionresponse table, the section is in 'single column' mode even though
// the condition response table is dual column.
SectionConfig sc = (SectionConfig)MyItemInfo.ActiveSection.MyConfig;
// One Column Mode or Two Column Mode in the RNO Column or Caution or Note
if ((sc.Section_ColumnMode == SectionConfig.SectionColumnMode.One && (!MyItemInfo.IsInCalvertConditionResponse || MyItemInfo.IsInRNO))
|| (sc.Section_ColumnMode == SectionConfig.SectionColumnMode.Two && MyItemInfo.IsInRNO)
|| (MyItemInfo.IsCautionOrNotePart)) // single column step editor
{
// setup the sub menus for the insert table ribbon button
btn.Tag = btn.SubItems[0].Tag;
btn.SubItems.Clear();
DoFigureW_WOborderSubMenu(btn);
// setup the sub menus for the context menu used with the keyborad shortcut <shift><ctrl><T>
cmbtn.Tag = cmbtn.SubItems[0].Tag;
cmbtn.SubItems.Clear();
DoFigureW_WOborderSubMenu(cmbtn);
}
else
{
// this is AER column in dual column-need to add 'Centered' & 'Left'
char[] sp = { ' ' };
btn.Tag = btn.SubItems[0].Tag;
btn.SubItems.Clear();
string[] insdata = btn.Tag.ToString().Split(sp);
int ftype = Convert.ToInt32(insdata[0]);
int sdtype = Convert.ToInt32(insdata[1]);
DevComponents.DotNetBar.ButtonItem cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "CENT", "Centered");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "Centered";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, 36, "CENT");
cmbt.Click += new System.EventHandler(btnInsStep_Click);
btn.SubItems.Add(cmbt);
cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "LT", "Left");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "Left";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, 37, "LT"); // Text table
cmbt.Click += new System.EventHandler(btnInsStep_Click);
btn.SubItems.Add(cmbt);
btn.Tag = null;
btn.Click -= new System.EventHandler(btnInsStep_Click);
// setup the sub menus for the insert figure ribbon button
foreach (DevComponents.DotNetBar.ButtonItem tabbtn in btn.SubItems)
DoFigureW_WOborderSubMenu(tabbtn);
// setup the sub menus for the context menu used with the keyborad shortcut <shift><ctrl><T>
foreach (DevComponents.DotNetBar.ButtonItem cmtabbtn in cmbtn.SubItems)
DoFigureW_WOborderSubMenu(cmtabbtn);
}
}
private void DoFigureW_WOborderSubMenu(DevComponents.DotNetBar.ButtonItem tabbtn)
{
char[] sp = { ' ' };
string[] insdata = tabbtn.Tag.ToString().Split(sp);
int ftype = Convert.ToInt32(insdata[0]);
int sdtype = Convert.ToInt32(insdata[1]);
int with = sdtype == Centered ? 36 : 37;
DevComponents.DotNetBar.ButtonItem cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "BD", "With Border");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "With Border";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, sdtype, "BD");
cmbt.Click += new System.EventHandler(btnInsStep_Click);
tabbtn.SubItems.Add(cmbt);
DoFigureFromSubMenu(cmbt);
int wo = sdtype == Centered ? 38 : 39;
cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + wo + "NB", "Without Border");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "Without Border";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, wo, "NB");
cmbt.Click += new System.EventHandler(btnInsStep_Click);
tabbtn.SubItems.Add(cmbt);
DoFigureFromSubMenu(cmbt);
tabbtn.Tag = null;
tabbtn.Click -= new System.EventHandler(btnInsStep_Click);
}
private void DoFigureFromSubMenu(DevComponents.DotNetBar.ButtonItem tabbtn)
{
char[] sp = { ' ' };
string[] insdata = tabbtn.Tag.ToString().Split(sp);
int ftype = Convert.ToInt32(insdata[0]);
int sdtype = Convert.ToInt32(insdata[1]);
DevComponents.DotNetBar.ButtonItem cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "RO", "RO Figure");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "RO Figure";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, sdtype, "RO");
cmbt.Click += new System.EventHandler(btnInsStep_Click);
tabbtn.SubItems.Add(cmbt);
cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "CL", "From Clipboard");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "From Clipboard";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, sdtype, "CL");
cmbt.Click += new System.EventHandler(btnInsStep_Click);
tabbtn.SubItems.Add(cmbt);
cmbt = new DevComponents.DotNetBar.ButtonItem("cmbtnt" + sdtype + "FL", "From File");
cmbt.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.TextOnlyAlways;
cmbt.Text = "From File";
cmbt.Tag = string.Format("{0} {1} {2}", ftype, sdtype, "FL"); // Text table
cmbt.Click += new System.EventHandler(btnInsStep_Click);
tabbtn.SubItems.Add(cmbt);
tabbtn.Tag = null;
tabbtn.Click -= new System.EventHandler(btnInsStep_Click);
}
private void DoTableSubMenu(DevComponents.DotNetBar.ButtonItem tabbtn)
{
char[] sp = { ' ' };
@@ -2146,12 +2347,18 @@ namespace Volian.Controls.Library
myROID = MyFlexGrid.ROID.ToLower();
myRODB = RODbInfo.Get(MyFlexGrid.RODbId);
}
else if (MyItemInfo.IsFigure && MyItemInfo.MyContent.ContentRoUsages != null && MyItemInfo.MyContent.ContentRoUsages.Count > 0)
{
myROID = MyItemInfo.MyContent.ContentRoUsages[0].ROID;
myRODB = MyItemInfo.MyContent.ContentRoUsages[0].MyRODb;
}
else
{
LinkText lt = new LinkText(_MyStepRTB.MyLinkText);
LinkText lt = new LinkText(_MyStepRTB.MyLinkText);
myROID = lt.MyRoUsageInfo.ROID.ToLower();
myRODB = lt.MyRoUsageInfo.MyRODb;
}
if (myROID == null) return;
if (myROID.StartsWith("ffff"))
{
MessageBox.Show("Unit Information RO's cannot be edited", "Unit Information RO", MessageBoxButtons.OK, MessageBoxIcon.Information);
@@ -2262,6 +2469,7 @@ namespace Volian.Controls.Library
MyEditItem.ToggleEditView(MyEditItem.MyStepPanel.VwMode);
SetButtonAndMenuEnabling(true);
SetStepButtonAndMenuEnabling(true);
SetMenuEnablingForFigures();
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnModeChange(this, new StepRTBModeChangeEventArgs(MyEditItem.MyStepPanel.VwMode));
btnEditMode.Checked = btnCMEditMode1.Checked = MyEditItem.MyStepPanel.VwMode == E_ViewMode.View;
MyEditItem.MyStepRTB.SpellCheckContextMenuOn(MyEditItem.MyStepPanel.VwMode != E_ViewMode.View);
@@ -3437,7 +3645,10 @@ namespace Volian.Controls.Library
_PastePlainTextOvrRide = true;
btnPaste_Click(sender, e);
}
private void btnPasteImage_Click(object sender, EventArgs e)
{
if (MyEditItem is ImageItem) (MyEditItem as ImageItem).PasteImage();
}
private void btnPasteStepText_Click(object sender, EventArgs e)
{
StartGridEditing(SelectionOption.End);