diff --git a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs index 846369bd..c3754665 100644 --- a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs +++ b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs @@ -137,6 +137,24 @@ namespace Volian.Controls.Library GridItem.MyUserInfo = value; } } + + // C2021-005 used by the table cell editor to pass font size information + private float _SelectedFontSize; + public float SelectedFontSize + { + get { return _SelectedFontSize; } + set + { + if (Parent is GridItem) + { + _SelectedFontSize = (float)value; + // initialize the font size dropdown + (Parent as GridItem).MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetFontSizeDropDownText(value); + _DoubleClickedCell = false; + } + } + } + public bool IsDirty { get @@ -1069,6 +1087,23 @@ namespace Volian.Controls.Library this.KeyUp +=new KeyEventHandler(VlnFlexGrid_KeyUp); TableCellEditor.EditMode = TableCellEditor.Visible; // need to comment out for compile for only jsj - 07FEB2011 this.MouseDown += new MouseEventHandler(VlnFlexGrid_MouseDown); + this.MouseUp += VlnFlexGrid_MouseUp; + this.DoubleClick += VlnFlexGrid_DoubleClick; + } + private bool _DoubleClickedCell = false; // C2021-005 need to know if user double-clicked on a cell + private void VlnFlexGrid_DoubleClick(object sender, EventArgs e) + { + // if user did a double click then don't try to get the font size - go directly to editing the table cell text + _DoubleClickedCell = true; + } + + // C2021-005 needed the mouseup event to control the table cell selecting and grabbing of the font size + public bool _GettingFontSize = false; + private void VlnFlexGrid_MouseUp(object sender, MouseEventArgs e) + { + // C2021-005 Get the font size if user didn't double click and on a table + if (!_DoubleClickedCell && Parent != null && Parent is GridItem && Cols.Fixed == 0 && Rows.Fixed == 0) + (Parent as GridItem).MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetFontSizeDropDown(); } private bool _FirstEntry = false; @@ -1112,8 +1147,6 @@ namespace Volian.Controls.Library _FirstEntry = false; } - - void _tableCellEditor_HeightChanged(object sender, EventArgs args) { if (_tableCellEditor._initializingEdit || !_tableCellEditor.Visible) return; @@ -2435,7 +2468,7 @@ namespace Volian.Controls.Library { // start editing the cell with the custom editor if(!IsRoTable ) - _tableCellEditor.StartEditing(e.Row, e.Col); + _tableCellEditor.StartEditing(e.Row, e.Col, _GettingFontSize); // C2021-005 added _GettingFontSize to prevent showing the editor e.Cancel = true; } @@ -3159,8 +3192,23 @@ namespace Volian.Controls.Library } if (dr == DialogResult.Yes) CopyToCopiedFlexGrid(GridCopyOption.Row); + //TestSetBackgroundColor(); } - + //public void TestSetBackgroundColor() + //{ + // for (int r = Selection.r1; r <= Selection.r2; r++) + // for (int c = Selection.c1; c <= Selection.c2; c++) + // { + // CellRange cr = GetMergedRange(r, c); + // if (cr.Style == null) cr.Style = this.Styles.Add("Shading"); + // if (cr.Style != null && cr.Style.BackColor != Color.DarkGreen && cr.Style.Name != "Fixed") + // { + // { + // cr.Style.BackColor = Color.DarkGreen; + // } + // } + // } + //} public void CopyColumn() { _tableCellEditor.Hide(); // B2017-200 force save of changes from active edit session @@ -4391,7 +4439,10 @@ namespace Volian.Controls.Library CellRange cr = GetMergedRange(r, c); if (cr.Style != null && cr.Style.BackColor != value && cr.Style.Name != "Fixed") { - cr.Style.BackColor = value; + //if (r == 0 && c == 0) + // cr.Style.BackColor = Color.DarkGreen; + //else + cr.Style.BackColor = value; //Console.WriteLine("{0}, {1}, {2}, {3}", r, c, cr.Style.Name, cr.Style.BackColor); } } @@ -4621,14 +4672,27 @@ namespace Volian.Controls.Library this.CursorMovement += new StepRTBCursorMovementEvent(TableCellEditor_CursorMovement); this.CursorKeyPress += new StepRTBCursorKeysEvent(TableCellEditor_CursorKeyPress); this.Leave += new EventHandler(_editor_Leave); + this.SelectionChanged += TableCellEditor_SelectionChanged; //this.HeightChanged += new StepRTBEvent(_HeightChanged); } + + // C2021-005 selecting characters in the cell text editor + private void TableCellEditor_SelectionChanged(object sender, EventArgs e) + { + if (!_initializingEdit) + { + float fnSz = GetRTFFontSize(); // returns the font size in pts from the text's RTF + _owner.SelectedFontSize = fnSz; // will trigger the changing of the font size from VlnFlexGrid class + } + } + protected override void Dispose(bool disposing) { base.Dispose(disposing); } // start editing: move to cell and activate - public void StartEditing(int row, int col) + // C2021-005 added the showEditor - set to true when we are getting the font size of the text + public void StartEditing(int row, int col, bool showEditor) { ItemInfo pinfo = MyItemInfo.MyProcedure as ItemInfo; DocVersionInfo dvi = (pinfo == null) ? null : pinfo.ActiveParent as DocVersionInfo; @@ -4674,12 +4738,15 @@ namespace Volian.Controls.Library //this.Size = sz; this.Width = rc.Width; + if (!showEditor) // C2021-005 if we are getting the font size don't show the editor + { // make editor visible - Visible = true; + Visible = true; + } - // and get the focus - //Select(); - Focus(); + // and get the focus + //Select(); + Focus(); _initializingEdit = false; }