C2020-001: Allow changing of font sizes within table (added rtf method argument)

C2020-001: Allow changing of font sizes within table, keep font size rtf for tables
C2020-001: Allow changing of font sizes within table, user interface
C2020-001: Allow changing of font sizes within table, added icons
This commit is contained in:
Kathy Ruffing 2020-02-11 12:42:26 +00:00
parent 23354f3ed2
commit 448f2e5653
8 changed files with 1829 additions and 1721 deletions

View File

@ -142,7 +142,7 @@ namespace VEPROMS
{
StepRTB cur = _DicStepRtb[fld.name];
string rtf = cur.Rtf;
string newval = DisplayText.StaticStripRtfCommands(rtf);
string newval = DisplayText.StaticStripRtfCommands(rtf, false); // C2020-001: added 'false'
// compare to original and if different, save in proc config.
string oldval = procConfig.GetValue("PSI", fld.name);
if (oldval != newval)

View File

@ -140,7 +140,7 @@ namespace VEPROMS
{
StepRTB cur = _DicStepRtb[fld.name];
string rtf = cur.Rtf;
string newval = DisplayText.StaticStripRtfCommands(rtf);
string newval = DisplayText.StaticStripRtfCommands(rtf, false); // C2020-001: added 'false'
// compare to original and if different, save in proc config.
string oldval = DoFolder ? folderConfig.GetValue("SI", fld.name) : dvConfig.GetValue("SI", fld.name);
if (oldval != newval)

View File

@ -556,7 +556,7 @@ namespace VEPROMS.CSLA.Library
{
// B2018-088 - Added code to look for CROUSGID
Regex regRefObj = new Regex(@"\#Link\:ReferencedObject:([0-9]*|<NewID>|<CROUSGID=-?[0-9]+>) ([0-9a-zA-Z]*) ([0-9]*)", RegexOptions.Singleline);
string strippedText = StaticStripRtfCommands(text);
string strippedText = StaticStripRtfCommands(text, _MyItemInfo!=null?_MyItemInfo.IsTable:false);
// (\\[^v \\]+)* --> look for any rtf commands (first part of lookFor)
// \\v0 --> end of comment
// (\\[^v \\]+)* --> more rtf commands ended by a space
@ -588,8 +588,8 @@ namespace VEPROMS.CSLA.Library
}
string gg = text.Substring(myIndex, myLength).TrimEnd(" ".ToCharArray());// RHM 20180608 - Found an issue where the value contained a trailing space
//System.Text.RegularExpressions.Group g = m.Groups[3];
string beforeRO = StaticStripRtfCommands(text.Substring(0, myIndex));
string afterRO = StaticStripRtfCommands(text.Substring(myIndex + myLength));
string beforeRO = StaticStripRtfCommands(text.Substring(0, myIndex), _MyItemInfo != null ? _MyItemInfo.IsTable : false);
string afterRO = StaticStripRtfCommands(text.Substring(myIndex + myLength), _MyItemInfo != null ? _MyItemInfo.IsTable : false);
Match myMatch = regRefObj.Match(m.ToString());
// B-2018-088 Made Error Log output more useful
if (m.ToString().ToUpper().Contains("<NEWID>") || m.ToString().ToUpper().Contains("<CROUSGID="))
@ -698,7 +698,7 @@ namespace VEPROMS.CSLA.Library
{
int profileDepth = ProfileTimer.Push(">>>> DoTransitionAdjustments");
bool undtran = _MyItemInfo.ActiveFormat.PlantFormat.FormatData.TransData.Underline;
string strippedText = StaticStripRtfCommands(text);
string strippedText = StaticStripRtfCommands(text, _MyItemInfo != null ? _MyItemInfo.IsTable : false);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v'?{{}}~ \\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:(ReferencedObject|Transition[^:]*?):[0-9]* ([0-9]*).*?\[END>");
MatchCollection matches = Regex.Matches(text, lookFor);
if (matches.Count == 0)
@ -1311,6 +1311,8 @@ namespace VEPROMS.CSLA.Library
break;
case 'f':
if (Regex.IsMatch(token, @"^\\fi[-0-9]+ ?$")) return token; // first line indent
// C2020-001: only keep the font size rtf if in a table.
if (_fromTable && Regex.IsMatch(token, @"^\\fs[-0-9]+ ?$")) return token; // font size
break;
case 'p':
if (Regex.IsMatch(token, @"^\\par ?$")) return "\r\n";
@ -1394,8 +1396,10 @@ namespace VEPROMS.CSLA.Library
private static Regex sreg9 = new Regex(@"(\\[^ \\?\r\n\t]+) (?=\r\n)"); // remove space before /r/n
// This is used in the DataLoader
public static string StaticStripRtfCommands(string rtf)
private static bool _fromTable = false; // C2020-001: Change Font Size in Tables - keep rtf '\fs##' for tables only
public static string StaticStripRtfCommands(string rtf, bool fromTable)
{
_fromTable = fromTable;
// replace \{ & \} with (![ & (!] respectively and then redo at end. The curly braces
// are rtf so were getting removed and/or not handled correctly.
string retval = rtf.Replace(@"\{", @" (![");
@ -1474,6 +1478,7 @@ namespace VEPROMS.CSLA.Library
// the indent character was translated in the richtextbox, change it back:
if (retval.IndexOf(@"\'05") > -1) retval = retval.Replace(@"\'05", "\x05");
_fromTable = false;
return retval;
}
#endregion

View File

@ -310,6 +310,16 @@ namespace Volian.Controls.Library.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap DecreaseFontSize_16x {
get {
object obj = ResourceManager.GetObject("DecreaseFontSize_16x", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@ -490,6 +500,16 @@ namespace Volian.Controls.Library.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap IncreaseFontSize_16x {
get {
object obj = ResourceManager.GetObject("IncreaseFontSize_16x", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

File diff suppressed because it is too large Load Diff

View File

@ -61,6 +61,8 @@ namespace Volian.Controls.Library
if (_MyEditItem == value) return; // Don't do this if the value is not different
_MyEditItem = value;
SetBtnInsSupInfoVisible();
ToggleTableFontSize(value is GridItem);
if (value != null)
{
(this.Parent as StepTabPanel).MyDisplayTabItem.SetupSecurity(MyItemInfo);
@ -169,7 +171,7 @@ namespace Volian.Controls.Library
private void AddEnhancedDocumentMenu(DevComponents.DotNetBar.ButtonItem myButtonItem, object sender)
{
DVEnhancedDocuments dveds = MyItemInfo.MyDocVersion.DocVersionConfig.MyEnhancedDocuments;
if (dveds.Count == 0) return; // No enhanced!
if (dveds == null || dveds.Count == 0) return; // No enhanced!
// for all enhanced documents, create the list of buttons as they should be for items in the docversion
// using the list of enhanced documents that are on the docversion. Note that later, some may be
@ -2461,7 +2463,7 @@ namespace Volian.Controls.Library
if (ctrl == null) return; // B2018-008 if a null is returned don't do anything
if (ctrl is VlnFlexGrid)
{
// Selected table cell is not in edit mode. Go into edit mode and position acording
// Selected table cell is not in edit mode. Go into edit mode and position according
// to the pass in selOpt.
if (MyFlexGrid != null && MyFlexGrid.Editor == null)
{
@ -2494,7 +2496,86 @@ namespace Volian.Controls.Library
else
applyStyle(); // not in a grid, apply style to current step type
}
// ChangeFontSize: similar to code that sets styles (above) except do the font size instead.
private void ChangeFontSize(SelectionOption selOpt, bool increase)
{
// Need to check if the selected table cell is in edit mode already.
// if already in edit mode, we don't want to do the StartEditing code below, because it
// will override the current cursor positioning and selection range.
Control ctrl = FindActiveControl();
if (ctrl == null) return; // B2018-008 if a null is returned don't do anything
if (ctrl is VlnFlexGrid)
{
// Selected table cell is not in edit mode. Go into edit mode and position according
// to the pass in selOpt.
if (MyFlexGrid != null && MyFlexGrid.Editor == null)
{
C1.Win.C1FlexGrid.CellRange cr = MyFlexGrid.Selection; // get the selected grid cell range
for (int r = cr.r1; r <= cr.r2; r++)
for (int c = cr.c1; c <= cr.c2; c++)
{
MyFlexGrid.Select(r, c);
MyFlexGrid.StartEditing();
switch (selOpt)
{
case SelectionOption.Start:
MyStepRTB.Select(0, 0);
break;
case SelectionOption.All:
MyStepRTB.SelectAll();
break;
case SelectionOption.End:
MyStepRTB.Select(MyStepRTB.TextLength, 0);
break;
default:
MyStepRTB.Select(0, 0);
break;
}
SetFontSize(MyStepRTB, increase);
}
MyFlexGrid.Select(cr);
}
else
SetFontSize(MyStepRTB, 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;
}
private void ToggleBold()
{
RTBAPI.ToggleBold(!RTBAPI.IsBold(_MyStepRTB), _MyStepRTB, _MyStepRTB.SelectionLength == 0 ? RTBAPI.RTBSelection.SCF_DEFAULT : RTBAPI.RTBSelection.SCF_SELECTION);
@ -2793,6 +2874,14 @@ namespace Volian.Controls.Library
{
_MyStepRTB.SetSelectedCase('T');
}
private void btnFontSizeInc_Click(object sender, EventArgs e)
{
ChangeFontSize(SelectionOption.All, true);
}
private void btnFontSizeDec_Click(object sender, EventArgs e)
{
ChangeFontSize(SelectionOption.All, false);
}
private void btnInsTrans_Click(object sender, EventArgs e)
{
StartGridEditing(SelectionOption.Start);
@ -4017,7 +4106,18 @@ namespace Volian.Controls.Library
{
MyFlexGrid.InsertColumnAfter();
}
public void ToggleTableFontSize(bool visible)
{
bool visl = visible;
if (MyFlexGrid != null)
{
if (MyFlexGrid.IsRoTable) visl = false;
}
lblFontSize.Visible = visl;
btnCMChgFontSize.Visible = visl;
btnCMFontSizeInc.Visible = btnFontSizeInc.Visible = visl;
btnCMFontSizeDec.Visible = btnFontSizeDec.Visible = visl;
}
public void ToggleTableDesignButtons(bool enable)
{
bool enableContent = enable;
@ -4047,6 +4147,7 @@ namespace Volian.Controls.Library
btnTblDgnPaste.Enabled = ((VlnFlexGrid.MyCopyInfo.MyCopiedFlexGrid != null) && enableContent);
btnTblDgnSplitCells.Enabled = enableContent;
btnCmGridSplitCell.Enabled = enableContent;
}
public void SetRibbonForGridCellIndent()
{

View File

@ -3502,7 +3502,7 @@ namespace Volian.Controls.Library
{
if (this[r, c] != null)
{
string strp = DisplayText.StaticStripRtfCommands((string)this[r, c]);
string strp = DisplayText.StaticStripRtfCommands((string)this[r, c], true); // C2020-001: added 'true', in a table
sb.Append(strp.Replace("\r\n", " "));
}
sb.Append("\r\n");