From dea491a3d999cec3965a0eb355aabb7808697639 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 13 Feb 2017 19:26:35 +0000 Subject: [PATCH] B2017-023 fixed null reference errors when text boxes on Working Draft Specific Information dialog are empty. B2017-024 Added a context menu with windows clipboard options --- PROMS/Volian.Controls.Library/StepRTB.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index 4eda4c25..a80af32b 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -389,7 +389,7 @@ namespace Volian.Controls.Library { get { - if (_MyStyleFont == null) _MyStyleFont = MyItemInfo.GetItemFont(); + if (_MyStyleFont == null && MyItemInfo != null) _MyStyleFont = MyItemInfo.GetItemFont(); // B2017-023 null reference check for empty workdraft set information dialog return _MyStyleFont; } } @@ -808,7 +808,7 @@ namespace Volian.Controls.Library private void SetUpStepRTB() { DetectUrls = false; - if(DoSpellCheck) + if (DoSpellCheck) C1SpellChecker2.SetActiveSpellChecking(this, true); this.Height = 10; // initialize the height to 10, the default height was too big for the cells in grid tables BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -843,12 +843,13 @@ namespace Volian.Controls.Library //The following line fixes bugs B2016-121 and B2016-146 if(!Focused)this.Focus();// If it doesn't have focus, set focus to the selected item //Console.WriteLine("vvvvvvvvvv StepRTB Mouse Down id= {0}",MyItemInfo.ItemID); - bool inPsi = this.Parent.FindForm().Name.Contains("frmPSI"); + bool inPsi = this.Parent.FindForm().Name.Contains("frmPSI") || this.Parent.FindForm().Name.Contains("frmSI"); if (!_ContextMenuStripChanged) OnSetMenu(this, new StepRTBMenuEventArgs(inPsi?"PSI":"OpenContextMenu")); _ContextMenuStripChanged = false; CorrectSelectionAtEndOfLine(); - if (e.Button == System.Windows.Forms.MouseButtons.Right && MyItemInfo.IsRtfRaw) OnSetMenu(this, new StepRTBMenuEventArgs("OpenRtfRawContextMenu")); + // B2017-023 null reference check for empty workdraft set information dialog + if (e.Button == System.Windows.Forms.MouseButtons.Right && (MyItemInfo == null || MyItemInfo.IsRtfRaw)) OnSetMenu(this, new StepRTBMenuEventArgs((MyItemInfo != null && MyItemInfo.IsRtfRaw)?"OpenRtfRawContextMenu":"PSI")); _MouseDown = true; } void StepRTB_MouseUp(object sender, MouseEventArgs e) @@ -1536,7 +1537,7 @@ namespace Volian.Controls.Library private bool _HandlingCtrlA = false; private void HandleLocalSelectionChange() { - if (this.MyItemInfo.IsRtfRaw) return; + if (this.MyItemInfo != null && this.MyItemInfo.IsRtfRaw) return; // B2017-023 null reference check for empty workdraft set information dialog //if (MyRTBItem != null && MyRTBItem.MyStepPanel.SelectedStepRTB != this) if (OnIsNotCurrentSelection(this, new EventArgs())) return; @@ -1929,7 +1930,7 @@ namespace Volian.Controls.Library } } } - if (MyItemInfo.IsRtfRaw) + if (MyItemInfo == null || MyItemInfo.IsRtfRaw) // B2017-023 null reference check for empty workdraft set information dialog { e.Handled = true; return; @@ -2142,7 +2143,7 @@ namespace Volian.Controls.Library { // if contains bad rtf (from Word), paste as text, otherwise, do the paste here. if (!PasteRtfAsText(true)) Paste(); - if (SelectionLength == 0) SelectionFont = MyStyleFont.WindowsFont; + if (SelectionLength == 0 && MyStyleFont != null) SelectionFont = MyStyleFont.WindowsFont; // B2017-023 null reference check for empty workdraft set information dialog } } e.Handled = true; @@ -3429,6 +3430,10 @@ namespace Volian.Controls.Library tsi2.Click += new EventHandler(tsi2_Click); e.Menu.Items.Insert(i, tsi2); // add our spell check dialog item } + else if (tsi1 is ToolStripMenuItem && tsi1.Text == "Clip Board") // B2017-024 added the Clip Board context menu in FrmSi design + { + e.Menu.Items.RemoveAt(i + 1); // if Clip Board menu item is there, then remove o ur Edit Menu + } else { // B2016-242: check for editorial change on spell check word click.