Initialize BorderListBox based upon current DPI
Changed background for border selection Draw Background and Borders for empty cells Set the Borders druing Grid conversion
This commit is contained in:
@@ -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<Items.Count;i++)
|
||||
_MaxLabelWidth = Math.Max(_MaxLabelWidth,(int) gr.MeasureString("XX" + Items[0].ToString(), Font).Width);
|
||||
}
|
||||
return _MaxLabelWidth;
|
||||
}
|
||||
void BorderListBox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
private void BorderListBox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
e.DrawBackground();
|
||||
e.DrawFocusRectangle();
|
||||
@@ -57,7 +78,7 @@ namespace Volian.Controls.Library
|
||||
Brush myBrush = new SolidBrush(e.ForeColor);
|
||||
e.Graphics.DrawString(myGridLBItem.LinePattern.ToString(), Font, myBrush, e.Bounds);
|
||||
Pen pn = VlnBorders.LinePen(myGridLBItem.LinePattern, e.ForeColor);
|
||||
int leftMargin = 50;
|
||||
int leftMargin = MaxLabelWidth(e.Graphics);
|
||||
int rightMargin = 4;
|
||||
switch (myGridLBItem.LinePattern)
|
||||
{
|
||||
|
Reference in New Issue
Block a user