From 8af0edb375001517f12537f1dcf1d0f00830cfd5 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 6 Nov 2015 21:04:31 +0000 Subject: [PATCH] Added events to allow keystrokes to toggle change bars, continuous action summary, and placekeeper check boxes. Made ribbon buttons for Superscript and Subscript public, also improved logic around the insert pagebreak button. --- PROMS/Volian.Controls.Library/StepRTB.cs | 106 ++++++++++++++++-- .../Volian.Controls.Library/StepTabRibbon.cs | 8 +- .../StepTabRibbon.designer.cs | Bin 514768 -> 514768 bytes 3 files changed, 102 insertions(+), 12 deletions(-) diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index 48f86f23..51b0525a 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -94,7 +94,37 @@ namespace Volian.Controls.Library { if (EnterKeyPressed != null) EnterKeyPressed(sender, args); } - public event StepRTBEvent InsertPgBrk; + public event StepRTBEvent ToggleChangeBar; // shortcut key + public void OnToggleChangeBar(object sender, EventArgs args) + { + if (ToggleChangeBar != null) ToggleChangeBar(sender, args); + } + public event StepRTBEvent ToggleContinuousActionSummary; // shortcut key + public void OnToggleContinuousActionSummary(object sender, EventArgs args) + { + if (ToggleContinuousActionSummary != null) ToggleContinuousActionSummary(sender, args); + } + public event StepRTBEvent TogglePlaceKeeper; // shortcut key + public void OnTogglePlaceKeeper(object sender, EventArgs args) + { + if (TogglePlaceKeeper != null) TogglePlaceKeeper(sender, args); + } + public event StepRTBEvent TogglePlaceKeeperContAct; // shortcut key + public void OnTogglePlaceKeeperContAct(object sender, EventArgs args) + { + if (TogglePlaceKeeperContAct != null) TogglePlaceKeeperContAct(sender, args); + } + public event StepRTBEvent ToggleSuperScript; // shortcut key <=> + public void OnToggleSuperScript(object sender, EventArgs args) + { + if (ToggleSuperScript != null) ToggleSuperScript(sender, args); + } + public event StepRTBEvent ToggleSubScript; // shortcut key <=> + public void OnToggleSubScript(object sender, EventArgs args) + { + if (ToggleSubScript != null) ToggleSubScript(sender, args); + } + public event StepRTBEvent InsertPgBrk; // short key public void OnInsertPgBrk(object sender, EventArgs args) { if (InsertPgBrk != null) InsertPgBrk(sender, args); @@ -1999,11 +2029,20 @@ namespace Volian.Controls.Library case Keys.Left: if (e.Shift) { - int newstart = FindStart(); // find start of link ending on. - // if not link, don't do special processing - if (newstart == SelectionStart - 1) return; - int len = SelectionLength + SelectionStart - newstart; - SetSelection(newstart, len); + int linkWidth = FindlinkWidth(false,e.Control); + + if (linkWidth == 0)// if not link, don't do special processing + { + if (e.Control) + { + this.AutoWordSelection = true; // this will select a word at a time + } + return; + } + else + linkWidth++; + int len = SelectionLength - linkWidth; + SetSelection(SelectionStart, len); // adjust the selcection around the linked text e.Handled = true; return; } @@ -2047,9 +2086,17 @@ namespace Volian.Controls.Library // it's handled in HandleSelectionChange. if (e.Shift && ((SelectionStart > 0) || (SelectionStart == 0 && _LinkLocations.Count > 0 && _LinkLocations[0].Start != 7))) { - int newlen = FindEnd(); + int newlen = FindlinkWidth(true,e.Control); + if (newlen == 0) // not on linked text + { + if (e.Shift && e.Control) + this.AutoWordSelection = true; + return; + } + else if (e.Shift && e.Control) + newlen++; int len = SelectionLength + newlen; - SetSelection(SelectionStart, len); + SetSelection(SelectionStart, len); // adjust the selection around the linked text e.Handled = true; return; } @@ -2190,6 +2237,8 @@ namespace Volian.Controls.Library Form frm = ParentForm(this); if (frm != null) frm.SelectNextControl(this, true, true, true, true); + else + StepRTB_ArrowPressed(e.Shift ? E_ArrowKeys.CtrlUp : E_ArrowKeys.CtrlRight); } else { @@ -2221,6 +2270,37 @@ namespace Volian.Controls.Library OnEnterKeyPressed(sender, e); } break; + case Keys.F2: + if (e.Alt && !e.Control && !e.Shift) // toggle change bar + { + OnToggleChangeBar(this, new EventArgs()); + e.Handled = true; + } + break; + case Keys.F7: + if (!e.Alt) // for the Include On check boxes on the step properties page + { + if (e.Control && e.Shift) // Toggle include on Placekeeper as Continuous Action + OnTogglePlaceKeeperContAct(this, new EventArgs()); + else if (e.Control) // Toggle include on Placekeeper + OnTogglePlaceKeeper(this, new EventArgs()); + else if (e.Shift) // toggle include on Continuous Action Summary + OnToggleContinuousActionSummary(this, new EventArgs()); + e.Handled = true; + } + break; + } + if (e.KeyValue == 187 && e.Control) // equal key pressed + { + if (e.Shift) // superscript + { + OnToggleSuperScript(this, new EventArgs()); + } + else // subscript + { + OnToggleSubScript(this, new EventArgs()); + } + e.Handled = true; } } private static Form ParentForm(Control ctrl) @@ -2658,6 +2738,16 @@ namespace Volian.Controls.Library } return 0; } + // if the selection is on linked text, then return the length of that linked text (the rtf length) + private int FindlinkWidth(bool movingRight, bool ctrlKey) + { + foreach (LinkLocation ll in _LinkLocations) + { + int selLen = SelectionLength + ((movingRight) ? 7 : 0); + if (SelectionStart + selLen >= ll.Start && SelectionStart + selLen - ((!movingRight && ctrlKey)?1:0) <= ll.End) return ll.End - ll.Start + 7; + } + return 0; + } private int FindStartUp() { foreach (LinkLocation ll in _LinkLocations) diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index ff382b9b..344e57ff 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -1650,8 +1650,8 @@ namespace Volian.Controls.Library } public void btnInsPgBrk_Click(object sender, EventArgs e) { - rtabInsert.Select(); - if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) return; + //rtabInsert.Select(); // insert page break is no longer visible on the ribbon + if (MyItemInfo.IsProcedure || MyItemInfo.IsSection || !MyItemInfo.IsHigh) return; MyEditItem.SaveContents(); // toggle manual page break StepConfig cfg = MyItemInfo.MyConfig as StepConfig; @@ -1891,14 +1891,14 @@ namespace Volian.Controls.Library btnCMUnderline.Checked = btnUnderline.Checked = RTBAPI.IsUnderline(_MyStepRTB); } - private void btnSuperscript_Click(object sender, EventArgs e) + public void btnSuperscript_Click(object sender, EventArgs e) { StartGridEditing(SelectionOption.All); RTBAPI.ToggleSuperscript(!RTBAPI.IsSuperScript(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION); btnCMSuperscript.Checked = btnSuperscript.Checked = RTBAPI.IsSuperScript(_MyStepRTB); } - private void btnSubscript_Click(object sender, EventArgs e) + public void btnSubscript_Click(object sender, EventArgs e) { StartGridEditing(SelectionOption.All); RTBAPI.ToggleSubscript(!RTBAPI.IsSubScript(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION); diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs index 0c4006e8db4d553a076dd19b3cdc6c52b6188980..5b6216c762fecfe041c851e579775a3c1ef591a4 100644 GIT binary patch delta 432 zcmXYtT_{6w7{XPMz%U(uD|hENaP>E0M3I6-9Ekxp?b+emy%lpN?bn)y=lH;Am} z7qT@4d0a{CEKp6BY727NOB|THGsT#(jf@u9?iz70fs!s)(XvOXSonZkIPs^MP={vTDJv1IVrE59Uog z?gyTY48nG+rNc<@{wK_V%-R+~lra>B7K}%Yf2KF!dXnDV2rPI;W)4vL1Zzs*{4z=^ qxT2YPlQCvvEG#o`btCiFal@v3At9suQrv0a`tt3IEYQfskNyAxSgQB{ delta 431 zcmcbxRsO|ax4~+7N2bJmS=MxN1f30gp*7>n-z?@c&8V%Gs|qA=9JSt zt&~||^C|lcOp_;EmYb|_&Stv6Nk*Q@Y8R}4+W4jmOlD=7oOjM*`iJvO0-OJwtCHN_ zaENgO|MW}zEGpA3GjeQ?xx`o^z--Q7Fg-DVS#|n{!;AvkIUX~12r!y%pZJ-P-IURE zy5S{8<>>;-Oaj}_XfWw%F&hC@HySajPB-vl654JO%)}?eXg2+$CX?#4G$yX;R~|F= zZA)WvNt`_E9nbVBY^-XN54@DveBi|y7Dl7#8v~hTfqaqa32kfwo6o(KV4Ob3otcNx zeEP$)Oo1R*PZs#dwK?YfIZj5)>4`PWijxm~;n^JV^MeeOKmCI!qsaC;F~%xcn8+Ms zMzQS%CXA0FVR|mS658(8$7mr171+LD1>*zB$+s@^Y!5ijl(V+2ow==@rLCQHTRWTG z^yvxOjBL}-R59~RS14oV+kU5nSw(2Oog8}zGbkRoroU5UcL9g!0w4nv5q#Snl-MWi F008x?pcw!F