📄 chanelpanel.cs
字号:
namespace Imps.Client.Pc
{
using System;
using System.Windows.Forms;
public class ChanelPanel : ElementPanel
{
private int _count_to_display;
private int _head;
private ElementControls _items = new ElementControls();
public ElementButton _scrolldown;
public ElementButton _scrollup;
public ChanelPanel()
{
base.HandleMouse = false;
}
private void ChangeItemsVisible()
{
for (int i = 0; i < this._items.Count; i++)
{
if ((i >= this._head) && (i < (this._head + this._count_to_display)))
{
this._items[i].Visible = this.Visible;
}
else
{
this._items[i].Visible = false;
}
}
}
private void ChangeItmesLocation()
{
for (int i = 0; i < this._items.Count; i++)
{
if (i == this._head)
{
this._items[i]._location.X = base.InnerX;
this._items[i]._location.Y = base.InnerY + 1;
}
else if ((i > this._head) && (i < (this._head + this._count_to_display)))
{
this._items[i]._location.X = base.InnerX;
this._items[i]._location.Y = (this._items[i - 1]._location.Y + this._items[i - 1]._size.Height) + 1;
}
}
}
private void ChangeScrollState()
{
if ((this._head + this._count_to_display) < this._items.Count)
{
this._scrolldown.State = ElementButton.ButtonState.STATE_NORMAL;
}
else
{
this._scrolldown.State = ElementButton.ButtonState.STATE_DISABLE;
}
if (this._head > 0)
{
this._scrollup.State = ElementButton.ButtonState.STATE_NORMAL;
}
else
{
this._scrollup.State = ElementButton.ButtonState.STATE_DISABLE;
}
}
public override void OnPaint(PaintEventArgs e)
{
if (this.Visible)
{
base.OnPaint(e);
foreach (Element element in this._items)
{
element.OnPaint(e);
}
this._scrollup.OnPaint(e);
this._scrolldown.OnPaint(e);
}
}
public override void OnSizeChanged(int w, int h)
{
base.OnSizeChanged(w, h);
if ((this._items.Count != 0) && ((this._scrollup.Style._normal_image != null) && (this._scrolldown.Style._normal_image != null)))
{
if (this._items[0]._size.Height == 0)
{
this._items[0]._size.Height = 1;
}
this._count_to_display = (base.InnerHeight / this._items[0]._size.Height) - 1;
if (this._count_to_display < 0)
{
this._count_to_display = 0;
}
if ((this._head + this._count_to_display) >= this._items.Count)
{
this._head = this._items.Count - this._count_to_display;
}
if (this._head < 0)
{
this._head = 0;
}
this.ChangeItmesLocation();
this.ChangeItemsVisible();
this._scrolldown._location.X = this._location.X + ((this._size.Width - this._scrolldown.Style._normal_image.Width) / 2);
this._scrolldown._location.Y = ((base.InnerY + base.InnerHeight) - this._scrolldown.Style._normal_image.Height) - 5;
this._scrolldown._size.Width = this._scrolldown.Style._normal_image.Width;
this._scrolldown._size.Height = this._scrolldown.Style._normal_image.Height;
this._scrollup._location.X = this._scrolldown._location.X;
this._scrollup._location.Y = (this._scrolldown._location.Y - this._scrollup.Style._normal_image.Height) - 5;
this._scrollup._size.Width = this._scrollup.Style._normal_image.Width;
this._scrollup._size.Height = this._scrollup.Style._normal_image.Height;
if (this._count_to_display < this._items.Count)
{
this._scrollup.Visible = true;
this._scrolldown.Visible = true;
}
else
{
this._scrollup.Visible = false;
this._scrolldown.Visible = false;
}
this.ChangeScrollState();
}
}
public void ScrollDown(object sender, EventArgs e)
{
if ((this._head + this._count_to_display) < this._items.Count)
{
this._head++;
}
this.ChangeItmesLocation();
this.ChangeItemsVisible();
this.ChangeScrollState();
base.RaiseInvalidate(false);
}
public void ScrollUp(object sender, EventArgs e)
{
if (this._head > 0)
{
this._head--;
}
this.ChangeItmesLocation();
this.ChangeItemsVisible();
this.ChangeScrollState();
base.RaiseInvalidate(false);
}
public ElementControls Items
{
get
{
return this._items;
}
}
public bool Visible
{
get
{
return base.Visible;
}
set
{
base.Visible = value;
foreach (Element element in this._items)
{
element.Visible = value;
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -