UITransfer:增加左右列表项个数变化事件

This commit is contained in:
Sunny 2020-08-14 20:43:28 +08:00
parent 1002b92cb0
commit 9c469275a3
8 changed files with 52 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -37,6 +37,7 @@
//
this.PagePanel.Controls.Add(this.uiLine1);
this.PagePanel.Controls.Add(this.uiTransfer1);
this.PagePanel.Size = new System.Drawing.Size(800, 480);
//
// uiTransfer1
//
@ -68,6 +69,8 @@
this.uiTransfer1.Size = new System.Drawing.Size(427, 370);
this.uiTransfer1.TabIndex = 3;
this.uiTransfer1.Text = "uiTransfer1";
this.uiTransfer1.ItemsLeftCountChange += new System.EventHandler(this.uiTransfer1_ItemsLeftCountChange);
this.uiTransfer1.ItemsRightCountChange += new System.EventHandler(this.uiTransfer1_ItemsRightCountChange);
//
// uiLine1
//
@ -84,7 +87,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.ClientSize = new System.Drawing.Size(800, 515);
this.Name = "FTransfer";
this.Symbol = 61516;
this.Text = "Transfer";

View File

@ -1,4 +1,6 @@
namespace Sunny.UI.Demo
using System;
namespace Sunny.UI.Demo
{
public partial class FTransfer : UITitlePage
{
@ -6,5 +8,15 @@
{
InitializeComponent();
}
private void uiTransfer1_ItemsLeftCountChange(object sender, System.EventArgs e)
{
Console.WriteLine("Left: " + uiTransfer1.ItemsLeft.Count);
}
private void uiTransfer1_ItemsRightCountChange(object sender, System.EventArgs e)
{
Console.WriteLine("Right: " + uiTransfer1.ItemsRight.Count);
}
}
}

View File

@ -37,6 +37,7 @@ namespace Sunny.UI
{
private readonly ListBoxEx listbox = new ListBoxEx();
private readonly UIScrollBar bar = new UIScrollBar();
private readonly Timer timer = new Timer();
public UIListBox()
{
@ -61,6 +62,25 @@ namespace Sunny.UI
listbox.Click += Listbox_Click;
listbox.DoubleClick += Listbox_DoubleClick;
listbox.BeforeDrawItem += Listbox_BeforeDrawItem;
timer.Tick += Timer_Tick;
timer.Start();
}
~UIListBox()
{
timer.Stop();
}
private void Timer_Tick(object sender, EventArgs e)
{
if (Items.Count == 0 && LastCount != 0)
{
LastCount = 0;
timer.Stop();
ItemsCountChange?.Invoke(sender, e);
timer.Start();
}
}
protected override void OnFontChanged(EventArgs e)

View File

@ -39,8 +39,23 @@ namespace Sunny.UI
{
InitializeComponent();
ShowText = false;
l1.ItemsCountChange += L1_ItemsCountChange;
l2.ItemsCountChange += L2_ItemsCountChange;
}
private void L2_ItemsCountChange(object sender, EventArgs e)
{
ItemsRightCountChange?.Invoke(sender, e);
}
private void L1_ItemsCountChange(object sender, EventArgs e)
{
ItemsLeftCountChange?.Invoke(sender, e);
}
public event EventHandler ItemsLeftCountChange;
public event EventHandler ItemsRightCountChange;
/// <summary>
/// 左侧列表
/// </summary>