!21 控件修改

Merge pull request !21 from 淘气小浩/master
This commit is contained in:
Sunny 2020-08-25 13:26:20 +08:00 committed by Gitee
commit d4027d9d02
7 changed files with 80 additions and 20 deletions

View File

@ -80,7 +80,6 @@
this.uiDataGridView1.Location = new System.Drawing.Point(0, 0);
this.uiDataGridView1.MultiSelect = false;
this.uiDataGridView1.Name = "uiDataGridView1";
this.uiDataGridView1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.uiDataGridView1.RowHeadersVisible = false;
dataGridViewCellStyle4.BackColor = System.Drawing.Color.White;
this.uiDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle4;
@ -90,11 +89,10 @@
this.uiDataGridView1.ShowRect = false;
this.uiDataGridView1.Size = new System.Drawing.Size(861, 380);
this.uiDataGridView1.TabIndex = 0;
this.uiDataGridView1.TagString = null;
//
// uiPagination1
//
this.uiPagination1.ActivePage = 500;
this.uiPagination1.ActivePage = 50;
this.uiPagination1.CausesValidation = false;
this.uiPagination1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.uiPagination1.Font = new System.Drawing.Font("微软雅黑", 12F);
@ -102,6 +100,7 @@
this.uiPagination1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiPagination1.Name = "uiPagination1";
this.uiPagination1.PagerCount = 11;
this.uiPagination1.PageSize = 50;
this.uiPagination1.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
this.uiPagination1.Size = new System.Drawing.Size(861, 35);
this.uiPagination1.TabIndex = 1;

View File

@ -119,6 +119,7 @@
this.uiButton1.TabIndex = 23;
this.uiButton1.Text = "Add Item";
this.uiButton1.Click += new System.EventHandler(this.uiButton1_Click);
this.uiButton1.DoubleClick += new System.EventHandler(this.uiButton1_DoubleClick);
//
// FListBox
//

View File

@ -13,7 +13,7 @@ namespace Sunny.UI.Demo
public override void Init()
{
uiListBox1.Items.Clear();
for (int i = 0; i < 20; i++)
for (int i = 0; i < 50; i++)
{
uiListBox1.Items.Add(i);
}
@ -49,5 +49,11 @@ namespace Sunny.UI.Demo
uiListBox1.Items.Add(DateTime.Now.ToString("yyyyMMdd") + "_" + num);
num++;
}
private void uiButton1_DoubleClick(object sender, EventArgs e)
{
uiListBox1.Items.Add(DateTime.Now.ToString("yyyyMMdd") + "_double_" + num);
num++;
}
}
}

View File

@ -55,6 +55,7 @@ namespace Sunny.UI
fillHoverColor = UIStyles.Blue.ButtonFillHoverColor;
fillPressColor = UIStyles.Blue.ButtonFillPressColor;
fillSelectedColor = UIStyles.Blue.ButtonFillSelectedColor;
SetStyle(ControlStyles.StandardDoubleClick, UseDoubleClick);
}
private bool isClick;
@ -76,6 +77,27 @@ namespace Sunny.UI
base.OnClick(e);
}
private bool useDoubleClick = false;
[Description("是否启用双击事件"), Category("SunnyUI")]
[DefaultValue(false)]
public bool UseDoubleClick
{
get
{
return useDoubleClick;
}
set
{
if (useDoubleClick != value)
{
useDoubleClick = value;
SetStyle(ControlStyles.StandardDoubleClick, value);
Invalidate();
}
}
}
private bool showTips = false;
[Description("是否显示角标"), Category("SunnyUI")]
@ -382,12 +404,22 @@ namespace Sunny.UI
{
if (Focused && e.KeyCode == Keys.Space)
{
IsPress = true;
Invalidate();
PerformClick();
}
base.OnKeyDown(e);
}
protected override void OnKeyUp(KeyEventArgs e)
{
IsPress = false;
Invalidate();
base.OnKeyUp(e);
}
[DefaultValue(false)]
[Description("显示激活时边框线"), Category("SunnyUI")]
public bool ShowFocusLine { get; set; }

View File

@ -321,7 +321,14 @@ namespace Sunny.UI
protected override void OnSizeChanged(EventArgs e)
{
SetScrollInfo();
if (Bar != null && Bar.Visible)
{
if (Bar.Value != 0)
{
ScrollBarInfo.SetScrollValue(Handle, Bar.Value);
}
}
//SetScrollInfo();
}
public void SetScrollInfo()
@ -379,22 +386,19 @@ namespace Sunny.UI
{
base.OnMouseWheel(e);
if (Bar.Visible)
if (Bar != null && Bar.Visible)
{
var si = ScrollBarInfo.GetInfo(Handle);
int temp = Math.Abs(e.Delta / 120);
if (e.Delta > 10)
{
if (si.nPos > 0)
{
ScrollBarInfo.ScrollUp(Handle);
}
int nposnum = si.nPos - temp * SystemInformation.MouseWheelScrollLines;
ScrollBarInfo.SetScrollValue(Handle, nposnum >= si.nMin ? nposnum : 0);
}
else if (e.Delta < -10)
{
if (si.nPos < si.ScrollMax)
{
ScrollBarInfo.ScrollDown(Handle);
}
int nposnum = si.nPos + temp * SystemInformation.MouseWheelScrollLines;
ScrollBarInfo.SetScrollValue(Handle, nposnum <= si.nMax ? nposnum : si.nMax);
}
}

View File

@ -395,17 +395,19 @@ namespace Sunny.UI
if (Bar != null && Bar.Visible)
{
var si = ScrollBarInfo.GetInfo(Handle);
int temp = Math.Abs(e.Delta / 120);
if (e.Delta > 10)
{
ScrollBarInfo.SetScrollValue(Handle, (si.nPos - SystemInformation.MouseWheelScrollLines) >= si.nMin ? si.nPos - SystemInformation.MouseWheelScrollLines : 0);
int nposnum = si.nPos - temp * SystemInformation.MouseWheelScrollLines;
ScrollBarInfo.SetScrollValue(Handle, nposnum >= si.nMin ? nposnum : 0);
}
else if (e.Delta < -10)
{
ScrollBarInfo.SetScrollValue(Handle, (si.nPos + SystemInformation.MouseWheelScrollLines) <= si.nMax ? (si.nPos + SystemInformation.MouseWheelScrollLines) : si.nMax);
int nposnum = si.nPos + temp * SystemInformation.MouseWheelScrollLines;
ScrollBarInfo.SetScrollValue(Handle, nposnum <= si.ScrollMax ? nposnum : si.ScrollMax);
}
SetScrollInfo();
}
SetScrollInfo();
}
public void SetStyle(UIStyle style)

View File

@ -703,8 +703,24 @@ namespace Sunny.UI
edtPage.HasMaximum = true;
edtPage.Maximum = PageCount;
if (activePage > PageCount) activePage = PageCount;
if (activePage < 1) activePage = 1;
if (activePage >= PageCount)
{
activePage = PageCount;
b16.Enabled = false;
}
else
{
b16.Enabled = true;
}
if (activePage <= 1)
{
activePage = 1;
b0.Enabled = false;
}
else
{
b0.Enabled = true;
}
edtPage.IntValue = activePage;
if (TotalCount == 0)