C#如何模拟Ruzzle手势

本文关键字:Ruzzle 手势 模拟 何模拟 | 更新日期: 2023-09-27 18:29:06

我正在尝试用C#为windows重新创建流行的智能手机游戏"Ruzzle"。我一直在试图弄清楚什么c#事件可以模拟鲁兹手势
如果你不熟悉这个游戏,这里有一个短视频。1分13秒跳http://www.youtube.com/watch?v=9uUk3_4vduo

我创建了一个"Check"类,如下所示:

public partial class Check: UserControl
    {
        public Check()
        {
            InitializeComponent();
        }
        string _letter; //letter contained  in the check
        public string Letter
        {
            get { return _letter; }
            set { _letter = value; }
        }
        int _value; //value of the letter
        public int Value
        {
            get { return _value; }
            set { _value= value; }
        }
        bool _selected; //if true orange background else white background
        public bool Selected
        {
            get { return _selected; }
            set { _selected= value; }
        }
        public Check(string l)
        {
            this._letter = l.ToUpper();
            this._selected = false;
            this.Size = new Size(100, 100);
            this.Paint += new PaintEventHandler(Check_Paint);
        }
        void Check_Paint(object sender, PaintEventArgs e)
        {
            Rectangle area = new Rectangle(new Point(0, 0), new Size(Height-3, Width-3));
            if (!Selezionato)
            {
                e.Graphics.DrawRectangle(Pens.Black, new Rectangle(new Point(0, 0), new Size(Height, Width)));
                e.Graphics.FillRectangle(Brushes.White, area);
                e.Graphics.DrawString(this._letter, DefaultFont, Brushes.Black, new PointF(Height / 3, Width /3));
                e.Graphics.DrawString(this._value.ToString(), DefaultFont, Brushes.Black, new PointF(Height-15, Width-15));
            }
            else
            {
                e.Graphics.DrawRectangle(Pens.Black, area);
                e.Graphics.FillRectangle(Brushes.Orange, area);
                e.Graphics.DrawString(this._letter, DefaultFont, Brushes.Black, new PointF(Height / 3, Width ));
                e.Graphics.DrawString(this._value.ToString(), DefaultFont, Brushes.Black, new PointF(Height, Width));
            }
        }

我有一个类"游戏",管理"检查"的二维数组

class Game
    {
        Scacco[,] myGame;
        public Game(Control father)
        {
            myGame= new Check[4, 4];
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    myGame[i, j] = new Check("l");
                    myGame[i, j].Location = new Point((i * (myGame[i, j].Width) + 10), (j * (myGame[i, j].Height )+ 10));
                    father.Controls.Add(myGame[i, j]);
                }
            }
        }
    }

这里我需要弄清楚是否存在类似"which mouse is down"的事件。我知道mousedown事件存在,但它只适用于一个检查:当我将鼠标悬停在另一个检查上时,该事件无法识别我的鼠标仍然向下

请告诉我我的解释是否清楚。提前谢谢!

C#如何模拟Ruzzle手势

MouseMove事件将在鼠标放下时生成,但仅限于最初捕获鼠标的Win32窗口。如果不使用捕获,消息将转到鼠标下的窗口。

当然,要区分"按下鼠标移动"answers"释放所有鼠标按钮移动",您可以在MouseDown事件中设置标志。