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 9739e7b2..bfb4a9ee 100644 Binary files a/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs and b/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs differ