我正在尝试使用 C# 为 Windows 重新创建流行的智能手机游戏“Ruzzle”。我一直试图弄清楚什么 c# 事件可以模拟 ruzzle 手势。
如果您不熟悉游戏,这里有一个简短的视频。在 1:13 分跳
http://www.youtube.com/watch?v=9uUk3_4vduo
我创建了一个像这样的“检查”类:
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]);
}
}
}
}
在这里我需要弄清楚是否有类似“当鼠标按下时”的事件。我知道 mousedown 事件存在,但它只适用于一个检查:只要我将鼠标悬停在另一个检查上,事件就无法识别我的鼠标仍然处于关闭状态。
让我知道我的解释是否清楚。先感谢您!