Eabei.GoBangGame/Eabei.Controls/ChessControl.cs
(完整代码) 1KBusing Eabei.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Eabei.Controls
{
public class ChessControl : Control
{
public ChessControl()
{
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.UserPaint, true);
}
private Model.ChessCardCamp _camp = ChessCardCamp.None;
[DefaultValue(typeof(ChessCardCamp), "None"), Description("表示是黑棋还是白棋")]
public ChessCardCamp Camp { get => _camp; set { _camp = value; this.Invalidate(false); } }
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//e.Graphics.DrawRectangle(new Pen(Color.FromArgb(0x64, 0x64, 0x64)), new Rectangle(0, 0, this.Width - 1, this.Height - 1));
Image image = _camp switch
{
ChessCardCamp.WhiteCamp => ResourceImage.WhiteCamp,
ChessCardCamp.BlackCamp => ResourceImage.BlackCamp,
_ => ResourceImage.NoneCamp
};
e.Graphics.DrawImage(image, new RectangleF(0, 0, this.Width - 1, this.Height - 1));
base.OnPaint(e);
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。