Eabei.GoBangGame/Eabei.Controls/TitleBarControl.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Eabei.Controls
{
    public class TitleBarControl : Panel
    {
        public TitleBarControl()
        {
            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);

            //this.BackColor = Color.FromArgb(0xff, 0xcc, 0x85, 0x2a);
            this.BackColor = Color.Transparent;
            this.Dock = DockStyle.Top;
            this.Font = new Font("华文云彩", 9);
        }

        private byte _alpha = 0x40;
        [DefaultValue(0x40), Description("背景色的透明通道")]
        public byte Alpha { get => _alpha; set { _alpha = value; this.Invalidate(false); } }

        private Size _closeSize = new Size(16, 16);
        [DefaultValue(typeof(Size), "16, 16"), Description("关闭按钮的大小")]
        public Size CloseSize { get => _closeSize; set { _closeSize = value; this.Invalidate(false); } }


        private string _title = "经典五子棋";
        [DefaultValue("经典五子棋"), Description("标题")]
        public string Title { get => _title; set { _title = value; this.Invalidate(false); } }

        public event EventHandler<EventArgs>? CloseEventHandler;



        private Rectangle closeRect;

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(_alpha, 0x4f, 0x58, 0x50)), new Rectangle(0, 0, this.Width - 1, this.Height - 1));

            int x, y;
            x = this.Width - 10 - _closeSize.Width;
            y = (this.Height - _closeSize.Height) / 2;
            closeRect = new Rectangle(new(x, y), _closeSize);
            e.Graphics.DrawImage(ResourceImage.close, closeRect);

            var size = e.Graphics.MeasureString(_title, this.Font);
            e.Graphics.DrawString(_title, this.Font, new SolidBrush(this.ForeColor), new PointF((this.Width - size.Width) / 2f, (this.Height - size.Height) / 2f));
        }

后面还有 17 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。