⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 character.cs

📁 一个由.NET WindowsForm上开发的华容道游戏
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace HuaRongDao
{
    public class Character:Control          
    {
        private string _logicName = "CC";
        private Size _logicSize = new Size(2,2);
        private Point _logicLocation = Point.Empty;
        private bool _isCC = true;
        private Rectangle _logicBounds = Rectangle.Empty;
        private bool _isFocused = false;

        public Character()
        {
        }
        
        public Character(string logicName, Size logicSize)
        {
            _logicName = logicName;
            _logicSize = logicSize;
            _isCC = false;
        }

        public Character(string logicName, Size logicSize, Point logicLocation)
        {
            _logicName = logicName;
            _logicSize = logicSize;
            LogicLocation = logicLocation;
            _isCC = false;
        }

        public Character(string logicName, Size logicSize, Point logicLocation, bool isCC)
        {
            _logicName = logicName;
            _logicSize = logicSize;
            LogicLocation = logicLocation;
            _isCC = isCC;
        }

        public string LogicName
        {
            get { return _logicName; }
        }

        public Size LogicSize
        {
            get { return _logicSize; }
        }

        public Point LogicLocation
        {
            get { return _logicLocation; }
            set
            {
                _logicLocation = value;
                _logicBounds = new Rectangle(value, this.LogicSize);
                OnLogicLocationChanged(new EventArgs());
            }
        }

        public bool IsFocused
        {
            get { return _isFocused; }
            set 
            {
                _isFocused = value;
                this.Refresh();
            }
        }

        public event EventHandler LogicLocationChanged = null;

        protected virtual void OnLogicLocationChanged(EventArgs e)
        {
            if (this.LogicLocationChanged != null)
            {
                this.LogicLocationChanged(this, e);
            }
        }

        public bool IsCC
        {
            get { return true; }
        }

        public Rectangle LogicBounds
        {
            get { return _logicBounds; }
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle rect = new Rectangle(new Point(0,0), this.Size);
            if (this.IsFocused)
            {
                e.Graphics.FillRectangle(Brushes.Aquamarine, rect);
            }
            e.Graphics.DrawString(this.LogicName, SystemFonts.DefaultFont, Brushes.Black, rect);
            rect.Width --;
            rect.Height--;
            e.Graphics.DrawRectangle(Pens.Black, rect);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -