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

This commit is contained in:
John Jenko 2017-02-13 19:26:35 +00:00
parent f933b59e5f
commit dea491a3d9

View File

@ -389,7 +389,7 @@ namespace Volian.Controls.Library
{ {
get 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; return _MyStyleFont;
} }
} }
@ -808,7 +808,7 @@ namespace Volian.Controls.Library
private void SetUpStepRTB() private void SetUpStepRTB()
{ {
DetectUrls = false; DetectUrls = false;
if(DoSpellCheck) if (DoSpellCheck)
C1SpellChecker2.SetActiveSpellChecking(this, true); C1SpellChecker2.SetActiveSpellChecking(this, true);
this.Height = 10; // initialize the height to 10, the default height was too big for the cells in grid tables 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; BorderStyle = System.Windows.Forms.BorderStyle.None;
@ -843,12 +843,13 @@ namespace Volian.Controls.Library
//The following line fixes bugs B2016-121 and B2016-146 //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 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); //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) if (!_ContextMenuStripChanged)
OnSetMenu(this, new StepRTBMenuEventArgs(inPsi?"PSI":"OpenContextMenu")); OnSetMenu(this, new StepRTBMenuEventArgs(inPsi?"PSI":"OpenContextMenu"));
_ContextMenuStripChanged = false; _ContextMenuStripChanged = false;
CorrectSelectionAtEndOfLine(); 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; _MouseDown = true;
} }
void StepRTB_MouseUp(object sender, MouseEventArgs e) void StepRTB_MouseUp(object sender, MouseEventArgs e)
@ -1536,7 +1537,7 @@ namespace Volian.Controls.Library
private bool _HandlingCtrlA = false; private bool _HandlingCtrlA = false;
private void HandleLocalSelectionChange() 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 (MyRTBItem != null && MyRTBItem.MyStepPanel.SelectedStepRTB != this)
if (OnIsNotCurrentSelection(this, new EventArgs())) if (OnIsNotCurrentSelection(this, new EventArgs()))
return; 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; e.Handled = true;
return; return;
@ -2142,7 +2143,7 @@ namespace Volian.Controls.Library
{ {
// if contains bad rtf (from Word), paste as text, otherwise, do the paste here. // if contains bad rtf (from Word), paste as text, otherwise, do the paste here.
if (!PasteRtfAsText(true)) Paste(); 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; e.Handled = true;
@ -3429,6 +3430,10 @@ namespace Volian.Controls.Library
tsi2.Click += new EventHandler(tsi2_Click); tsi2.Click += new EventHandler(tsi2_Click);
e.Menu.Items.Insert(i, tsi2); // add our spell check dialog item 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 else
{ {
// B2016-242: check for editorial change on spell check word click. // B2016-242: check for editorial change on spell check word click.