📄 elementpanel.cs
字号:
namespace Imps.Client.Pc
{
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
public class ElementPanel : Element
{
private string _current = "default";
public ElementPanel()
{
base._style = new ElementPanelStyle();
}
private void DrawBackground(Graphics g)
{
if (this.Style._backgroundTL != null)
{
g.DrawImage(this.Style._backgroundTL, this._location.X, this._location.Y, this.Style._backgroundTL.Width, this.Style._backgroundTL.Height);
}
if (this.Style._backgroundTR != null)
{
g.DrawImage(this.Style._backgroundTR, (this._location.X + this._size.Width) - this.Style._backgroundTR.Width, this._location.Y, this.Style._backgroundTR.Width, this.Style._backgroundTR.Height);
}
if (this.Style._backgroundT != null)
{
this.DrawBackgroundTop(g);
}
if (this.Style._backgroundL != null)
{
this.DrawBackgroundLeft(g);
}
if (this.Style._backgroundR != null)
{
this.DrawBackgroundRight(g);
}
if (this.Style._backgroundC != null)
{
this.DrawBackgroundCenter(g);
}
if (this.Style._backgroundBL != null)
{
g.DrawImage(this.Style._backgroundBL, this._location.X, (this._location.Y + this._size.Height) - this.Style._backgroundBL.Height, this.Style._backgroundBL.Width, this.Style._backgroundBL.Height);
}
if (this.Style._backgroundBR != null)
{
g.DrawImage(this.Style._backgroundBR, (this._location.X + this._size.Width) - this.Style._backgroundBR.Width, (this._location.Y + this._size.Height) - this.Style._backgroundBR.Height, this.Style._backgroundBR.Width, this.Style._backgroundBR.Height);
}
if (this.Style._backgroundB != null)
{
this.DrawBackgroundBottom(g);
}
}
private void DrawBackgroundBottom(Graphics g)
{
int num = (this.Style._backgroundBL != null) ? this.Style._backgroundBL.Width : 0;
int num2 = (this.Style._backgroundBR != null) ? this.Style._backgroundBR.Width : 0;
int w = (this._size.Width - num) - num2;
int h = this.Style._backgroundB.Height;
int num5 = num;
int num6 = this._size.Height - this.Style._backgroundB.Height;
this.DrawStretchBitmap(g, this.Style._backgroundB, this._location.X + num5, this._location.Y + num6, w, h);
}
private void DrawBackgroundCenter(Graphics g)
{
int num = (this.Style._backgroundL != null) ? this.Style._backgroundL.Width : 0;
int num2 = (this.Style._backgroundR != null) ? this.Style._backgroundR.Width : 0;
int num3 = (this.Style._backgroundT != null) ? this.Style._backgroundT.Height : 0;
int num4 = (this.Style._backgroundB != null) ? this.Style._backgroundB.Height : 0;
int w = (this._size.Width - num) - num2;
int h = (this._size.Height - num3) - num4;
int num7 = num;
int num8 = num3;
this.DrawStretchBitmap(g, this.Style._backgroundC, this._location.X + num7, this._location.Y + num8, w, h);
}
private void DrawBackgroundLeft(Graphics g)
{
int num = (this.Style._backgroundTL != null) ? this.Style._backgroundTL.Height : 0;
int num2 = (this.Style._backgroundBL != null) ? this.Style._backgroundBL.Height : 0;
int w = this.Style._backgroundL.Width;
int h = (this._size.Height - num) - num2;
int num5 = 0;
int num6 = num;
this.DrawStretchBitmap(g, this.Style._backgroundL, this._location.X + num5, this._location.Y + num6, w, h);
}
private void DrawBackgroundRight(Graphics g)
{
int num = (this.Style._backgroundTR != null) ? this.Style._backgroundTR.Height : 0;
int num2 = (this.Style._backgroundBR != null) ? this.Style._backgroundBR.Height : 0;
int w = this.Style._backgroundR.Width;
int h = (this._size.Height - num) - num2;
int num5 = this._size.Width - this.Style._backgroundR.Width;
int num6 = num;
this.DrawStretchBitmap(g, this.Style._backgroundR, this._location.X + num5, this._location.Y + num6, w, h);
}
private void DrawBackgroundTop(Graphics g)
{
int num = (this.Style._backgroundTL != null) ? this.Style._backgroundTL.Width : 0;
int num2 = (this.Style._backgroundTR != null) ? this.Style._backgroundTR.Width : 0;
int w = (this._size.Width - num) - num2;
int h = this.Style._backgroundT.Height;
int num5 = num;
int num6 = 0;
this.DrawStretchBitmap(g, this.Style._backgroundT, this._location.X + num5, this._location.Y + num6, w, h);
}
private void DrawStretchBitmap(Graphics g, Bitmap bmp, int x, int y, int w, int h)
{
if ((bmp != null) && ((w > 0) && (h > 0)))
{
Brush brush = new TextureBrush(bmp, WrapMode.Tile, new Rectangle(0, 0, bmp.Width, bmp.Height));
Bitmap image = new Bitmap(w, h);
Graphics.FromImage(image).FillRectangle(brush, 0, 0, w, h);
g.DrawImage(image, x, y);
}
}
public override void OnPaint(PaintEventArgs e)
{
this.DrawBackground(e.Graphics);
}
public void OnPositionChanged(object sender, PositionEventArgs e)
{
EForm form = sender as EForm;
try
{
if (this.Style.Positions.ContainsKey(e.EventName))
{
this.Style.Positions.get_Item(e.EventName);
this._current = e.EventName;
}
else
{
this._current = "default";
}
}
catch
{
this._current = "default";
}
this.OnSizeChanged(form.Width, form.Height);
}
public override void OnSizeChanged(int w, int h)
{
Rectangle rectangle = EStyleBase.StyleRectToWindowRect(this.CurrentRect, this.Style._xAlignment, this.Style._yAlignment, this.Style._horAlignment, this.Style._verAlignment, new Size(w, h));
base._location = rectangle.Location;
base._size = rectangle.Size;
}
public Rectangle CurrentRect
{
get
{
if (this._current == "default")
{
return new Rectangle(this.Style._location, this.Style._size);
}
try
{
return this.Style.Positions.get_Item(this._current);
}
catch
{
this._current = "default";
return this.CurrentRect;
}
}
}
public int InnerHeight
{
get
{
return ((this._size.Height - this.Style._paddingTop) - this.Style._paddingBottom);
}
}
public int InnerWidth
{
get
{
return ((this._size.Width - this.Style._paddingLeft) - this.Style._paddingRight);
}
}
public int InnerX
{
get
{
return (this._location.X + this.Style._paddingLeft);
}
}
public int InnerY
{
get
{
return (this._location.Y + this.Style._paddingTop);
}
}
public ElementPanelStyle Style
{
get
{
return (ElementPanelStyle) base._style;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -