我有一个出现 always on the top
和 fullscreen
的应用程序> kiosk机器的应用程序。另外,我必须关闭explorer.exe
。
因此,没有键盘,我将无法访问任何内容。
我正在考虑制作手势或无敌按钮,以便我可以在没有键盘的情况下打开explorer.exe
。。
我想知道是否有一种方法可以同时检测两个按钮。我尝试使用以下代码,但它不起作用。
ps:我无法按线进行调试,因为我的PC没有触摸屏。 因此,我找不到哪一行引起问题。
private bool button1WasClicked = false;
private bool button2WasClicked = false;
private void button1_MouseDown(object sender, MouseEventArgs e)
{
button1WasClicked = true;
}
private void button1_MouseUp(object sender, MouseEventArgs e)
{
button1WasClicked = false;
}
private void button2_MouseUp(object sender, MouseEventArgs e)
{
button2WasClicked = false;
}
private void button2_MouseDown(object sender, MouseEventArgs e)
{
if (button1WasClicked == true)
{
Process.Start(Path.Combine(Environment.GetEnvironmentVariable("windir"), "explorer.exe"));
Application.Exit();
button1WasClicked = false;
}
}
您不能用鼠标或键盘立即单击两个按钮,如果您在谈论使用触摸屏,Winforms Framework不支持它们被解释为单个鼠标的点击)。您将需要查看使用Surface SDK或其他内容。
我找到了一个不同的解决方案,其中必须以某个序列单击按钮以实现我想要的东西。我还添加了一个计时器。以下是我的代码。
private bool panel1WasClicked = false;
private bool panel2WasClicked = false;
int second = 0;
private void panel1_Click(object sender, EventArgs e)
{
MaintenanceTimer.Interval = 500;
MaintenanceTimer.Start();
second = 0;
if (panel1WasClicked == false)
{
panel1WasClicked = true;
}
else
{
panel1WasClicked = false;
}
}
private void panel2_Click(object sender, EventArgs e)
{
if (panel2WasClicked == false && panel1WasClicked == true)
{
panel2WasClicked = true;
}
else
{
panel2WasClicked = false;
}
}
private void panel3_Click(object sender, EventArgs e)
{
if (panel1WasClicked && panel2WasClicked == true)
{
//Do something
}
panel1WasClicked = false;
panel2WasClicked = false;
MaintenanceTimer.Stop();
}
private void MaintenanceTimer_Tick(object sender, EventArgs e)
{
second += 1;
if (second >= 5)
{
MaintenanceTimer.Stop();
second = 0;
panel1WasClicked = false;
panel2WasClicked = false;
}
}