From 9fae7d8e38d9ed64391038ebfb596feb214d6e11 Mon Sep 17 00:00:00 2001 From: Kathy Date: Thu, 13 Feb 2020 13:46:09 +0000 Subject: [PATCH] =?UTF-8?q?B2020-018:=20table=20font=20size=20=E2=80=93=20?= =?UTF-8?q?short=20cut=20keys=20not=20catching=20limits=20&=20selection=20?= =?UTF-8?q?not=20kept=20when=20using=20buttons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PROMS/Volian.Controls.Library/StepRTB.cs | 49 ++++++++++++++++++ .../Volian.Controls.Library/StepTabRibbon.cs | 41 ++------------- .../StepTabRibbon.designer.cs | Bin 551760 -> 551768 bytes 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index 2452a53c..f617007f 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -2161,6 +2161,15 @@ namespace Volian.Controls.Library case Keys.Oemplus: // the plus on the keyboard (not the key pad) e.Handled = true; break; + // B2020-018: Oemcomma & OemPeriod are short cut keys for changing the font size - only do this if in a table: + case Keys.Oemcomma: // '<' + if (_MyItemInfo != null && _MyItemInfo.IsTable && !IsRoTable) SetFontSize(false); + e.Handled = true; + break; + case Keys.OemPeriod: // '>' + if (_MyItemInfo != null && _MyItemInfo.IsTable && !IsRoTable) SetFontSize(true); + e.Handled = true; + break; } } else @@ -2618,6 +2627,46 @@ namespace Volian.Controls.Library } } + //B2020-018: SetFontSize and SetFontSizeReplace were moved from StepTabRibbon so that the short cut keys could also + // access the code that puts boundaries on font size. + // SetFontSize: replace rtf string of selection or entire rtb + public void SetFontSize(bool increase) + { + if (SelectedText == null || SelectedText == "") + Rtf = SetFontSizeReplace(Rtf, increase); + else + { + int selst = SelectionStart; + int selln = SelectionLength; + SelectedRtf = SetFontSizeReplace(SelectedRtf, increase); + Select(selst, selln); + } + } + private string SetFontSizeReplace(string rtf, bool increase) + { + MatchCollection mc = Regex.Matches(rtf, @"\\fs([0-9]+)"); + bool didMsg = false; + foreach (Match match in mc) + { + float sz = float.Parse(match.Groups[1].Value); + float repwith = increase ? sz + 1 : sz - 1; + if (repwith > 36 || repwith < 16) // Font size can be increased to 18 and decreased to 8 (note that \fs## has number 2 * pt) + { + if (!didMsg) // only put out message once. + { + MessageBox.Show(increase ? "Reached maximum font size, cannot increase." : "Reached minimum font size, cannot decrease.", "Warning font size change"); + didMsg = true; + } + } + else + { + string repsz = match.Value; // use \fs## rather than number in replace in case text contains the number + string repwithsz = match.Value.Replace(sz.ToString(), ((int)repwith).ToString()); + rtf = rtf.Replace(repsz, repwithsz); + } + } + return rtf; + } private static Form ParentForm(Control ctrl) { while (!(ctrl.Parent is Form || ctrl.Parent is EditItem)) diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index 60208784..07630801 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -2531,50 +2531,15 @@ namespace Volian.Controls.Library MyStepRTB.Select(0, 0); break; } - SetFontSize(MyStepRTB, increase); + MyStepRTB.SetFontSize(increase); } MyFlexGrid.Select(cr); } else - SetFontSize(MyStepRTB, increase); // not in a grid, apply style to current step type + MyStepRTB.SetFontSize(increase); // not in a grid, apply style to current step type } else - SetFontSize(MyStepRTB, increase); - } - // SetFontSize: replace rtf string of selection or entire rtb - private void SetFontSize(StepRTB MyStepRTB, bool increase) - { - if (MyStepRTB.SelectedText == null || MyStepRTB.SelectedText == "") - MyStepRTB.Rtf = SetFontSizeReplace(MyStepRTB.Rtf, increase); - else - MyStepRTB.SelectedRtf = SetFontSizeReplace(MyStepRTB.SelectedRtf, increase); - } - // SetFontSizeReplace: for the input string, increase or decrease the font size - use a regular expression to get - // all current font sizes in the string & increase them all. - private string SetFontSizeReplace(string rtf, bool increase) - { - MatchCollection mc = Regex.Matches(rtf, @"\\fs([0-9]+)"); - bool didMsg = false; - foreach (Match match in mc) - { - float sz = float.Parse(match.Groups[1].Value); - float repwith = increase ? sz + 1 : sz - 1; - if (repwith > 36 || repwith < 16) // Font size can be increased to 18 and decreased to 8 (note that \fs## has number 2 * pt) - { - if (!didMsg) // only put out message once. - { - MessageBox.Show(increase ? "Reached maximum font size, cannot increase." : "Reached minimum font size, cannot decrease.", "Warning font size change"); - didMsg = true; - } - } - else - { - string repsz = match.Value; // use \fs## rather than number in replace in case text contains the number - string repwithsz = match.Value.Replace(sz.ToString(), ((int)repwith).ToString()); - rtf = rtf.Replace(repsz, repwithsz); - } - } - return rtf; + MyStepRTB.SetFontSize(increase); } private void ToggleBold() { diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs index 9739e7b2e4f712863980b76e2000848a68dc4627..bfb4a9eea85cc096ec785aaf6d784759f12547f6 100644 GIT binary patch delta 93 zcmca`P4UJx#fBEf7N#xCzwS)GbCz9f`nwEPt?3E(nMI~6++*gLZji|ufZ%T5cb7Sh maeB--pu(gR%zD!=+-H_(uer|*#4JF}3dC&NYwojO=>`CJfhfiR delta 96 zcmca{P4U7t#fBEf7N#xCzwS&gxWeo(UEmJ0*mSc@)}YA~d|AM}?Fa5MXE09BIm0eA o-5{1x3nn2jJ)wY=WBQ#uR-N_@_nCp11&CRJm~H!p`|K;a0gP%WcK`qY