C2021-005 put a dropdown list on font sizes on the table ribbon
This commit is contained in:
@@ -126,7 +126,7 @@ namespace Volian.Controls.Library
|
||||
get { return _MyUserInfo; }
|
||||
set { _MyUserInfo = value; }
|
||||
}
|
||||
|
||||
|
||||
private DevComponents.DotNetBar.ButtonItem _DefaultContextMenu;
|
||||
|
||||
public void ClearContextMenu()
|
||||
@@ -707,7 +707,7 @@ namespace Volian.Controls.Library
|
||||
//// only turn on the Insert Before/After and the CopyStep buttons if on a step part
|
||||
////btnInsAftH.Enabled = btnInsBefH.Enabled = btnInsAfter.Enabled = btnInsBefore.Enabled = btnCpyStp.Enabled =
|
||||
//// allow && !(MyItemInfo.IsProcedure || MyItemInfo.IsSection || MyItemInfo.IsFigure || MyItemInfo.IsTable || MyItemInfo.IsRNOPart);
|
||||
rbPdf.Enabled = allow;
|
||||
btnPdfCreate.Enabled = allow || (MyFlexGrid != null); // allways allow if on a table even if table cell is empty
|
||||
|
||||
//// toggle context menus used with the shortcut key
|
||||
//btnCMInsHLS.Enabled = btnCMInsRNO.Enabled = btnCMInsSubStps.Enabled = btnCMInsCaution.Enabled =
|
||||
@@ -2557,10 +2557,66 @@ 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)
|
||||
//C2021-005 the font size for the selected talbe cell(s)
|
||||
private float GetTableCellFontSize(SelectionOption selOpt)
|
||||
{
|
||||
// Need to check if the selected table cell is in edit mode already.
|
||||
// return 0 if there are multiple font sizes or just an invalid selection
|
||||
float rtnFontSize = -1;
|
||||
// Need to check if the selected table cell is already in edit mode.
|
||||
// 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 rtnFontSize; // 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)
|
||||
{
|
||||
float fntSz = 0;
|
||||
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++)
|
||||
{
|
||||
if (rtnFontSize == 0) continue;
|
||||
MyFlexGrid._GettingFontSize = true;
|
||||
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;
|
||||
}
|
||||
fntSz = MyStepRTB.GetRTFFontSize(); // returns 0 when there are mulitiple font sizes
|
||||
if (rtnFontSize == -1)
|
||||
rtnFontSize = fntSz; // first time getting font size in the foreach loop
|
||||
else if (fntSz == 0 || fntSz != rtnFontSize)
|
||||
rtnFontSize = 0; // indicates multiple font sizes in the selection
|
||||
}
|
||||
MyFlexGrid.Select(cr);
|
||||
MyFlexGrid.Focus();
|
||||
MyFlexGrid._GettingFontSize = false; // _GettingFontSize prevents the cell text editor from flashing on/off when getting font size
|
||||
}
|
||||
else
|
||||
rtnFontSize = MyStepRTB.GetRTFFontSize(); // returns 0 when there are mulitiple font sizes
|
||||
}
|
||||
return rtnFontSize;
|
||||
}
|
||||
// C2021-005 change the font size of the selected table cell(s) or cell text
|
||||
private void ChangeFontSize(SelectionOption selOpt, float newSize)
|
||||
{
|
||||
// ChangeFontSize: similar to code that sets styles (above) except do the font size instead.
|
||||
// Need to check if the selected table cell is already in edit mode.
|
||||
// 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();
|
||||
@@ -2592,15 +2648,28 @@ namespace Volian.Controls.Library
|
||||
MyStepRTB.Select(0, 0);
|
||||
break;
|
||||
}
|
||||
MyStepRTB.SetFontSize(increase);
|
||||
MyStepRTB.SetFontSize(newSize);
|
||||
}
|
||||
MyFlexGrid.Select(cr);
|
||||
}
|
||||
else
|
||||
MyStepRTB.SetFontSize(increase); // not in a grid, apply style to current step type
|
||||
MyStepRTB.SetFontSize(newSize); // not in a grid, apply style to current step type
|
||||
}
|
||||
else
|
||||
MyStepRTB.SetFontSize(increase);
|
||||
{
|
||||
if (MyStepRTB != null)
|
||||
{
|
||||
// the table cell editor lost focus when the font size dropdown is active
|
||||
// Save the text selection information because when we re-activate it the selection
|
||||
// will be lost.
|
||||
// the logic below was copied from the Save Transition button function
|
||||
int ss = MyStepRTB.SelectionStart;
|
||||
int sl = MyStepRTB.SelectionLength;
|
||||
MyStepRTB.OnReturnToEditor(this, new EventArgs());
|
||||
MyStepRTB.Select(ss, sl);
|
||||
MyStepRTB.SetFontSize(newSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ToggleBold()
|
||||
{
|
||||
@@ -4139,10 +4208,14 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (MyFlexGrid.IsRoTable) visl = false;
|
||||
}
|
||||
lblFontSize.Visible = visl;
|
||||
btnCMChgFontSize.Visible = visl;
|
||||
btnCMFontSizeInc.Visible = btnFontSizeInc.Visible = visl;
|
||||
btnCMFontSizeDec.Visible = btnFontSizeDec.Visible = visl;
|
||||
// C2021-005 - setup the font size dropdowns for the table ribbon and context menu
|
||||
// A list of font sizes is set in the base format file and can be overidden in a plant's format file
|
||||
string tfntszs = MyItemInfo.ActiveFormat.PlantFormat.FormatData.FontSizes.TableFontSizes;
|
||||
rbTblFntSz.Items.Clear();
|
||||
cmFontSizeList.Items.Clear();
|
||||
rbTblFntSz.Items.AddRange(tfntszs.Replace(" ", "").Split(",".ToCharArray())); // dropdown on table ribbon
|
||||
cmFontSizeList.Items.AddRange(tfntszs.Replace(" ", "").Split(",".ToCharArray())); // dropdown on context menu
|
||||
}
|
||||
public void ToggleTableDesignButtons(bool enable)
|
||||
{
|
||||
@@ -4219,6 +4292,23 @@ namespace Volian.Controls.Library
|
||||
btnInsRO.Enabled = enable && Mydvi.DocVersionAssociationCount > 0; // 2016-128 don't enable if RO Path was not selected at the Working Draft node
|
||||
btnCMRtfCellEdit.Enabled = enable && !MyFlexGrid.IsRoTable;
|
||||
}
|
||||
private bool _initTblFontSizeDropdown = true; // C2021-005 flag to allow setting font size in dropdown without triggering the dropdown item select
|
||||
// C2021-005 get the font size being used in the selected table cell(s) then ititialize the font dropdown
|
||||
public void SetFontSizeDropDown()
|
||||
{
|
||||
float sz = GetTableCellFontSize(SelectionOption.All);
|
||||
SetFontSizeDropDownText(sz);
|
||||
}
|
||||
// C2021-005 Initialize the font size dropdown
|
||||
public void SetFontSizeDropDownText(float fsz)
|
||||
{
|
||||
_initTblFontSizeDropdown = true;
|
||||
rbTblFntSz.SelectedIndex = -1;
|
||||
rbTblFntSz.Text = fsz.ToString();
|
||||
cmFontSizeList.SelectedIndex = -1;
|
||||
cmFontSizeList.Text = fsz.ToString();
|
||||
_initTblFontSizeDropdown = false;
|
||||
}
|
||||
private void btnTblDgnAdjustSize_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MyFlexGrid.Cols.Fixed == 0) // allow change of size.
|
||||
@@ -4428,6 +4518,26 @@ namespace Volian.Controls.Library
|
||||
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Change Image Size");
|
||||
MyEditItem.MyStepPanel.OnTabDisplay(sender, args);
|
||||
}
|
||||
|
||||
// C2021-005 user selected a font size from the dropdown (table ribbon)
|
||||
private void rbTblFntSz_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_initTblFontSizeDropdown)
|
||||
{
|
||||
float newSize = Convert.ToSingle(rbTblFntSz.SelectedItem); // font size selction from dropdown
|
||||
ChangeFontSize(SelectionOption.All, newSize); // newSize is the font pt size not the RFT font size (which is twice the pt size)
|
||||
}
|
||||
}
|
||||
|
||||
// C2021-005 user selected a font size from the dropdown (context menu)
|
||||
private void cmFontSizeList_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_initTblFontSizeDropdown)
|
||||
{
|
||||
float newSize = Convert.ToSingle(cmFontSizeList.SelectedItem);
|
||||
ChangeFontSize(SelectionOption.All, newSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class StepTabRibbonEventArgs : EventArgs
|
||||
{
|
||||
|
Reference in New Issue
Block a user