diff --git a/PROMS/Volian.Controls.Library/BorderListBox.cs b/PROMS/Volian.Controls.Library/BorderListBox.cs index 7c55558a..72f0a1d6 100644 --- a/PROMS/Volian.Controls.Library/BorderListBox.cs +++ b/PROMS/Volian.Controls.Library/BorderListBox.cs @@ -34,7 +34,7 @@ namespace Volian.Controls.Library //this.Font.Size; DrawItem += new DrawItemEventHandler(BorderListBox_DrawItem); //MeasureItem += new MeasureItemEventHandler(BorderListBox_MeasureItem); - Items.Add(new GridLBItem( GridLinePattern.None )); + Items.Add(new GridLBItem(GridLinePattern.None)); Items.Add(new GridLBItem(GridLinePattern.Single)); Items.Add(new GridLBItem(GridLinePattern.Double)); Items.Add(new GridLBItem(GridLinePattern.Thick)); @@ -42,13 +42,34 @@ namespace Volian.Controls.Library Items.Add(new GridLBItem(GridLinePattern.Dotted)); SelectedIndex = 1; } + public void SetupFontAndSize(int fontSize) + { + Font = new Font(Font.FontFamily, fontSize, Font.Style); + using (Graphics gr = CreateGraphics()) + { + SizeF mySize = gr.MeasureString("Almg", Font); + ItemHeight = (int)Math.Ceiling(mySize.Height); + } + int newHeight = Items.Count * ItemHeight + 4; + Size = new Size(newHeight, newHeight); + } #endregion #region Event Handlers - void BorderListBox_MeasureItem(object sender, MeasureItemEventArgs e) + //void BorderListBox_MeasureItem(object sender, MeasureItemEventArgs e) + //{ + // e.ItemHeight = 22; + //} + private int _MaxLabelWidth = 0; + private int MaxLabelWidth(Graphics gr) { - e.ItemHeight = 22; + if(_MaxLabelWidth == 0) + { + for(int i=0;i= MyFlexGrid.Cols.Count-1 || MyFlexGrid.Selection.r1 >= MyFlexGrid.Rows.Count-1) + return; C1.Win.C1FlexGrid.CellRange cr = MyFlexGrid.GetEvenSelection(); rbnBorderSelectionPanel.InitializeBorder(MyFlexGrid.MyBorders, cr.r1, cr.c1, cr.r2, cr.c2); } @@ -288,6 +290,8 @@ namespace Volian.Controls.Library // Note: the QAT menu is to the right of the V start button in the upper left _RibbonControl.AutoExpand = false; _RibbonControl.Items[0].RaiseClick(); // initially default to HOME tab + rbnBorderlistBox.Resize+=new EventHandler(rbnBorderlistBox_Resize); + rbnBorderlistBox.SetupFontAndSize(6); // 6 Point Font } void _RibbonControl_SizeChanged(object sender, EventArgs e) @@ -1891,26 +1895,25 @@ namespace Volian.Controls.Library MyEditItem.Invalidate(); MyFlexGrid.Invalidate(); } - private void btnTblNoBorder_Click(object sender, EventArgs e) { rbnBorderSelectionPanel.AllBorders = GridLinePattern.None; } - private void btnTblOutline_Click(object sender, EventArgs e) { rbnBorderSelectionPanel.OutlineBorder = rbnBorderlistBox.SelectedLinePattern; } - private void btnTblInside_Click(object sender, EventArgs e) { rbnBorderSelectionPanel.InsideBorders = rbnBorderlistBox.SelectedLinePattern; } - + private void rbnBorderlistBox_Resize(object sender, EventArgs e) + { + rbnBorderSelectionPanel.Size = rbnBorderlistBox.Size; + _RibbonControl.Height = rbnBorderlistBox.Height + _RibbonControl.Height - _RibbonControl.ClientSize.Height; + //_RibbonControl.Height = rbnBorderlistBox.Height + _RibbonControl.Height - _RibbonControl.ClientSize.Height; + } } - - - public enum E_FieldToEdit { StepText, Text, Number }; public class StepTabRibbonEventArgs : EventArgs { diff --git a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs index b1564294..f9e1c9c9 100644 --- a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs +++ b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs @@ -660,10 +660,10 @@ namespace Volian.Controls.Library DisplayText dt = new DisplayText(gi.MyItemInfo, rtfText, true); rtfText = dt.StartText; } + // it does, so draw background + e.DrawCell(DrawCellFlags.Background); if (rtfText.StartsWith(@"{\rtf")) { - // it does, so draw background - e.DrawCell(DrawCellFlags.Background); // draw the RTF text if (e.Bounds.Width > 0 && e.Bounds.Height > 0) @@ -683,23 +683,23 @@ namespace Volian.Controls.Library } if (e.Style != null) { - switch (e.Style.TextAlign) - { - case TextAlignEnum.CenterBottom: - case TextAlignEnum.GeneralBottom: - case TextAlignEnum.LeftBottom: - case TextAlignEnum.RightBottom: - hAdjust = hDiff; - break; - case TextAlignEnum.CenterCenter: - case TextAlignEnum.GeneralCenter: - case TextAlignEnum.LeftCenter: - case TextAlignEnum.RightCenter: - hAdjust = hDiff / 2; - break; - default: - break; - } + switch (e.Style.TextAlign) + { + case TextAlignEnum.CenterBottom: + case TextAlignEnum.GeneralBottom: + case TextAlignEnum.LeftBottom: + case TextAlignEnum.RightBottom: + hAdjust = hDiff; + break; + case TextAlignEnum.CenterCenter: + case TextAlignEnum.GeneralCenter: + case TextAlignEnum.LeftCenter: + case TextAlignEnum.RightCenter: + hAdjust = hDiff / 2; + break; + default: + break; + } } if (IsRoTable) { @@ -710,19 +710,18 @@ namespace Volian.Controls.Library _rtf.ForeColor = e.Style.ForeColor; } _rtf.BackColor = e.Style.BackColor; - _rtf.Render(e.Graphics, new Rectangle(e.Bounds.X+1,e.Bounds.Y + hAdjust,e.Bounds.Width-3,e.Bounds.Height)); + _rtf.Render(e.Graphics, new Rectangle(e.Bounds.X + 1, e.Bounds.Y + hAdjust, e.Bounds.Width - 3, e.Bounds.Height)); //CellRange cr = GetCellRange(e.Row, e.Col); //Console.WriteLine("ownerDraw UserData [{0},{1}] = {2}", cr.r1, cr.c1, _rtf.ContentsRectangle.Height); //cr.UserData = _rtf.ContentsRectangle.Height; } - - // and draw border last - //e.DrawCell(DrawCellFlags.Border); - // This can be used to draw more specific borders - DrawCellBorder(e); - // we're done with this cell - e.Handled = true; } + // and draw border last + //e.DrawCell(DrawCellFlags.Border); + // This can be used to draw more specific borders + DrawCellBorder(e); + // we're done with this cell + e.Handled = true; } } @@ -3003,7 +3002,8 @@ namespace Volian.Controls.Library TrimMergedRangeCellText(cr); } } - } + MyBorders = new VlnBorders(GridLinePattern.Single, Rows.Count, Cols.Count); + } //private Regex _RemoveComments = new Regex(@"\\v .*?\\v0( |$)");