From 4cc3c5f1f725af0cca37bccdec241e2a2fd1c5df Mon Sep 17 00:00:00 2001 From: Jsj Date: Fri, 22 Aug 2008 18:47:19 +0000 Subject: [PATCH] --- .../DisplayRO.Designer.cs | 106 +++- PROMS/Volian.Controls.Library/DisplayRO.cs | 591 +++++++++++++++++- PROMS/Volian.Controls.Library/DisplayRO.resx | 11 + 3 files changed, 677 insertions(+), 31 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DisplayRO.Designer.cs b/PROMS/Volian.Controls.Library/DisplayRO.Designer.cs index 98d68739..5abe8c87 100644 --- a/PROMS/Volian.Controls.Library/DisplayRO.Designer.cs +++ b/PROMS/Volian.Controls.Library/DisplayRO.Designer.cs @@ -28,14 +28,19 @@ namespace Volian.Controls.Library /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DisplayRO)); this.tvROFST = new System.Windows.Forms.TreeView(); this.panelValue = new System.Windows.Forms.Panel(); + this.lbROId = new DevComponents.DotNetBar.LabelX(); + this.labelX1 = new DevComponents.DotNetBar.LabelX(); this.pnlROButtons = new System.Windows.Forms.Panel(); + this.btnPreviewRO = new DevComponents.DotNetBar.ButtonX(); this.btnCancelRO = new DevComponents.DotNetBar.ButtonX(); this.btnSaveRO = new DevComponents.DotNetBar.ButtonX(); this.panelRoValue = new System.Windows.Forms.Panel(); this.tbROValue = new DevComponents.DotNetBar.Controls.TextBoxX(); this.lblROValue = new DevComponents.DotNetBar.LabelX(); + this.superTooltip1 = new DevComponents.DotNetBar.SuperTooltip(); this.panelValue.SuspendLayout(); this.pnlROButtons.SuspendLayout(); this.panelRoValue.SuspendLayout(); @@ -43,49 +48,88 @@ namespace Volian.Controls.Library // // tvROFST // - this.tvROFST.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.tvROFST.Dock = System.Windows.Forms.DockStyle.Fill; this.tvROFST.HideSelection = false; - this.tvROFST.Location = new System.Drawing.Point(0, 64); + this.tvROFST.Location = new System.Drawing.Point(0, 122); this.tvROFST.Margin = new System.Windows.Forms.Padding(4); this.tvROFST.Name = "tvROFST"; - this.tvROFST.Size = new System.Drawing.Size(300, 559); + this.tvROFST.Size = new System.Drawing.Size(311, 502); this.tvROFST.TabIndex = 5; this.tvROFST.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.tvROFST_BeforeExpand); this.tvROFST.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvROFST_AfterSelect); // // panelValue // + this.panelValue.Controls.Add(this.lbROId); + this.panelValue.Controls.Add(this.labelX1); this.panelValue.Controls.Add(this.pnlROButtons); this.panelValue.Controls.Add(this.panelRoValue); this.panelValue.Dock = System.Windows.Forms.DockStyle.Top; this.panelValue.Location = new System.Drawing.Point(0, 0); this.panelValue.Margin = new System.Windows.Forms.Padding(4); this.panelValue.Name = "panelValue"; - this.panelValue.Size = new System.Drawing.Size(301, 65); + this.panelValue.Size = new System.Drawing.Size(311, 122); this.panelValue.TabIndex = 7; // + // lbROId + // + this.lbROId.Dock = System.Windows.Forms.DockStyle.Left; + this.lbROId.ForeColor = System.Drawing.SystemColors.Highlight; + this.lbROId.Location = new System.Drawing.Point(61, 27); + this.lbROId.Name = "lbROId"; + this.lbROId.Size = new System.Drawing.Size(244, 28); + this.superTooltip1.SetSuperTooltip(this.lbROId, new DevComponents.DotNetBar.SuperTooltipInfo("RO ID", "", "The RO ID for the selected RO Value will be displayed here.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, true, new System.Drawing.Size(150, 80))); + this.lbROId.TabIndex = 11; + // + // labelX1 + // + this.labelX1.Dock = System.Windows.Forms.DockStyle.Left; + this.labelX1.Location = new System.Drawing.Point(0, 27); + this.labelX1.Name = "labelX1"; + this.labelX1.Size = new System.Drawing.Size(61, 28); + this.superTooltip1.SetSuperTooltip(this.labelX1, new DevComponents.DotNetBar.SuperTooltipInfo("RO ID", "", "The RO ID for the selected RO Value will be displayed here.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, true, new System.Drawing.Size(150, 80))); + this.labelX1.TabIndex = 10; + this.labelX1.Text = "RO ID:"; + this.labelX1.TextAlignment = System.Drawing.StringAlignment.Center; + // // pnlROButtons // + this.pnlROButtons.Controls.Add(this.btnPreviewRO); this.pnlROButtons.Controls.Add(this.btnCancelRO); this.pnlROButtons.Controls.Add(this.btnSaveRO); - this.pnlROButtons.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnlROButtons.Location = new System.Drawing.Point(0, 32); + this.pnlROButtons.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnlROButtons.Location = new System.Drawing.Point(0, 55); this.pnlROButtons.Margin = new System.Windows.Forms.Padding(4); this.pnlROButtons.Name = "pnlROButtons"; - this.pnlROButtons.Size = new System.Drawing.Size(301, 33); + this.pnlROButtons.Size = new System.Drawing.Size(311, 67); this.pnlROButtons.TabIndex = 9; // + // btnPreviewRO + // + this.btnPreviewRO.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; + this.btnPreviewRO.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; + this.btnPreviewRO.Dock = System.Windows.Forms.DockStyle.Top; + this.btnPreviewRO.Enabled = false; + this.btnPreviewRO.Location = new System.Drawing.Point(0, 45); + this.btnPreviewRO.Name = "btnPreviewRO"; + this.btnPreviewRO.Size = new System.Drawing.Size(311, 23); + this.superTooltip1.SetSuperTooltip(this.btnPreviewRO, new DevComponents.DotNetBar.SuperTooltipInfo("Preview", "", "This will Preview the selected RO Table, X/Y Plot, or Image.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, true, new System.Drawing.Size(150, 80))); + this.btnPreviewRO.TabIndex = 10; + this.btnPreviewRO.Text = "Preview"; + this.btnPreviewRO.Click += new System.EventHandler(this.btnPreviewRO_Click); + // // btnCancelRO // this.btnCancelRO.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnCancelRO.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnCancelRO.Dock = System.Windows.Forms.DockStyle.Right; - this.btnCancelRO.Location = new System.Drawing.Point(211, 0); + this.btnCancelRO.Dock = System.Windows.Forms.DockStyle.Top; + this.btnCancelRO.Enabled = false; + this.btnCancelRO.Location = new System.Drawing.Point(0, 22); this.btnCancelRO.Margin = new System.Windows.Forms.Padding(4); this.btnCancelRO.Name = "btnCancelRO"; - this.btnCancelRO.Size = new System.Drawing.Size(90, 33); + this.btnCancelRO.Size = new System.Drawing.Size(311, 23); + this.superTooltip1.SetSuperTooltip(this.btnCancelRO, new DevComponents.DotNetBar.SuperTooltipInfo("Cancel", "", "This become active when you about to replace an existing RO link in you procedure" + + ".\r\n\r\nNOTE: This willL NOT un-do after you select the Save RO button.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, true, new System.Drawing.Size(195, 145))); this.btnCancelRO.TabIndex = 9; this.btnCancelRO.Text = "Cancel"; this.btnCancelRO.Click += new System.EventHandler(this.btnCancelRO_Click); @@ -94,11 +138,13 @@ namespace Volian.Controls.Library // this.btnSaveRO.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnSaveRO.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnSaveRO.Dock = System.Windows.Forms.DockStyle.Left; + this.btnSaveRO.Dock = System.Windows.Forms.DockStyle.Top; + this.btnSaveRO.Enabled = false; this.btnSaveRO.Location = new System.Drawing.Point(0, 0); this.btnSaveRO.Margin = new System.Windows.Forms.Padding(4); this.btnSaveRO.Name = "btnSaveRO"; - this.btnSaveRO.Size = new System.Drawing.Size(92, 33); + this.btnSaveRO.Size = new System.Drawing.Size(311, 22); + this.superTooltip1.SetSuperTooltip(this.btnSaveRO, new DevComponents.DotNetBar.SuperTooltipInfo("Save RO", "", resources.GetString("btnSaveRO.SuperTooltip"), null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, true, new System.Drawing.Size(340, 125))); this.btnSaveRO.TabIndex = 8; this.btnSaveRO.Text = "Save RO"; this.btnSaveRO.Click += new System.EventHandler(this.btnSaveRO_Click); @@ -111,21 +157,28 @@ namespace Volian.Controls.Library this.panelRoValue.Location = new System.Drawing.Point(0, 0); this.panelRoValue.Margin = new System.Windows.Forms.Padding(4); this.panelRoValue.Name = "panelRoValue"; - this.panelRoValue.Size = new System.Drawing.Size(301, 32); + this.panelRoValue.Size = new System.Drawing.Size(311, 27); this.panelRoValue.TabIndex = 8; // // tbROValue // + this.tbROValue.BackColor = System.Drawing.SystemColors.ControlLightLight; // // // this.tbROValue.Border.Class = "TextBoxBorder"; - this.tbROValue.Dock = System.Windows.Forms.DockStyle.Fill; - this.tbROValue.Location = new System.Drawing.Point(67, 0); + this.tbROValue.Dock = System.Windows.Forms.DockStyle.Top; + this.tbROValue.Location = new System.Drawing.Point(64, 0); this.tbROValue.Margin = new System.Windows.Forms.Padding(4); this.tbROValue.Name = "tbROValue"; - this.tbROValue.Size = new System.Drawing.Size(234, 22); + this.tbROValue.ReadOnly = true; + this.tbROValue.Size = new System.Drawing.Size(247, 22); + this.superTooltip1.SetSuperTooltip(this.tbROValue, new DevComponents.DotNetBar.SuperTooltipInfo("RO Value", "", "The value of selected RO will be displayed here.\r\n\r\nExceptions:\r\n- Tables, X/Y Pl" + + "ots, and Images will state what they are. The Preview button will display the va" + + "lue.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, true, new System.Drawing.Size(230, 135))); this.tbROValue.TabIndex = 7; + this.tbROValue.WatermarkText = "Select RO Below"; + this.tbROValue.WordWrap = false; // // lblROValue // @@ -134,20 +187,27 @@ namespace Volian.Controls.Library this.lblROValue.Location = new System.Drawing.Point(0, 0); this.lblROValue.Margin = new System.Windows.Forms.Padding(4); this.lblROValue.Name = "lblROValue"; - this.lblROValue.Size = new System.Drawing.Size(67, 32); + this.lblROValue.Size = new System.Drawing.Size(64, 27); + this.superTooltip1.SetSuperTooltip(this.lblROValue, new DevComponents.DotNetBar.SuperTooltipInfo("RO Value", "", "The value of selected RO will be displayed here.\r\n\r\nExceptions:\r\n- Tables, X/Y Pl" + + "ots, and Images will state what they are. The Preview button will display the va" + + "lue.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, true, new System.Drawing.Size(230, 135))); this.lblROValue.TabIndex = 6; this.lblROValue.Text = "RO Value:"; this.lblROValue.TextLineAlignment = System.Drawing.StringAlignment.Near; // + // superTooltip1 + // + this.superTooltip1.LicenseKey = "F962CEC7-CD8F-4911-A9E9-CAB39962FC1F"; + // // DisplayRO // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.panelValue); this.Controls.Add(this.tvROFST); + this.Controls.Add(this.panelValue); this.Margin = new System.Windows.Forms.Padding(4); this.Name = "DisplayRO"; - this.Size = new System.Drawing.Size(301, 624); + this.Size = new System.Drawing.Size(311, 624); this.panelValue.ResumeLayout(false); this.pnlROButtons.ResumeLayout(false); this.panelRoValue.ResumeLayout(false); @@ -165,5 +225,9 @@ namespace Volian.Controls.Library private System.Windows.Forms.Panel pnlROButtons; private DevComponents.DotNetBar.ButtonX btnCancelRO; private DevComponents.DotNetBar.ButtonX btnSaveRO; + private DevComponents.DotNetBar.ButtonX btnPreviewRO; + private DevComponents.DotNetBar.LabelX labelX1; + private DevComponents.DotNetBar.LabelX lbROId; + private DevComponents.DotNetBar.SuperTooltip superTooltip1; } } diff --git a/PROMS/Volian.Controls.Library/DisplayRO.cs b/PROMS/Volian.Controls.Library/DisplayRO.cs index e70eb0b3..9babfe23 100644 --- a/PROMS/Volian.Controls.Library/DisplayRO.cs +++ b/PROMS/Volian.Controls.Library/DisplayRO.cs @@ -4,8 +4,11 @@ using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; +using System.IO; using System.Windows.Forms; using VEPROMS.CSLA.Library; +using XYPlots; +using DevComponents.DotNetBar; namespace Volian.Controls.Library { @@ -35,14 +38,16 @@ namespace Volian.Controls.Library { if (_CurROLink == value) return; _CurROLink = value; - UpdateROTree(); _SavCurROLink = _CurROLink; + UpdateROTree(); } else // insert - clear out controls { _CurROLink = value; tbROValue.Text = null; + lbROId.Text = ""; tvROFST.SelectedNode = null; + btnSaveRO.Enabled = btnCancelRO.Enabled = false; } } } @@ -61,10 +66,12 @@ namespace Volian.Controls.Library _MyRTB.LinkChanged += new StepRTBLinkEvent(_MyRTB_LinkChanged); if (_MyRTB.MyLinkText == null) { - _CurROLink = null; + CurROLink = null; //_CurROLink + _SavCurROLink = null; } } } + void _MyRTB_LinkChanged(object sender, StepPanelLinkEventArgs args) { if (_MyRTB.MyLinkText == null) @@ -74,24 +81,123 @@ namespace Volian.Controls.Library CurROLink = args.MyLinkText.RoUsageid; } } + + private DocVersionInfo _Mydvi; + + public DocVersionInfo Mydvi + { + get { return _Mydvi; } + set { _Mydvi = value; } + } + + + private ProgressBarItem _ProgressBar; + + public ProgressBarItem ProgressBar + { + get { return _ProgressBar; } + set { _ProgressBar = value; } + } + + //public int ProgBarMax + //{ + // get { return _ProgressBar.Maximum; } + // set { _ProgressBar.Maximum = value; } + //} + + //public int ProgBarValue + //{ + // get { return _ProgressBar.Value; } + // set { _ProgressBar.Value = value; } + //} + + //public string ProgBarText + //{ + // get { return _ProgressBar.Text; } + // set + // { + // _ProgressBar.TextVisible = true; + // _ProgressBar.Text = value; + // } + //} + #endregion #region Constructors public DisplayRO() { InitializeComponent(); + _ProgressBar = null; } #endregion #region Events + ROFST.rochild selectedChld; private void tvROFST_AfterSelect(object sender, TreeViewEventArgs e) { + tbROValue.Text = null; + lbROId.Text = ""; + btnCancelRO.Enabled = false; + btnSaveRO.Enabled = false; + btnPreviewRO.Enabled = false; + if (e.Node.Tag is ROFST.rochild) { ROFST.rochild chld = (ROFST.rochild)e.Node.Tag; - if (chld.type == 1 && chld.value != null) tbROValue.Text = chld.value; - else tbROValue.Text = null; + selectedChld = chld; + if (chld.value != null) + { + string SavROLink = ""; + if (_SavCurROLink != null) + SavROLink = _SavCurROLink.Substring(_SavCurROLink.IndexOf(' ') + 1, 12); + lbROId.Text = chld.appid; + btnSaveRO.Enabled = ((_SavCurROLink == null) || !(chld.roid.Equals(SavROLink))); + btnCancelRO.Enabled = ((_SavCurROLink != null) && !(chld.roid.Equals(SavROLink))); + switch (chld.type) + { + case 1: // standard (regular) text RO type + tbROValue.Text = chld.value; + btnPreviewRO.Enabled = false; + break; + case 2: // Table RO type + tbROValue.Text = "(Table)"; + btnPreviewRO.Enabled = true; + break; + case 4: // X/Y Plot RO type + tbROValue.Text = "(Graph)"; + btnPreviewRO.Enabled = true; + break; + case 8: // Intergrated Graphics RO type + tbROValue.Text = "(Image)"; + btnPreviewRO.Enabled = true; + break; + } + } } - else - tbROValue.Text = null; + + + //if (e.Node.Tag is ROFST.rochild) + //{ + // ROFST.rochild chld = (ROFST.rochild)e.Node.Tag; + // if (chld.type == 1 && chld.value != null) + // { + // string SavROLink = ""; + // if (_SavCurROLink != null) + // SavROLink = _SavCurROLink.Substring(_SavCurROLink.IndexOf(' ') + 1, 12); + // tbROValue.Text = chld.value; + // btnSaveRO.Enabled = ((_SavCurROLink == null) || !(chld.roid.Equals(SavROLink))); + // btnCancelRO.Enabled = ((_SavCurROLink != null) && !(chld.roid.Equals(SavROLink))); + // } + // //else + // //{ + // // tbROValue.Text = null; + // // btnCancelRO.Enabled = btnSaveRO.Enabled = false; + // //} + //} + ////else + ////{ + //// tbROValue.Text = null; + //// btnCancelRO.Enabled = btnSaveRO.Enabled = false; + ////} + } private void tvROFST_BeforeExpand(object sender, TreeViewCancelEventArgs e) @@ -123,8 +229,10 @@ namespace Volian.Controls.Library // if children, add dummy node if (chld != null && chld.Length > 0) { + ProgressBar_Initialize(chld.Length, tn.Text); for (int i = 0; i < chld.Length; i++) { + ProgressBar_SetValue(i); TreeNode tmp = null; // if this is a group, i.e. type 0, add a dummy node if (chld[i].type == 0 && chld[i].children == null) @@ -132,7 +240,7 @@ namespace Volian.Controls.Library // TODO: KBR how to handle this? //Console.WriteLine("ro junk"); continue; - else if (chld[i].type == 1 && chld[i].value == null) + else if (/*chld[i].type == 1 && */ chld[i].value == null) { tmp = new TreeNode(chld[i].title); tmp.Tag = chld[i]; @@ -140,6 +248,17 @@ namespace Volian.Controls.Library TreeNode sub = new TreeNode("VLN_DUMMY_FOR_TREE"); tmp.Nodes.Add(sub); } + //else if (chld[i].type == 2 && chld[i].value == null) // table + //{ + // if ((_MyRTB.MyItemInfo.MyContent.Type % 10000) == (int)E_FromType.Table) + // { + // tmp = new TreeNode(chld[i].title); + // tmp.Tag = chld[i]; + // tn.Nodes.Add(tmp); + // TreeNode sub = new TreeNode("VLN_DUMMY_FOR_TREE"); + // tmp.Nodes.Add(sub); + // } + //} else { tmp = new TreeNode(chld[i].title); @@ -148,6 +267,7 @@ namespace Volian.Controls.Library } } } + ProgressBar_Clear(); } private void LoadTree() { @@ -180,6 +300,9 @@ namespace Volian.Controls.Library int rousageid = System.Convert.ToInt32(tmpstr.Substring(0, sp)); string roid = tmpstr.Substring(sp + 1, tmpstr.Length - sp - 1); string db = roid.Substring(0, 4); + bool multValSel = false; + if (roid.Length == 16) + multValSel = true; ROFST.rochild rochld = MyROFST.GetRoChild(roid.Substring(0, 12).ToUpper()); // use this to walk up tree until database - this is used to expand tree. @@ -225,7 +348,27 @@ namespace Volian.Controls.Library } } - if (tnExpand != null) tvROFST.SelectedNode = tnExpand; + //if (tnExpand != null) tvROFST.SelectedNode = tnExpand; + + if (tnExpand != null) + { + // If a multiple return value, try to select the proper node + if (multValSel) + { + LoadChildren(tnExpand); + tnExpand.Expand(); + foreach (TreeNode tn in tnExpand.Nodes) + { + ROFST.rochild chld = (ROFST.rochild)tn.Tag; + if (chld.roid == roid) + { + tnExpand = tn; + break; + } + } + } + tvROFST.SelectedNode = tnExpand; + } } private void btnSaveRO_Click(object sender, EventArgs e) { @@ -238,15 +381,443 @@ namespace Volian.Controls.Library if (obj is ROFST.rochild) { ROFST.rochild roch = (ROFST.rochild) obj; - string linktxt = string.Format("#Link:ReferencedObject: #xx {0}", roch.roid); - _MyRTB.InsertRO(tbROValue.Text, linktxt); + if (_MyRTB != null) // if null, it's Word attachment + { + if (CheckROSelection(roch)) + { + //string linktxt = string.Format("#Link:ReferencedObject: #xx {0}", roch.roid); + string ROID = roch.roid; + //TODO: need to get the current user's USERID + RoUsage ro = RoUsage.MakeRoUsage(MyRTB.MyItemInfo.MyContent.Get(), ROID, null, DateTime.Now, "TEST"); + //string linktxt = string.Format(@"{0}{1}\v #Link:ReferencedObject:{2} {3}\v0", + // '\x15', MyROFST.GetRoValue(ROID.Substring(0, 12).ToUpper()), ro.ROUsageID, ROID); + string linktxt = string.Format(@"#Link:ReferencedObject:{0} {1}", ro.ROUsageID, ROID); + // Resolve symbols and scientific notation in the RO return value + _MyRTB.InsertRO(ConvertSymbolsAndStuff(tbROValue.Text), linktxt); + } + } + else // we're in an Word attachment + { + string accPrefix = (roch.type == 8) ? _Mydvi.DocVersionConfig.RODefaults_graphicsprefix : _Mydvi.DocVersionConfig.RODefaults_setpointprefix; + string AccPageID = string.Format("<{0}-{1}>", accPrefix, roch.appid); + //TODO: CAN WE AUTOMATICALLY PLACE RO ONTO WORD ATTACHEMNT? + if (MessageBox.Show(AccPageID,"Place on Windows Clipboard?",MessageBoxButtons.YesNo) == DialogResult.Yes) + Clipboard.SetText(AccPageID); + } + btnSaveRO.Enabled = btnCancelRO.Enabled = btnPreviewRO.Enabled = false; + _SavCurROLink = null; + CurROLink = null; } } + + private bool CheckROSelection(ROFST.rochild selectedRO) + { + bool goodToGo = true; + bool replacingRO = (_SavCurROLink != null); + string insrpl = (replacingRO) ? "Cannot Replace" : "Cannot Insert"; + string errormsg = ""; + switch (selectedRO.type) + { + case 1: // regular text RO + if (_MyRTB.MyItemInfo.IsFigure) + { + errormsg = (replacingRO) ? "a Figure with a non-figure." : "a text RO in a Figure type."; + goodToGo = false; + } + break; + case 2: // table RO + if (_MyRTB.MyItemInfo.IsFigure) + { + errormsg = (replacingRO) ? "a Figure with a non-figure." : "a table into a Figure type."; + goodToGo = false; + } + else if (_MyRTB.MyItemInfo.MyContent.Type != 20007) //(!_MyRTB.MyItemInfo.IsTable) // Not in a table substep type + { + errormsg = (replacingRO) ? "a non-table RO with a Table RO." : "a table into a non-table type."; + //TODO: Prompt user to insert a new Table substep type and place this RO into it + goodToGo = false; + } + break; + case 4: // X/Y Plot RO type + if (!_MyRTB.MyItemInfo.IsAccPages) + { + errormsg = (replacingRO) ? "a non-X/Y Plot RO with an X/Y Plot RO." : "an X/Y Plot RO in an non-Accessory Page type."; + //TODO: Prompt user to insert a new substep type that handles x/y Plots and place this RO into it + goodToGo = false; + } + break; + case 8: // figure (intergrated graphics) + if (!_MyRTB.MyItemInfo.IsFigure && !_MyRTB.MyItemInfo.IsAccPages) + { + errormsg = (replacingRO) ? "a graphics RO with a non-graphcis RO." : "a Graphics RO in an non-Figure or a non-Accessory Page type."; + //TODO: Prompt user to insert a new substep type that handles x/y Plots and place this RO into it + goodToGo = false; + } + break; + } + if (!goodToGo) + MessageBox.Show(string.Format("{0} {1}", insrpl, errormsg), (replacingRO)?"Invalid RO Replacement":"Invalid RO Insert"); + return goodToGo; + } + private void btnCancelRO_Click(object sender, EventArgs e) { _CurROLink = _SavCurROLink; + btnCancelRO.Enabled = false; UpdateROTree(); } + + private void btnPreviewRO_Click(object sender, EventArgs e) + { + if (selectedChld.type == 8) // intergrated graphic + { + string ropth = _CurROFST.GetFstPath(); + ropth = ropth.Substring(0, ropth.LastIndexOf('\\') + 1); + string fname = selectedChld.value.Substring(0, selectedChld.value.IndexOf('\n')); + int thedot = fname.LastIndexOf('.'); + if (thedot == -1 || (thedot != (fname.Length - 4))) + fname += string.Format(".{0}", MyROFST.GetDefaultGraphicExtension()); + + string imgfile = ropth + fname; + if (File.Exists(imgfile)) + { + PreviewROImage pvROImg = new PreviewROImage(imgfile, selectedChld.title); + pvROImg.ShowDialog(); + } + else + MessageBox.Show(string.Format("{0}", imgfile), "Cannot Find Image File"); + } + else if (selectedChld.type == 2) // table + { + PreviewMultiLineRO pmlROTable = new PreviewMultiLineRO(selectedChld.value, selectedChld.title); + pmlROTable.ShowDialog(); + } + else if (selectedChld.type == 4) // x/y plot + { + //PreviewMultiLineRO pmlROTable = new PreviewMultiLineRO(selectedChld.value, selectedChld.title); + //pmlROTable.ShowDialog(); // This will show the graph commands + this.Cursor = Cursors.WaitCursor; + // TemporaryFolder is magical. It will automatically (behind the scenes) build a path to a temporary + // folder on the user's machine. It does this only the first time it's reference (GET), after that + // it uses what it has. + string pdfname = TemporaryFolder; //@"G:\debugdat\testplot\"; + pdfname += "\\" + selectedChld.appid + ".pdf"; + //if (File.Exists(pdfname)) + // File.Delete(pdfname); + XYPlot ROGraph = new XYPlot(selectedChld.value, pdfname); + this.Cursor = Cursors.Default; + + // Run an internet browser window + WebBrowser wb = new WebBrowser(pdfname); + wb.TitleText = selectedChld.title; + wb.ShowDialog();// .Show(); + + // Run the default PDF reader + //System.Diagnostics.Process ActRdr = System.Diagnostics.Process.Start(pdfname); + //ActRdr.WaitForExit(); + + // Wait for the PDF viewing process to close then delete the temporary file + // wait for a one minute max + if (!WaitToDeleteFile(pdfname,1)) + MessageBox.Show(string.Format("The PDF viewer was holding this file open: \n\n{0}",pdfname),"Cannot Delete Temporary File"); + } + } + private void ProgressBar_Initialize(int max, string desc) + { + if (_ProgressBar != null) + { + _ProgressBar.Maximum = max; + _ProgressBar.Text = desc; + _ProgressBar.TextVisible = true; + } + } + + private void ProgressBar_SetValue(int curval) + { + if (_ProgressBar != null) + { + _ProgressBar.Value = curval; + } + } + + private void ProgressBar_Clear() + { + if (_ProgressBar != null) + { + _ProgressBar.Text = ""; + _ProgressBar.Maximum = 0; + _ProgressBar.Value = 0; + _ProgressBar.TextVisible = false; + } + } + + #region Utils + private string ConvertSymbolsAndStuff(string instr) + { + string outstr = instr; + + outstr = outstr.Replace("`", @"\'b0"); // convert backquote to degree - left over from DOS days. + outstr = outstr.Replace("\xa0", @"\u160?"); // hardspace + outstr = outstr.Replace("\xb0", @"\'b0"); // degree + outstr = outstr.Replace("\x7f", @"\u916?"); // delta + outstr = outstr.Replace("\x2265", @"\u8805?"); // greater than or equal + outstr = outstr.Replace("\x2264", @"\u8804?"); // less than or equal + outstr = outstr.Replace("\xB1", @"\'b1"); // plus minus + outstr = outstr.Replace("\x3A3", @"\u931?"); // sigma + outstr = outstr.Replace("\x3C4", @"\u947?"); // gamma + outstr = outstr.Replace("\xBD", @"\'bd"); // half + outstr = outstr.Replace("\x25A0", @"\u9604?"); // accum 2584 + outstr = outstr.Replace("\x7", @"\u9679?"); // bullet 25CF + outstr = outstr.Replace("\x2248", @"\u8776?"); // approx eq + outstr = outstr.Replace("\x2261", @"\u8773?"); // similar eq 2245 + outstr = outstr.Replace("\xF7", @"\'f7"); // division + outstr = outstr.Replace("\x221A", @"\u8730?"); // square root + outstr = outstr.Replace("\x393", @"\u961?"); // rho 3C1 + outstr = outstr.Replace("\x3C0", @"\u960?"); // pi + outstr = outstr.Replace("\xb5", @"\u956?"); // micro 3BC (try e6, if not work try 109) + outstr = outstr.Replace("\x3B4", @"\u948?"); // lower case delta + outstr = outstr.Replace("\x3C3", @"\u963?"); // lower case sigma + outstr = outstr.Replace("\xBC", @"\'bc"); // quarter + outstr = outstr.Replace("\x3C6", @"\'d8"); // dist zero, D8 + outstr = outstr.Replace("\xC9", @"\u274?"); // energy, 112 + outstr = outstr.Replace("\xEC", @"\'ec"); // grave + outstr = outstr.Replace("\x2502", @"\u9474?"); // bar + outstr = outstr.Replace("\x3B5", @"\u949?"); // epsilon + outstr = outstr.Replace("\x398", @"\u952?"); // theta, 3B8 + outstr = outstr.Replace("\x221E", @"\u8857?"); // dot in oval, 2299 + outstr = outstr.Replace("\xBF", @"\u964?"); // tau, 3C4 + outstr = outstr.Replace("\x2310", @"\u9830?"); // diamond, 2666 + outstr = outstr.Replace("\x2192", @"\u8594?"); + outstr = outstr.Replace("\x2190", @"\u8592?"); + outstr = outstr.Replace("\x2191", @"\u8593?"); + outstr = outstr.Replace("\x2193", @"\u8595?"); + outstr = outstr.Replace("\x2207", @"\u8711?"); + // TODO: DO WE NEED TO CHECK WHETHER TO REPLACE ^ CHARACTER FOR SETPOINTS? + //if (DoCaret) s2 = s2.Replace("^", @"\u916"); + outstr = outstr.Replace("^", @"\u916"); + + outstr = ConvertDOSSuperAndSubScripts(outstr); + + outstr = ConvertFortranFormatToScienctificNotation(outstr); + + return outstr; + } + private string ConvertFortranFormatToScienctificNotation(string str) + { + string outstr = ""; + int orglen = str.Length; + int cnt = 0; + int ptr; + + int nbytes; + int tstr, tstr2, rptr, start = 0; + + while (cnt < orglen) + { + // position up to the the next number, sign, or period + ptr = str.IndexOfAny("+-0123456789.".ToCharArray(), cnt); + if (ptr == -1) + { + outstr += str.Substring(cnt); + break; // jump out of while loop - nothing else to process + } + if ((ptr - cnt) > 0) + { + outstr += str.Substring(cnt, ptr - cnt); + cnt = ptr; + } + + if (cnt > start && str[cnt - 1] == '\'') + { + //B2003-053: only remove the single quote character + // if str ptr is not at the end of the string or + // the next char (after the str ptr) is not a space + // or newline... (as per Paul Linn on 7/17/03) + int len = orglen - cnt; + if (len <= 1 || str[cnt + 1] == ' ' || str[cnt + 1] == '\n') + start = cnt; + else + start = cnt - 1; + } + else start = cnt; + tstr = cnt; + + //Skip preceeding signs + if (str[cnt] == '+' || str[cnt] == '-') + cnt++; + + cnt = NextNonNumber(str, cnt); + if (str[cnt] == '.') + { + cnt = NextNonNumber(str, cnt + 1); + if (str[start] == '\'') + { + start++; + } + else if (str[cnt] == 'E' && cnt > tstr) + { + nbytes = (cnt - tstr); // don't include the 'E' + outstr += str.Substring(tstr, nbytes); + cnt++; + + rptr = outstr.Length - 1; + while (outstr[rptr] == '0') rptr--; + if (outstr[rptr] != '.') rptr++; + if (rptr < (outstr.Length - 1)) + outstr = outstr.Substring(0, rptr + 1); // trim trailing 0's + + int poutstr = 0; + if (outstr[poutstr] == '+' || outstr[poutstr] == '-') poutstr++; + if (!outstr[poutstr].Equals("1")) + { + outstr += "x1"; + } + outstr += "0\\super "; + + tstr2 = cnt; + if (str[cnt] == '+' || str[cnt] == '-') cnt++; + cnt = NextNonNumber(str, cnt); + + if (str[cnt] == '.' && char.IsDigit(str, cnt + 1)) + cnt = NextNonNumber(str, cnt + 1); + + nbytes = cnt - tstr2; // +1; + outstr += str.Substring(tstr2, nbytes); + outstr += "\\nosupersub "; + + if (!char.IsLetterOrDigit(str, cnt) && !char.IsWhiteSpace(str, cnt)) + return (str.Substring(tstr)); + } + } + else + { + outstr += str.Substring(start, cnt - start + 1); + cnt++; + } + } + return (outstr); + } + + private int NextNonNumber(string str, int cnt) + { + int rtn = 0; + string tstr = str.Substring(cnt); + int len = tstr.Length; + while (rtn < len && char.IsDigit(tstr,rtn)) rtn++; + return rtn + cnt; + } + + private string ConvertDOSSuperAndSubScripts(string instr) + { + string outstr = ""; + string tstr = instr; + int cnt = 0; + int ptr = 0; + bool issupper=false, issub = false; + + while (tstr != null && (ptr = tstr.IndexOfAny("#~".ToCharArray(), cnt)) >= 0) + { + if (ptr > cnt) + outstr += tstr.Substring(cnt, ptr - cnt); + switch (tstr[ptr]) + { + case '#': + if (issub || issupper) + outstr += "\\nosupersub "; + else + outstr += "\\super "; + issupper = !issupper; + issub = false; + break; + case '~': + if (issupper || issub) + outstr += "\\nosupersub "; + else + outstr += "\\sub "; + issub = !issub; + issupper = false; + break; + } + cnt = ptr + 1; + if (cnt >= tstr.Length) + tstr = null; + else + tstr = instr.Substring(cnt); + cnt = 0; + } + if (tstr != null) + outstr += tstr; + return outstr; + } + + private static string _TemporaryFolder = null; + public static string TemporaryFolder + { + get + { + if (_TemporaryFolder == null) + { + // This will create a Temp\VE-PROMS folder in the LocalSettings Folder. + //XP - C:\Documents and Settings\{user}\Local Settings\Application Data\Temp\VE-PROMS + //Vista - C:\Users\{user}\AppData\Local\Temp\VE-PROMS + _TemporaryFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Temp"; + if (!Directory.Exists(TemporaryFolder)) Directory.CreateDirectory(TemporaryFolder); + _TemporaryFolder += @"\VE-PROMS"; + if (!Directory.Exists(TemporaryFolder)) Directory.CreateDirectory(TemporaryFolder); + } + return _TemporaryFolder; + } + } + + /// + /// Keep trying to delete the given file until successful OR until MaxMinutes has elasped + /// + /// File to delete (including path) + /// Maxium Minutes to keep trying + /// + private static bool WaitToDeleteFile(string fname, int MaxMinutes) + { + bool deletedfile = false; + DateTime dt_start = DateTime.Now; + DateTime dt_loop = dt_start; + int mins_start = dt_start.Minute; + int mins_loop = dt_loop.Minute; + while (!deletedfile && ((mins_loop - mins_start) < MaxMinutes)) + { + try + { + dt_loop = DateTime.Now; + File.Delete(fname); + deletedfile = true; + } + catch + { + continue; // The process is still holding file, try again. + } + } + return deletedfile; + } + + #endregion // utils + + //private void AddToROUsage(ROFST.rochild roch) + //{ + // if (instance < dt.Rows.Count) + // { + // //DataRow dr = dt.Rows[instance]; + // string ROID = roch.roid; + // RoUsage ro = RoUsage.MakeRoUsage(content, ROID, null, DateTime.Now, "Migration"); + // string results = string.Format(@"{0}{1}\v #Link:ReferencedObject:{2} {3}\v0", + // '\x15', rofst.GetRoValue(ROID.Substring(0, 12).ToUpper()), ro.ROUsageID, ROID); + // rotxt.Append(results); + // instance++; + // } + // else + // { + // log.Error("Error setting RO data in text field"); + // log.ErrorFormat("proc number = {0}, oldstepsequence = {1}, instance = {2}", ProcNumber, seqcvt, instance); + // } + //} #endregion } } diff --git a/PROMS/Volian.Controls.Library/DisplayRO.resx b/PROMS/Volian.Controls.Library/DisplayRO.resx index 19dc0dd8..f24ecbca 100644 --- a/PROMS/Volian.Controls.Library/DisplayRO.resx +++ b/PROMS/Volian.Controls.Library/DisplayRO.resx @@ -117,4 +117,15 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + For Step Editor sections: +- This will place the selected RO at the cursor position. +- This will replace an RO with the selected RO. + +For Word sections +- This will place the needed RO ID on the clipboard. + \ No newline at end of file