📄 wndlessscorepicturebox.cs
字号:
namespace Imps.Client.Pc.WndlessControls
{
using Imps.Client;
using System;
using System.Drawing;
using System.Windows.Forms;
public class WndlessScorePictureBox : WndlessControl
{
private Image _copper;
private Image _gold;
private int _scoreLevel;
private Image _silver;
private Size _size = new Size(0x65, 0x10);
public WndlessScorePictureBox()
{
base.ToolTipText = "请点击查看具体等级说明";
}
private int getCopperCount(int scoreLevel)
{
return ((scoreLevel % 9) % 3);
}
private int getGoldCount(int scoreLevel)
{
return (scoreLevel / 9);
}
private int getSliverCount(int scoreLevel)
{
return ((scoreLevel % 9) / 3);
}
protected override void OnPaint(PaintEventArgs e)
{
if (this.ValidateScoreLevel(this.ScoreLevel))
{
Image goldenImage = this.GoldenImage;
Image image = this.CopperImage;
Image silverImage = this.SilverImage;
if (((goldenImage != null) && (image != null)) && (silverImage != null))
{
base.BorderStyle = BorderStyle.None;
if (this.ScoreLevel == 0)
{
TextRenderer.DrawText((IDeviceContext) e.Graphics, "暂无等级", base.Font, base.Bounds, base.OwnerControl.ForeColor, Color.Transparent, 4);
}
else
{
int num = this.getGoldCount(this.ScoreLevel);
int num2 = this.getSliverCount(this.ScoreLevel);
int num3 = this.getCopperCount(this.ScoreLevel);
float x = this.ClientRectangle.X;
float y = this.ClientRectangle.Y;
for (int i = 0; i < num; i++)
{
e.Graphics.DrawImage(goldenImage, x, y);
x += goldenImage.Width + 1;
}
for (int j = 0; j < num2; j++)
{
e.Graphics.DrawImage(silverImage, x, y);
x += silverImage.Width + 1;
}
for (int k = 0; k < num3; k++)
{
e.Graphics.DrawImage(image, x, y);
x += image.Width + 1;
}
}
}
}
}
public void PaintDirectly(Graphics g, Rectangle bounds)
{
PaintEventArgs e = new PaintEventArgs(g, bounds);
this.OnPaint(e);
}
private bool ValidateScoreLevel(int scoreLevel)
{
if (scoreLevel >= 0)
{
return (scoreLevel <= 0x1b);
}
return false;
}
public Image CopperImage
{
get
{
if (this._copper == null)
{
try
{
this._copper = ImpsResources.GetImage("Images.BronzeMedal.png");
}
catch
{
}
}
return this._copper;
}
set
{
this._copper = value;
}
}
public Image GoldenImage
{
get
{
if (this._gold == null)
{
try
{
this._gold = ImpsResources.GetImage("Images.GoldenMedal.png");
}
catch
{
}
}
return this._gold;
}
set
{
this._gold = value;
}
}
public override Size PreferredClientSize
{
get
{
return this._size;
}
}
public int ScoreLevel
{
get
{
return this._scoreLevel;
}
set
{
if (!this.ValidateScoreLevel(value))
{
throw new OverflowException("积分超过系统限制");
}
if (this._scoreLevel != value)
{
this._scoreLevel = value;
base.DoAutoSize(true);
Rectangle rc = new Rectangle(base.Bounds.X, base.Bounds.Y, 0x66, 0x10);
base.Invalidate(rc);
}
}
}
public Image SilverImage
{
get
{
if (this._silver == null)
{
try
{
this._silver = ImpsResources.GetImage("Images.SilverMedal.png");
}
catch
{
}
}
return this._silver;
}
set
{
this._silver = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -