Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#如何模拟小雨手势_C#_Events - Fatal编程技术网

C#如何模拟小雨手势

C#如何模拟小雨手势,c#,events,C#,Events,我正在尝试用C#为windows重新创建流行的智能手机游戏“Ruzzle”。 我一直在试图弄清楚什么样的c#event可以模拟雨点手势。 如果你不熟悉这个游戏,这里有一个简短的视频。在1:13分跳伞 我创建了这样一个“Check”类: public partial class Check: UserControl { public Check() { InitializeComponent(); }

我正在尝试用C#为windows重新创建流行的智能手机游戏“Ruzzle”。 我一直在试图弄清楚什么样的c#event可以模拟雨点手势。
如果你不熟悉这个游戏,这里有一个简短的视频。在1:13分跳伞

我创建了这样一个“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));
            }
        }
然后我有一个类“游戏”来管理“检查”的二维数组

类游戏
{
Scacco[,]我的游戏;
公共游戏(控制之父)
{
myGame=新支票[4,4];
对于(int i=0;i<4;i++)
{
对于(int j=0;j<4;j++)
{
myGame[i,j]=新支票(“l”);
myGame[i,j]。位置=新点((i*(myGame[i,j]。宽度)+10),(j*(myGame[i,j]。高度)+10);
父.Controls.Add(myGame[i,j]);
}
}
}
}
这里我需要弄清楚是否有类似“鼠标按下”这样的事件。我知道mousedown事件存在,但它只在一个检查上起作用:当我将鼠标悬停在另一个检查上时,事件无法识别我的鼠标仍在向下移动。

让我知道我的解释是否清楚。
提前谢谢你

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


当然,要区分“鼠标按钮按下时的移动”和“鼠标按钮释放时的移动”,您可以在
MouseDown
事件中设置一个标志。

使用鼠标位置轮询可以跟踪用户访问的方块上的路径。也许这样行。
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]);
                }
            }
        }
    }