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:
2020-02-11 12:42:26 +00:00
parent 23354f3ed2
commit 448f2e5653
8 changed files with 1829 additions and 1721 deletions

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");