diff --git a/PROMS/Volian.Controls.Library/DisplayTabControl.cs b/PROMS/Volian.Controls.Library/DisplayTabControl.cs index 3c16564c..f11f5688 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabControl.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabControl.cs @@ -48,6 +48,12 @@ namespace Volian.Controls.Library } public partial class DisplayTabControl : UserControl { + public event ItemSelectedChangedEvent OpenEnhancedDocument; + public void OnOpenEnhancedDocument(ItemSelectedChangedEventArgs args) + { + if (OpenEnhancedDocument != null) + OpenEnhancedDocument(this, args); + } public event DisplayTabControlStatusEvent StatusChanged; public void ONStatusChanged(object Sender, DisplayTabControlStatusEventArgs args) { @@ -92,8 +98,18 @@ namespace Volian.Controls.Library public Dictionary ItemsChangeIds = null; private ItemInfo _MyItemInfo = null; private EditItem _MyEditItem = null; + + public EditItem MyEditItem + { + get { return _MyEditItem; } + set { _MyEditItem = value; } + } private StepRTB _MyStepRTB = null; private bool _RibbonExpanded=true; + public StepRTB MyStepRTB + { + get { return _MyStepRTB; } + } public bool RibbonExpanded { get { return _RibbonExpanded; } @@ -453,11 +469,11 @@ namespace Volian.Controls.Library break; case ItemInfo.EAddpingPart.Replace: EditItem ei = edtitm.PasteReplace(copyStartID); - if (ei.MyItemInfo.ItemID != edtitm.MyItemInfo.ItemID) - { - edtitm.Dispose(); - MyCopyStep = ei.MyItemInfo; - } + if (ei.MyItemInfo.ItemID != edtitm.MyItemInfo.ItemID) + { + edtitm.Dispose(); + MyCopyStep = ei.MyItemInfo; + } break; default: return false; ; @@ -807,6 +823,22 @@ namespace Volian.Controls.Library /// /// /// + public bool IsItemInfoProcedureOpen(ItemInfo ii) + { + ItemInfo proc = ii.MyProcedure; // Find procedure Item + if (dicEnhancedDocuments.ContainsKey(ii.MyProcedure.MyDocVersion)) + { + frmEnhanced frm = dicEnhancedDocuments[ii.MyProcedure.MyDocVersion]; + string key = "Item - " + proc.ItemID.ToString(); + if (frm.MyDisplayTabClntrol._MyDisplayTabItems.ContainsKey(key)) + return true; + } + // return true; + //return false; + return false; + } + public Dictionary dicEnhancedDocuments = new Dictionary(); + private DisplayTabItem OpenStepTabPage(ItemInfo myItemInfo) { ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item @@ -840,9 +872,19 @@ namespace Volian.Controls.Library } Application.DoEvents(); pg.SelectedItemInfo = myItemInfo; // Select the item + //StepConfig sc = new StepConfig(myItemInfo.MyContent.Config); + //if (sc.Step_SourceToBackground != null || sc.Step_SourceToDeviation != null) + // pg.MyStepTabPanel.MyStepTabRibbon.btnEnhancedDocSync.Visible = true; + //else + // pg.MyStepTabPanel.MyStepTabRibbon.btnEnhancedDocSync.Visible = false; return pg; } - + private bool _SyncEnhancedDocuments; + public bool SyncEnhancedDocuments + { + get { return _SyncEnhancedDocuments; } + set { _SyncEnhancedDocuments = value; } + } public void HandleChangeId(ItemInfo myItemInfo, DisplayTabItem pg) { if (myItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds) @@ -855,8 +897,8 @@ namespace Volian.Controls.Library { if (!Volian.Base.Library.VlnSettings.GetCommandFlag("NOCHGID")) { - dlgChgId dlgCI = new dlgChgId(this); //, null); - dlgCI.ShowDialog(this); + dlgChgId dlgCI = new dlgChgId(this); //, null); + dlgCI.ShowDialog(this); } ItemsChangeIds.Add(myItemInfo.MyProcedure.ItemID, ChgId); SetChangeId(ChgId, pg, myItemInfo); diff --git a/PROMS/Volian.Controls.Library/RTBItem.cs b/PROMS/Volian.Controls.Library/RTBItem.cs index f3f8cbe4..d03a9b9d 100644 --- a/PROMS/Volian.Controls.Library/RTBItem.cs +++ b/PROMS/Volian.Controls.Library/RTBItem.cs @@ -172,7 +172,7 @@ namespace Volian.Controls.Library // for hls in background documents - without this, the tab gets overwritten by the rtb. if (MyItemInfo.FormatStepData == null || MyItemInfo.FormatStepData.TabData.IdentEdit.Contains("{Section Prefix}") || !MyItemInfo.IsHigh || (MyItemInfo.IsHigh && MyItemInfo.FormatStepData.PageBreakOnStep)) - _MyStepRTB.Left = lblTab.Left + lblTab.Width; + _MyStepRTB.Left = lblTab.Left + lblTab.Width; _MyStepRTB.Width = Width - _MyStepRTB.Left - RTBMargin - CheckOffMargin; } _TabFormat = value; @@ -410,11 +410,53 @@ namespace Volian.Controls.Library /// /// /// + private bool _ProcessingEnter = false; private void _StepRTB_Enter(object sender, EventArgs e) { if (MyStepPanel.DisplayItemChanging) return; //vlnStackTrace.ShowStack("_StepRTB_Enter {0}",this.MyID); MyStepPanel.SelectedEditItem = this; + if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.SyncEnhancedDocuments) + { + if (!_ProcessingEnter) + { + _ProcessingEnter = true; + DisplayTabItem dti = null; + StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config); + if (sc.Step_SourceToBackground != null && sc.Step_SourceToDeviation != null) + { + ItemInfo bii = ItemInfo.Get(int.Parse(sc.Step_SourceToBackground)); + if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsItemInfoProcedureOpen(bii)) + MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnOpenEnhancedDocument(new ItemSelectedChangedEventArgs(bii)); + // dti = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(bii); + ItemInfo dii = ItemInfo.Get(int.Parse(sc.Step_SourceToDeviation)); + if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsItemInfoProcedureOpen(dii)) + MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnOpenEnhancedDocument(new ItemSelectedChangedEventArgs(dii)); + //dti = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(dii); + if (dti != null) + dti.MyStepTabPanel.MyDisplayTabControl.OpenItem(this.MyItemInfo); + } + else if (sc.Step_SourceToBackground != null && sc.Step_SourceToDeviation == null) + { + ItemInfo bii = ItemInfo.Get(int.Parse(sc.Step_SourceToBackground)); + if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsItemInfoProcedureOpen(bii)) + MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnOpenEnhancedDocument(new ItemSelectedChangedEventArgs(bii)); + //dti = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(bii); + if (dti != null) + dti.MyStepTabPanel.MyDisplayTabControl.OpenItem(this.MyItemInfo); + } + else if (sc.Step_SourceToBackground == null && sc.Step_SourceToDeviation != null) + { + ItemInfo dii = ItemInfo.Get(int.Parse(sc.Step_SourceToDeviation)); + if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsItemInfoProcedureOpen(dii)) + MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnOpenEnhancedDocument(new ItemSelectedChangedEventArgs(dii)); + //dti = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(dii); + if (dti != null) + dti.MyStepTabPanel.MyDisplayTabControl.OpenItem(this.MyItemInfo); + } + _ProcessingEnter = false; + } + } } /// /// Pass the AttachmentClick event to the StepPanel control. @@ -676,6 +718,7 @@ namespace Volian.Controls.Library { if (MyStepRTB.ReadOnly) return; if (!MyStepRTB.ActiveMode) return; + if (MyStepRTB.IsExperimenting) return; if (MyStepRTB.MyItemInfo.MyContent.Number != null && !MyStepRTB.IsDirty && MyStepRTB.Text.Contains("(Resolved Transition Text)") == false) return; bool success = MyStepRTB.OrigDisplayText.Save((RichTextBox)MyStepRTB); if (success) diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index aaa34bd8..b65a00f5 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -303,6 +303,12 @@ namespace Volian.Controls.Library get { return OrigRTF != Rtf; } } private bool _InitializingRTB; + private bool _IsExperimenting = false; + public bool IsExperimenting + { + get { return _IsExperimenting; } + set { _IsExperimenting = value; } + } private IContainer _Container = null; private string _MyClassName=string.Empty; public string MyClassName @@ -416,6 +422,7 @@ namespace Volian.Controls.Library // RefreshDisplay is used to update the rtb for an entire Item as defined by MyItemInfo. public void RefreshDisplay(bool activeMode) { + if (IsExperimenting) return; ActiveMode = activeMode; OnAdjustTableWidth(this, new StepRTBTableWidthEventArgs(true)); _InitializingRTB = true; @@ -445,6 +452,12 @@ namespace Volian.Controls.Library } RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT); bool readOnlyStep = MyItemInfo == null || MyItemInfo.FormatStepData == null ? false : MyItemInfo.FormatStepData.ReadOnly; + if (!readOnlyStep) + { + StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config); + if (sc.Step_BackgroundToSource != null || sc.Step_DeviationToSource != null) + readOnlyStep = true; + } ReadOnly = readOnlyStep || VwMode == E_ViewMode.View || ActiveMode == false; AddRtfText(vlntxt.StartText); //AddRtfStyles(); @@ -481,25 +494,25 @@ namespace Volian.Controls.Library // this line of code was moved before the find for the indent so that // the window gets resized if the indent changes the height, i.e. more line(s) in window. - AddEventHandlers(); + AddEventHandlers(); //if (MyItemInfo.InList(186722)) Console.WriteLine("here"); if ((indchar = Find(indentToken, indchar, RichTextBoxFinds.None)) >= 0) { int nindents = 0; - while ((indchar = Find(indentToken, indchar, RichTextBoxFinds.None)) >= 0) - { + while ((indchar = Find(indentToken, indchar, RichTextBoxFinds.None)) >= 0) + { nindents++; - Point indent = GetPositionFromCharIndex(indchar); - SelectionHangingIndent = indent.X; + Point indent = GetPositionFromCharIndex(indchar); + SelectionHangingIndent = indent.X; - // RHM 02/20/2013 - // The following line attempts to remove the indent character for display purposes. - // However, if the indent is followed immediately by an RO or Transition the - // RichTextBox will not allow the character to be removed this way and the RichTextBox - // will beep. So, to keep from going in an infintie loop, the value of indchar is incremented. - SelectedRtf = SelectedRtf.Replace(@"\'05", ""); - indchar++;// Don't so the same one twice. - } + // RHM 02/20/2013 + // The following line attempts to remove the indent character for display purposes. + // However, if the indent is followed immediately by an RO or Transition the + // RichTextBox will not allow the character to be removed this way and the RichTextBox + // will beep. So, to keep from going in an infintie loop, the value of indchar is incremented. + SelectedRtf = SelectedRtf.Replace(@"\'05",""); + indchar ++;// Don't so the same one twice. + } if (MyItemInfo != null && MyItemInfo.ActiveFormat != null && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.DontResetIndentOnNewline) { @@ -734,7 +747,7 @@ namespace Volian.Controls.Library } void StepRTB_SelectionChanged(object sender, EventArgs e) { - if (_InitializingRTB) return; + if (_InitializingRTB || _IsExperimenting) return; HandleSelectionChange(); } private bool _MouseDown = false; @@ -1384,7 +1397,7 @@ namespace Volian.Controls.Library #region TextAndContentsEvents void StepRTB_TextChanged(object sender, EventArgs e) { - if (_InitializingRTB) return; + if (_InitializingRTB || _IsExperimenting) return; // Was setting _IsDirty to true here, but this was getting called from // 'dotnetbar' when text was NOT Changed. So _IsDirty was made into // a property and compared original rtf versus current richtextbox's @@ -1892,57 +1905,57 @@ namespace Volian.Controls.Library } else { - switch (e.KeyCode) - { - case Keys.X: //ctrl-X - case Keys.C: //ctrl-C - // handle the clipboard copy and cut when a Transition or RO is selected - // For now, we are coping/cutting just the displayed text to the clipboard (like 16-bit VE-PROMS) - string ts = GetSelectedDisplayableText(); - if (ts != null && ts != "") Clipboard.SetText(GetSelectedDisplayableText()); - e.Handled = true; - e.SuppressKeyPress = true; - if (ts != null && ts != "" && e.KeyCode == Keys.X) // cut to clipboard - delete the selected text - HandleDeleteKeyWithSelectedText(e, null); - break; - case Keys.V: - // NOTE that if in a Properties Dialog StepRTB (for numbers and titles) or in a Procedure Specific - // Information (PSI) Dialog, i.e. any non-EditItem/Step editor field, the following code is run - // for the ctrl-V. For EditItems & Grid cells, the code in StepTabRibbon's btnPaste_Click is - // run. The way this occurs is that in the designer for StepTabRibbon (StepTabRibbon.designer.cs), - // the line of code: - // this.btnPaste.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlV); - // maps the Ctrl-V to btnPaste for those StepRTB's that are associated with the StepTabRibbon, i.e. - // EditItems & Grid cells. - IDataObject iData = Clipboard.GetDataObject(); - if (!iData.GetDataPresent(DataFormats.Text) && !iData.GetDataPresent(DataFormats.Rtf)) - { - MessageBox.Show("Cannot paste, text has special characters or symbols that will not paste correctly."); - } - else - { - // if contains bad rtf (from Word), paste as text, otherwise, do the paste here. - if (!PasteRtfAsText(true)) Paste(); - if (SelectionLength == 0) SelectionFont = MyStyleFont.WindowsFont; - } - e.Handled = true; - return; - case Keys.Home: - StepRTB_HomeEndPressed(e); - e.Handled = true; - break; - case Keys.End: - StepRTB_HomeEndPressed(e); - e.Handled = true; - break; - // 16bit Proms used 'ctrl-enter' for Hard returns. 32bit Proms uses 'shift-enter' - // because the richtextbox does this by default. Also Word uses 'shift-enter' - // for Hard return. And Word uses 'ctrl-enter' for inserting of page break. So - // 'ctrl-enter' for 32bit will insert page break - case Keys.Enter: - OnInsertPgBrk(this, new EventArgs()); - e.Handled = true; - break; + switch (e.KeyCode) + { + case Keys.X: //ctrl-X + case Keys.C: //ctrl-C + // handle the clipboard copy and cut when a Transition or RO is selected + // For now, we are coping/cutting just the displayed text to the clipboard (like 16-bit VE-PROMS) + string ts = GetSelectedDisplayableText(); + if (ts != null && ts != "") Clipboard.SetText(GetSelectedDisplayableText()); + e.Handled = true; + e.SuppressKeyPress = true; + if (ts != null && ts != "" && e.KeyCode == Keys.X) // cut to clipboard - delete the selected text + HandleDeleteKeyWithSelectedText(e, null); + break; + case Keys.V: + // NOTE that if in a Properties Dialog StepRTB (for numbers and titles) or in a Procedure Specific + // Information (PSI) Dialog, i.e. any non-EditItem/Step editor field, the following code is run + // for the ctrl-V. For EditItems & Grid cells, the code in StepTabRibbon's btnPaste_Click is + // run. The way this occurs is that in the designer for StepTabRibbon (StepTabRibbon.designer.cs), + // the line of code: + // this.btnPaste.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlV); + // maps the Ctrl-V to btnPaste for those StepRTB's that are associated with the StepTabRibbon, i.e. + // EditItems & Grid cells. + IDataObject iData = Clipboard.GetDataObject(); + if (!iData.GetDataPresent(DataFormats.Text) && !iData.GetDataPresent(DataFormats.Rtf)) + { + MessageBox.Show("Cannot paste, text has special characters or symbols that will not paste correctly."); + } + else + { + // if contains bad rtf (from Word), paste as text, otherwise, do the paste here. + if (!PasteRtfAsText(true)) Paste(); + if (SelectionLength == 0) SelectionFont = MyStyleFont.WindowsFont; + } + e.Handled = true; + return; + case Keys.Home: + StepRTB_HomeEndPressed(e); + e.Handled = true; + break; + case Keys.End: + StepRTB_HomeEndPressed(e); + e.Handled = true; + break; + // 16bit Proms used 'ctrl-enter' for Hard returns. 32bit Proms uses 'shift-enter' + // because the richtextbox does this by default. Also Word uses 'shift-enter' + // for Hard return. And Word uses 'ctrl-enter' for inserting of page break. So + // 'ctrl-enter' for 32bit will insert page break + case Keys.Enter: + OnInsertPgBrk(this, new EventArgs()); + e.Handled = true; + break; // The following keys are supported in underlying RTB (with ctrl key), but PROMS should not // do anything for that functionality: case Keys.R: // Right Align text