This commit is contained in:
Kathy Ruffing 2012-05-08 13:05:32 +00:00
parent 83f38ec348
commit 00e634f4ed
3 changed files with 42 additions and 6 deletions

View File

@ -166,7 +166,7 @@ namespace Volian.Controls.Library
} }
else // otherwise, get data from config else // otherwise, get data from config
{ {
if (CurItemInfo.IsHigh) cbPageBreak.Checked = sc.Step_ManualPagebreak; if (CurItemInfo.IsHigh) cbPageBreak.Checked = sc.Step_NewManualPagebreak;
cbCAS.Checked = sc.Step_CAS; cbCAS.Checked = sc.Step_CAS;
} }
@ -280,7 +280,7 @@ namespace Volian.Controls.Library
if (_Initalizing) return; if (_Initalizing) return;
StepConfig sc = CurItemInfo.MyConfig as StepConfig; StepConfig sc = CurItemInfo.MyConfig as StepConfig;
if (sc == null) return; if (sc == null) return;
sc.Step_ManualPagebreak = cbPageBreak.Checked; sc.Step_NewManualPagebreak = cbPageBreak.Checked;
} }
private void cbCAS_CheckedChanged(object sender, EventArgs e) private void cbCAS_CheckedChanged(object sender, EventArgs e)
{ {

View File

@ -531,6 +531,8 @@ namespace Volian.Controls.Library
InitializeComponent(); InitializeComponent();
SetUpStepRTB(); SetUpStepRTB();
AddEventHandlers(); AddEventHandlers();
this.BorderStyleChanged += new EventHandler(StepRTB_BorderStyleChanged);
} }
public StepRTB(IContainer container) public StepRTB(IContainer container)
{ {
@ -539,6 +541,8 @@ namespace Volian.Controls.Library
_Container = container; _Container = container;
SetUpStepRTB(); SetUpStepRTB();
AddEventHandlers(); AddEventHandlers();
this.BorderStyleChanged += new EventHandler(StepRTB_BorderStyleChanged);
} }
protected override void OnMouseWheel(MouseEventArgs e) protected override void OnMouseWheel(MouseEventArgs e)
{ {
@ -546,8 +550,12 @@ namespace Volian.Controls.Library
//MyRTBItem.MyStepPanel.MouseWheel(e); //MyRTBItem.MyStepPanel.MouseWheel(e);
//base.OnMouseWheel(e); //base.OnMouseWheel(e);
} }
// 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() private void RemoveEventHandlers()
{ {
if (_EventHandlersForKeyPress==0) return;
ContentsResized -= new ContentsResizedEventHandler(StepRTB_ContentsResized); ContentsResized -= new ContentsResizedEventHandler(StepRTB_ContentsResized);
this.Click -= new EventHandler(StepRTB_Click); this.Click -= new EventHandler(StepRTB_Click);
this.KeyPress -= new KeyPressEventHandler(StepRTB_KeyPress); this.KeyPress -= new KeyPressEventHandler(StepRTB_KeyPress);
@ -561,9 +569,15 @@ namespace Volian.Controls.Library
this.ContextMenuStripChanged -= new EventHandler(StepRTB_ContextMenuStripChanged); this.ContextMenuStripChanged -= new EventHandler(StepRTB_ContextMenuStripChanged);
this.RTBSelectionChanged -= new StepRTBEvent(StepRTB_RTBSelectionChanged); this.RTBSelectionChanged -= new StepRTBEvent(StepRTB_RTBSelectionChanged);
this.HandleDestroyed -= new EventHandler(StepRTB_HandleDestroyed); this.HandleDestroyed -= new EventHandler(StepRTB_HandleDestroyed);
_EventHandlersForKeyPress = _EventHandlersForKeyPress - 1;
} }
private int _EventHandlersForKeyPress = 0;
// 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 AddEventHandlers() private void AddEventHandlers()
{ {
if (_EventHandlersForKeyPress>0) return;
// Always be sure to add the same event handlers to RemoveEventHandlers // Always be sure to add the same event handlers to RemoveEventHandlers
BorderStyle = System.Windows.Forms.BorderStyle.None; BorderStyle = System.Windows.Forms.BorderStyle.None;
this.DetectUrls = true; this.DetectUrls = true;
@ -580,6 +594,17 @@ namespace Volian.Controls.Library
this.ContextMenuStripChanged += new EventHandler(StepRTB_ContextMenuStripChanged); this.ContextMenuStripChanged += new EventHandler(StepRTB_ContextMenuStripChanged);
this.RTBSelectionChanged += new StepRTBEvent(StepRTB_RTBSelectionChanged); this.RTBSelectionChanged += new StepRTBEvent(StepRTB_RTBSelectionChanged);
this.HandleDestroyed += new EventHandler(StepRTB_HandleDestroyed); this.HandleDestroyed += new EventHandler(StepRTB_HandleDestroyed);
_EventHandlersForKeyPress = _EventHandlersForKeyPress+1;
}
// 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. The following was added so that the keypress event is restored
// after the border style was changed. This is specifically for the steprtb's on property pages.
void StepRTB_BorderStyleChanged(object sender, EventArgs e)
{
if (_EventHandlersForKeyPress==0)
this.KeyPress += new KeyPressEventHandler(StepRTB_KeyPress);
_EventHandlersForKeyPress++;
} }
private bool _Closed = false; private bool _Closed = false;
public bool Closed public bool Closed
@ -1763,6 +1788,7 @@ namespace Volian.Controls.Library
break; break;
} }
} }
if (((int)e.KeyCode) == 220) e.Handled = true;
switch (e.KeyCode) switch (e.KeyCode)
{ {
case Keys.Left: case Keys.Left:
@ -2011,6 +2037,16 @@ namespace Volian.Controls.Library
{ {
if (!ReadOnly) if (!ReadOnly)
{ {
// The richtextbox in steprtb does not properly place backslashes into the rtf text. It appears
// that the backslash is stored as a single backslash rather than a double backslash which
// causes the rtf/displaytext saving to strip additional characters. For now, the easiest
// approach is to not allow backslashes to be used. This is a 'temporary' fix for B2011-077.
if (e.KeyChar == 92)
{
MessageBox.Show("Backslash is not a usable character in PROMS", "Backslash", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
e.Handled = true;
return;
}
// add the character with its font depending on the char.... // add the character with its font depending on the char....
if (!IsControlChar) if (!IsControlChar)
{ {

View File

@ -653,7 +653,7 @@ namespace Volian.Controls.Library
if (MyItemInfo.IsHigh) if (MyItemInfo.IsHigh)
{ {
StepConfig cfg = MyItemInfo.MyConfig as StepConfig; StepConfig cfg = MyItemInfo.MyConfig as StepConfig;
btnInsPgBrk.Checked = cfg == null ? false : cfg.Step_ManualPagebreak; btnInsPgBrk.Checked = cfg == null ? false : cfg.Step_NewManualPagebreak;
} }
btnInsPgBrk.Enabled = MyItemInfo.IsHigh; btnInsPgBrk.Enabled = MyItemInfo.IsHigh;
btnPageBreak.Enabled = MyItemInfo.IsHigh; // edit context menu btnPageBreak.Enabled = MyItemInfo.IsHigh; // edit context menu
@ -973,8 +973,8 @@ namespace Volian.Controls.Library
// toggle manual page break // toggle manual page break
StepConfig cfg = MyItemInfo.MyConfig as StepConfig; StepConfig cfg = MyItemInfo.MyConfig as StepConfig;
cfg.Step_ManualPagebreak = !cfg.Step_ManualPagebreak; cfg.Step_NewManualPagebreak = !cfg.Step_NewManualPagebreak;
btnPageBreak.Checked = btnInsPgBrk.Checked = cfg.Step_ManualPagebreak; btnPageBreak.Checked = btnInsPgBrk.Checked = cfg.Step_NewManualPagebreak;
} }
private void btnIndent_Click(object sender, EventArgs e) private void btnIndent_Click(object sender, EventArgs e)
{ {