* UIDataGridView:更新默认设置为原生控件设置
This commit is contained in:
parent
12227b3404
commit
f3adc6af6e
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
BIN
Bin/SunnyUI.pdb
BIN
Bin/SunnyUI.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,6 @@
|
|||||||
namespace Sunny.UI.Demo.Charts
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace Sunny.UI.Demo.Charts
|
||||||
{
|
{
|
||||||
public partial class FBarChart : UITitlePage
|
public partial class FBarChart : UITitlePage
|
||||||
{
|
{
|
||||||
@ -52,6 +54,9 @@
|
|||||||
option.XAxis.Name = "日期";
|
option.XAxis.Name = "日期";
|
||||||
option.YAxis.Name = "数值";
|
option.YAxis.Name = "数值";
|
||||||
|
|
||||||
|
option.YAxisScaleLines.Add(new UIScaleLine() { Color = Color.Red, Name = "上限", Value = 12 });
|
||||||
|
option.YAxisScaleLines.Add(new UIScaleLine() { Color = Color.Gold, Name = "下限", Value = -20 });
|
||||||
|
|
||||||
BarChart.SetOption(option);
|
BarChart.SetOption(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
series.Name = "Star count";
|
series.Name = "Star count";
|
||||||
series.Center = new UICenter(50, 55);
|
series.Center = new UICenter(50, 55);
|
||||||
series.Radius = 70;
|
series.Radius = 70;
|
||||||
|
series.Label.Show = true;
|
||||||
|
|
||||||
//增加数据
|
//增加数据
|
||||||
series.AddData("2020-05-19", 38);
|
series.AddData("2020-05-19", 38);
|
||||||
|
@ -81,7 +81,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
if (YAxisStart >= 0)
|
if (YAxisStart >= 0)
|
||||||
{
|
{
|
||||||
float h = Math.Abs((float)(DrawSize.Height * (series.Data[j]- start *interval) / ((end -start) * interval)));
|
float h = Math.Abs((float)(DrawSize.Height * (series.Data[j] - start * interval) / ((end - start) * interval)));
|
||||||
|
|
||||||
Bars[i].Add(new BarInfo()
|
Bars[i].Add(new BarInfo()
|
||||||
{
|
{
|
||||||
@ -91,9 +91,9 @@ namespace Sunny.UI
|
|||||||
x2, h)
|
x2, h)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (YAxisEnd<=0)
|
else if (YAxisEnd <= 0)
|
||||||
{
|
{
|
||||||
float h = Math.Abs((float)(DrawSize.Height * (end * interval-series.Data[j]) / ((end - start) * interval)));
|
float h = Math.Abs((float)(DrawSize.Height * (end * interval - series.Data[j]) / ((end - start) * interval)));
|
||||||
Bars[i].Add(new BarInfo()
|
Bars[i].Add(new BarInfo()
|
||||||
{
|
{
|
||||||
Rect = new RectangleF(
|
Rect = new RectangleF(
|
||||||
@ -294,6 +294,7 @@ namespace Sunny.UI
|
|||||||
DrawSeries(g, BarOption.Series);
|
DrawSeries(g, BarOption.Series);
|
||||||
if (BarOption.ToolTip != null && BarOption.ToolTip.AxisPointer.Type == UIAxisPointerType.Line) DrawToolTip(g);
|
if (BarOption.ToolTip != null && BarOption.ToolTip.AxisPointer.Type == UIAxisPointerType.Line) DrawToolTip(g);
|
||||||
DrawLegend(g, BarOption.Legend);
|
DrawLegend(g, BarOption.Legend);
|
||||||
|
DrawAxisScales(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawToolTip(Graphics g)
|
private void DrawToolTip(Graphics g)
|
||||||
@ -314,8 +315,8 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
private void DrawAxis(Graphics g)
|
private void DrawAxis(Graphics g)
|
||||||
{
|
{
|
||||||
if (YAxisStart>=0) g.DrawLine(ChartStyle.ForeColor, DrawOrigin, new Point(DrawOrigin.X + DrawSize.Width, DrawOrigin.Y));
|
if (YAxisStart >= 0) g.DrawLine(ChartStyle.ForeColor, DrawOrigin, new Point(DrawOrigin.X + DrawSize.Width, DrawOrigin.Y));
|
||||||
if (YAxisEnd <= 0) g.DrawLine(ChartStyle.ForeColor, new Point(DrawOrigin.X, BarOption.Grid.Top), new Point(DrawOrigin.X + DrawSize.Width, BarOption.Grid.Top));
|
if (YAxisEnd <= 0) g.DrawLine(ChartStyle.ForeColor, new Point(DrawOrigin.X, BarOption.Grid.Top), new Point(DrawOrigin.X + DrawSize.Width, BarOption.Grid.Top));
|
||||||
|
|
||||||
g.DrawLine(ChartStyle.ForeColor, DrawOrigin, new Point(DrawOrigin.X, DrawOrigin.Y - DrawSize.Height));
|
g.DrawLine(ChartStyle.ForeColor, DrawOrigin, new Point(DrawOrigin.X, DrawOrigin.Y - DrawSize.Height));
|
||||||
|
|
||||||
@ -367,7 +368,7 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
SizeF sfname = g.MeasureString(BarOption.XAxis.Name, SubFont);
|
SizeF sfname = g.MeasureString(BarOption.XAxis.Name, SubFont);
|
||||||
g.DrawString(BarOption.XAxis.Name,SubFont,ChartStyle.ForeColor, DrawOrigin.X +(DrawSize.Width-sfname.Width)/2.0f, DrawOrigin.Y + BarOption.XAxis.AxisTick.Length +sfname.Height);
|
g.DrawString(BarOption.XAxis.Name, SubFont, ChartStyle.ForeColor, DrawOrigin.X + (DrawSize.Width - sfname.Width) / 2.0f, DrawOrigin.Y + BarOption.XAxis.AxisTick.Length + sfname.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BarOption.YAxis.AxisTick.Show)
|
if (BarOption.YAxis.AxisTick.Show)
|
||||||
@ -420,9 +421,23 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
SizeF sfname = g.MeasureString(BarOption.YAxis.Name, SubFont);
|
SizeF sfname = g.MeasureString(BarOption.YAxis.Name, SubFont);
|
||||||
int x = (int)(DrawOrigin.X - BarOption.YAxis.AxisTick.Length - wmax - sfname.Height);
|
int x = (int)(DrawOrigin.X - BarOption.YAxis.AxisTick.Length - wmax - sfname.Height);
|
||||||
int y = (int) (BarOption.Grid.Top + (DrawSize.Height - sfname.Width) / 2);
|
int y = (int)(BarOption.Grid.Top + (DrawSize.Height - sfname.Width) / 2);
|
||||||
g.DrawString(BarOption.YAxis.Name,SubFont,ChartStyle.ForeColor, new Point(x,y),
|
g.DrawString(BarOption.YAxis.Name, SubFont, ChartStyle.ForeColor, new Point(x, y),
|
||||||
new StringFormat(){Alignment = StringAlignment.Center}, 270);
|
new StringFormat() { Alignment = StringAlignment.Center }, 270);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawAxisScales(Graphics g)
|
||||||
|
{
|
||||||
|
foreach (var line in BarOption.YAxisScaleLines)
|
||||||
|
{
|
||||||
|
double ymin = YAxisStart * YAxisInterval;
|
||||||
|
double ymax = YAxisEnd * YAxisInterval;
|
||||||
|
float pos = (float)((line.Value - ymin) * (Height - BarOption.Grid.Top - BarOption.Grid.Bottom) / (ymax - ymin));
|
||||||
|
pos = (Height - BarOption.Grid.Bottom - pos);
|
||||||
|
g.DrawLine(line.Color, DrawOrigin.X, pos, Width - BarOption.Grid.Right, pos);
|
||||||
|
SizeF sf = g.MeasureString(line.Name, SubFont);
|
||||||
|
g.DrawString(line.Name, SubFont, line.Color, DrawOrigin.X + 4, pos - 2 - sf.Height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public UIChartGrid Grid = new UIChartGrid();
|
public UIChartGrid Grid = new UIChartGrid();
|
||||||
|
|
||||||
//public UIPieLegend Legend;
|
public readonly List<UIScaleLine> XAxisScaleLines = new List<UIScaleLine>();
|
||||||
|
|
||||||
//public UIPieToolTip ToolTip;
|
public readonly List<UIScaleLine> YAxisScaleLines = new List<UIScaleLine>();
|
||||||
|
|
||||||
public void AddSeries(UIBarSeries series)
|
public void AddSeries(UIBarSeries series)
|
||||||
{
|
{
|
||||||
@ -43,7 +43,7 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public string ValueFormat { get; set; } = "F0";
|
public string ValueFormat { get; set; } = "F0";
|
||||||
|
|
||||||
public UIAxisPointer AxisPointer= new UIAxisPointer();
|
public UIAxisPointer AxisPointer = new UIAxisPointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UIAxisPointer
|
public class UIAxisPointer
|
||||||
@ -53,7 +53,7 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public enum UIAxisPointerType
|
public enum UIAxisPointerType
|
||||||
{
|
{
|
||||||
Line,Shadow
|
Line, Shadow
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UIAxis
|
public class UIAxis
|
||||||
@ -111,13 +111,13 @@ namespace Sunny.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int Interval { get; set; } = 0;
|
public int Interval { get; set; } = 0;
|
||||||
|
|
||||||
public delegate string DoFormatter(double value,int index);
|
public delegate string DoFormatter(double value, int index);
|
||||||
|
|
||||||
public event DoFormatter Formatter;
|
public event DoFormatter Formatter;
|
||||||
|
|
||||||
public string GetLabel(double value, int index)
|
public string GetLabel(double value, int index)
|
||||||
{
|
{
|
||||||
return Formatter != null ? Formatter?.Invoke(value, index) : value.ToString("F"+ DecimalCount);
|
return Formatter != null ? Formatter?.Invoke(value, index) : value.ToString("F" + DecimalCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -92,7 +92,7 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UILiveChartStyle:UIChartStyle
|
public class UILiveChartStyle : UIChartStyle
|
||||||
{
|
{
|
||||||
public override Color BackColor => Color.FromArgb(16, 36, 71);
|
public override Color BackColor => Color.FromArgb(16, 36, 71);
|
||||||
|
|
||||||
@ -106,10 +106,10 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
return new[]
|
return new[]
|
||||||
{
|
{
|
||||||
Color.FromArgb(33, 149, 242),
|
Color.FromArgb(33, 149, 242),
|
||||||
Color.FromArgb(254, 192, 7),
|
Color.FromArgb(254, 192, 7),
|
||||||
Color.FromArgb(243, 67, 54),
|
Color.FromArgb(243, 67, 54),
|
||||||
Color.FromArgb(96, 125, 138),
|
Color.FromArgb(96, 125, 138),
|
||||||
Color.FromArgb(0,187,211),
|
Color.FromArgb(0,187,211),
|
||||||
Color.FromArgb(232,30,99),
|
Color.FromArgb(232,30,99),
|
||||||
Color.FromArgb(254,87,34),
|
Color.FromArgb(254,87,34),
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
@ -30,6 +31,13 @@ namespace Sunny.UI
|
|||||||
public UILegend Legend;
|
public UILegend Legend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class UIScaleLine
|
||||||
|
{
|
||||||
|
public double Value { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public Color Color { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class UILegend
|
public class UILegend
|
||||||
{
|
{
|
||||||
public UILeftAlignment Left { get; set; } = UILeftAlignment.Center;
|
public UILeftAlignment Left { get; set; } = UILeftAlignment.Center;
|
||||||
|
@ -130,6 +130,26 @@ namespace Sunny.UI
|
|||||||
RectangleF rectx = new RectangleF(rect.X - 10, rect.Y - 10, rect.Width + 20, rect.Width + 20);
|
RectangleF rectx = new RectangleF(rect.X - 10, rect.Y - 10, rect.Width + 20, rect.Width + 20);
|
||||||
g.FillPie(color, (ActivePieIndex == pieIndex && ActiveAzIndex == azIndex) ? rectx : rect, Angles[pieIndex][azIndex].Start - 90, Angles[pieIndex][azIndex].Sweep);
|
g.FillPie(color, (ActivePieIndex == pieIndex && ActiveAzIndex == azIndex) ? rectx : rect, Angles[pieIndex][azIndex].Start - 90, Angles[pieIndex][azIndex].Sweep);
|
||||||
Angles[pieIndex][azIndex].TextSize = g.MeasureString(Angles[pieIndex][azIndex].Text, LegendFont);
|
Angles[pieIndex][azIndex].TextSize = g.MeasureString(Angles[pieIndex][azIndex].Text, LegendFont);
|
||||||
|
|
||||||
|
if (pie.Label.Show)
|
||||||
|
{
|
||||||
|
double az = Angles[pieIndex][azIndex].Start + Angles[pieIndex][azIndex].Sweep / 2;
|
||||||
|
double x = Math.Abs(Math.Sin(az * Math.PI / 180));
|
||||||
|
double y = Math.Abs(Math.Cos(az * Math.PI / 180));
|
||||||
|
|
||||||
|
SizeF sf = g.MeasureString(pie.Data[0].Value.ToString("F0"), SubFont);
|
||||||
|
PointF pf;
|
||||||
|
if (az >= 0 && az < 90)
|
||||||
|
pf = new PointF((float)(DrawCenter(pie).X + RadiusSize(pie) * x + 6), (float)(DrawCenter(pie).Y - RadiusSize(pie) * y - sf.Height - 6));
|
||||||
|
else if (az >= 90 && az < 180)
|
||||||
|
pf = new PointF((float)(DrawCenter(pie).X + RadiusSize(pie) * x + 6), (float)(DrawCenter(pie).Y + RadiusSize(pie) * y + 6));
|
||||||
|
else if (az >= 180 && az < 270)
|
||||||
|
pf = new PointF((float)(DrawCenter(pie).X - RadiusSize(pie) * x - 6) - sf.Width, (float)(DrawCenter(pie).Y + RadiusSize(pie) * y + 6));
|
||||||
|
else
|
||||||
|
pf = new PointF((float)(DrawCenter(pie).X - RadiusSize(pie) * x - 6) - sf.Width, (float)(DrawCenter(pie).Y - RadiusSize(pie) * y) - sf.Height - 6);
|
||||||
|
|
||||||
|
g.DrawString(pie.Data[azIndex].Value.ToString("F0"), SubFont, color, pf.X, pf.Y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,6 +252,24 @@ namespace Sunny.UI
|
|||||||
return new RectangleF(left - halfRadius, top - halfRadius, halfRadius * 2, halfRadius * 2);
|
return new RectangleF(left - halfRadius, top - halfRadius, halfRadius * 2, halfRadius * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Point DrawCenter(UIPieSeries series)
|
||||||
|
{
|
||||||
|
int left = series.Center.Left;
|
||||||
|
int top = series.Center.Top;
|
||||||
|
left = Width * left / 100;
|
||||||
|
top = Height * top / 100;
|
||||||
|
return new Point(left, top);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float RadiusSize(UIPieSeries series)
|
||||||
|
{
|
||||||
|
int left = series.Center.Left;
|
||||||
|
int top = series.Center.Top;
|
||||||
|
left = Width * left / 100;
|
||||||
|
top = Height * top / 100;
|
||||||
|
return Math.Min(Width, Height) * series.Radius / 200.0f;
|
||||||
|
}
|
||||||
|
|
||||||
private class Angle
|
private class Angle
|
||||||
{
|
{
|
||||||
public float Start { get; set; }
|
public float Start { get; set; }
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
* 创建日期: 2020-01-01
|
* 创建日期: 2020-01-01
|
||||||
*
|
*
|
||||||
* 2020-01-01: V2.2.0 增加文件说明
|
* 2020-01-01: V2.2.0 增加文件说明
|
||||||
* 2020-04-25: V2.2.4 功能增强、美化
|
* 2020-04-25: V2.2.4 功能增强、美化
|
||||||
|
* 2020-07-15: V2.2.6 更改默认配置为原生
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -29,26 +30,23 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
public sealed class UIDataGridView : DataGridView, IStyleInterface
|
public sealed class UIDataGridView : DataGridView, IStyleInterface
|
||||||
{
|
{
|
||||||
private readonly UIScrollBar Bar = new UIScrollBar();
|
private readonly UIScrollBar VBar = new UIScrollBar();
|
||||||
|
|
||||||
public UIDataGridView()
|
public UIDataGridView()
|
||||||
{
|
{
|
||||||
BackgroundColor = UIColor.White;
|
BackgroundColor = UIColor.White;
|
||||||
GridColor = UIColor.Blue;
|
GridColor = UIColor.Blue;
|
||||||
Font = UIFontColor.Font;
|
Font = UIFontColor.Font;
|
||||||
ScrollBars = ScrollBars.Vertical;
|
|
||||||
DoubleBuffered = true;
|
DoubleBuffered = true;
|
||||||
Bar.Parent = this;
|
|
||||||
Bar.Visible = false;
|
VBar.Parent = this;
|
||||||
Bar.FillColor = UIColor.LightBlue;
|
VBar.Visible = false;
|
||||||
Bar.ForeColor = UIColor.Blue;
|
VBar.FillColor = UIColor.LightBlue;
|
||||||
Bar.StyleCustomMode = true;
|
VBar.ForeColor = UIColor.Blue;
|
||||||
Bar.ValueChanged += Bar_ValueChanged;
|
VBar.StyleCustomMode = true;
|
||||||
|
VBar.ValueChanged += VBarValueChanged;
|
||||||
SetBarPosition();
|
SetBarPosition();
|
||||||
|
|
||||||
//列占满行
|
|
||||||
AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
|
|
||||||
//支持自定义标题行风格
|
//支持自定义标题行风格
|
||||||
EnableHeadersVisualStyles = false;
|
EnableHeadersVisualStyles = false;
|
||||||
|
|
||||||
@ -66,12 +64,26 @@ namespace Sunny.UI
|
|||||||
RowTemplate.Height = 29;
|
RowTemplate.Height = 29;
|
||||||
RowTemplate.MinimumHeight = 29;
|
RowTemplate.MinimumHeight = 29;
|
||||||
AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
|
AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
|
||||||
|
|
||||||
|
//设置奇偶数行颜色
|
||||||
|
StripeEvenColor = UIColor.White;
|
||||||
|
StripeOddColor = UIColor.LightBlue;
|
||||||
|
|
||||||
|
VerticalScrollBar.ValueChanged += VerticalScrollBar_ValueChanged;
|
||||||
|
|
||||||
|
Style = UIStyle.Blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
//列占满行
|
||||||
|
//AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
|
||||||
//行选
|
//行选
|
||||||
SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
|
||||||
//禁止调整数据行行高
|
//禁止调整数据行行高
|
||||||
//AllowUserToResizeRows = false;
|
AllowUserToResizeRows = false;
|
||||||
|
|
||||||
//允许调整标题行行宽
|
//允许调整标题行行宽
|
||||||
AllowUserToResizeColumns = true;
|
AllowUserToResizeColumns = true;
|
||||||
@ -83,36 +95,44 @@ namespace Sunny.UI
|
|||||||
//MultiSelect = false;
|
//MultiSelect = false;
|
||||||
|
|
||||||
//自动生成行
|
//自动生成行
|
||||||
AutoGenerateColumns = true;
|
//AutoGenerateColumns = true;
|
||||||
|
|
||||||
//禁用最后一行空白,自动新增行
|
//禁用最后一行空白,自动新增行
|
||||||
AllowUserToAddRows = false;
|
AllowUserToAddRows = false;
|
||||||
|
AllowUserToDeleteRows = false;
|
||||||
|
|
||||||
//禁止只读
|
//禁止只读
|
||||||
ReadOnly = false;
|
//ReadOnly = false;
|
||||||
|
|
||||||
//不显示表格线
|
//不显示表格线
|
||||||
CellBorderStyle = DataGridViewCellBorderStyle.None;
|
CellBorderStyle = DataGridViewCellBorderStyle.None;
|
||||||
|
}
|
||||||
|
|
||||||
StripeEvenColor = UIColor.White;
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
StripeOddColor = UIColor.LightBlue;
|
{
|
||||||
|
base.OnPaint(e);
|
||||||
|
|
||||||
VerticalScrollBar.ValueChanged += VerticalScrollBar_ValueChanged;
|
if (ShowRect)
|
||||||
|
{
|
||||||
|
Color color = RectColor;
|
||||||
|
color = Enabled ? color : UIDisableColor.Fill;
|
||||||
|
e.Graphics.DrawRectangle(color, new Rectangle(0, 0, Width - 1, Height - 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void VerticalScrollBar_ValueChanged(object sender, EventArgs e)
|
private void VerticalScrollBar_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Bar.Value = FirstDisplayedScrollingRowIndex;
|
VBar.Value = FirstDisplayedScrollingRowIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Bar_ValueChanged(object sender, EventArgs e)
|
private void VBarValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
FirstDisplayedScrollingRowIndex = Bar.Value;
|
FirstDisplayedScrollingRowIndex = VBar.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetScrollInfo()
|
public void SetScrollInfo()
|
||||||
{
|
{
|
||||||
if (Bar == null)
|
if (VBar == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -120,28 +140,28 @@ namespace Sunny.UI
|
|||||||
if (VerticalScrollBar.Visible)
|
if (VerticalScrollBar.Visible)
|
||||||
{
|
{
|
||||||
SetBarPosition();
|
SetBarPosition();
|
||||||
Bar.Maximum = RowCount - 1;
|
VBar.Maximum = RowCount - 1;
|
||||||
Bar.Value = FirstDisplayedScrollingRowIndex;
|
VBar.Value = FirstDisplayedScrollingRowIndex;
|
||||||
Bar.Visible = true;
|
VBar.Visible = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Bar.Visible = false;
|
VBar.Visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnMouseWheel(MouseEventArgs e)
|
protected override void OnMouseWheel(MouseEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnMouseWheel(e);
|
base.OnMouseWheel(e);
|
||||||
if (Bar.Visible)
|
if (VBar.Visible)
|
||||||
{
|
{
|
||||||
if (e.Delta > 10)
|
if (e.Delta > 10)
|
||||||
{
|
{
|
||||||
Bar.SetValue(Bar.Value - Bar.Maximum / 20);
|
VBar.SetValue(VBar.Value - VBar.Maximum / 20);
|
||||||
}
|
}
|
||||||
else if (e.Delta < -10)
|
else if (e.Delta < -10)
|
||||||
{
|
{
|
||||||
Bar.SetValue(Bar.Value + Bar.Maximum / 20);
|
VBar.SetValue(VBar.Value + VBar.Maximum / 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,11 +187,11 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
private void SetBarPosition()
|
private void SetBarPosition()
|
||||||
{
|
{
|
||||||
Bar.Left = Width - ScrollBarInfo.VerticalScrollBarWidth() - 2;
|
VBar.Left = Width - ScrollBarInfo.VerticalScrollBarWidth() - 2;
|
||||||
Bar.Top = 0;
|
VBar.Top = 1;
|
||||||
Bar.Width = ScrollBarInfo.VerticalScrollBarWidth() + 1;
|
VBar.Width = ScrollBarInfo.VerticalScrollBarWidth() + 1;
|
||||||
Bar.Height = Height;
|
VBar.Height = Height - 2;
|
||||||
Bar.BringToFront();
|
VBar.BringToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnColumnAdded(DataGridViewColumnEventArgs e)
|
protected override void OnColumnAdded(DataGridViewColumnEventArgs e)
|
||||||
@ -243,8 +263,8 @@ namespace Sunny.UI
|
|||||||
StripeEvenColor = uiColor.GridStripeEvenColor;
|
StripeEvenColor = uiColor.GridStripeEvenColor;
|
||||||
StripeOddColor = uiColor.GridStripeOddColor;
|
StripeOddColor = uiColor.GridStripeOddColor;
|
||||||
|
|
||||||
Bar.FillColor = uiColor.GridStripeOddColor;
|
VBar.FillColor = uiColor.GridStripeOddColor;
|
||||||
Bar.ForeColor = uiColor.PrimaryColor;
|
VBar.ForeColor = uiColor.PrimaryColor;
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
@ -256,25 +276,6 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public string TagString { get; set; }
|
public string TagString { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 重新设置边框
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="m">当前的Windows消息</param>
|
|
||||||
protected override void WndProc(ref Message m)
|
|
||||||
{
|
|
||||||
base.WndProc(ref m);
|
|
||||||
if (IsDisposed || Disposing) return;
|
|
||||||
if (ShowRect)
|
|
||||||
{
|
|
||||||
if (m.Msg == 0xf || m.Msg == 0x133)
|
|
||||||
{
|
|
||||||
Color color = RectColor;
|
|
||||||
color = Enabled ? color : UIDisableColor.Fill;
|
|
||||||
ControlEx.ResetBorderColor(m, this, 1, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否显示边框
|
/// 是否显示边框
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user