触摸屏监视器windows窗体应用程序c#
我有一个应用程序,它向来到我的商店的用户显示网站上的信息。它工作完美,但现在我有触摸屏显示器,所以我想启用它。我可以更改此代码吗,否则我将不得不从头开始构建另一个应用程序 这是我的密码:触摸屏监视器windows窗体应用程序c#,c#,winforms,touch,screen,monitor,C#,Winforms,Touch,Screen,Monitor,我有一个应用程序,它向来到我的商店的用户显示网站上的信息。它工作完美,但现在我有触摸屏显示器,所以我想启用它。我可以更改此代码吗,否则我将不得不从头开始构建另一个应用程序 这是我的密码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Security.Permissions;
using System.Windows.Forms;
namespace WebsiteWrapper
{
public partial class Form1 : Form
{
public static Timer IdleTimer = new Timer();
const int Tempo = 90000; // 1min - represents the configured time to see if the application is in idle
public Form1()
{
Application.Idle += new EventHandler(Application_Idle);
IdleTimer.Interval = Tempo;
IdleTimer.Tick += TimesUp;
IdleTimer.Start();
InitializeComponent();
Application.Idle -= new EventHandler(Application_Idle);
}
//avoid the page to open external links
private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
{
e.Cancel = true;
}
public void Application_Idle(object sender, EventArgs e)
{
if (IdleTimer.Enabled)
{
IdleTimer.Start();
}
}
//reload de webBrowser when it reachs 1min of inactivity
public void TimesUp(object sender, EventArgs e)
{
this.webBrowser1.Navigate("http://www.myWebsite.co.mz/index.php/pt/novo");
}
}
//events messages
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public class LeaveIdleMessageFilter : IMessageFilter
{
const int WM_NCLBUTTONDOWN = 0x00A1;
const int WM_NCLBUTTONUP = 0x00A2;
const int WM_NCRBUTTONDOWN = 0x00A4;
const int WM_NCRBUTTONUP = 0x00A5;
const int WM_NCMBUTTONDOWN = 0x00A7;
const int WM_NCMBUTTONUP = 0x00A8;
const int WM_NCXBUTTONDOWN = 0x00AB;
const int WM_NCXBUTTONUP = 0x00AC;
const int WM_KEYDOWN = 0x0100;
const int WM_KEYUP = 0x0101;
const int WM_MOUSEMOVE = 0x0200;
const int WM_LBUTTONDOWN = 0x0201;
const int WM_LBUTTONUP = 0x0202;
const int WM_RBUTTONDOWN = 0x0204;
const int WM_RBUTTONUP = 0x0205;
const int WM_MBUTTONDOWN = 0x0207;
const int WM_MBUTTONUP = 0x0208;
const int WM_XBUTTONDOWN = 0x020B;
const int WM_XBUTTONUP = 0x020C;
// The Messages array must be sorted due to use of Array.BinarySearch
static int[] Messages = new int[] {WM_NCLBUTTONDOWN,
WM_NCLBUTTONUP, WM_NCRBUTTONDOWN, WM_NCRBUTTONUP, WM_NCMBUTTONDOWN,
WM_NCMBUTTONUP, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP, WM_KEYDOWN, WM_KEYUP,
WM_LBUTTONDOWN, WM_LBUTTONUP, WM_RBUTTONDOWN, WM_RBUTTONUP,
WM_MBUTTONDOWN, WM_MBUTTONUP, WM_XBUTTONDOWN, WM_XBUTTONUP};
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == WM_MOUSEMOVE) // mouse move is high volume
return false;
if (!Program.IdleTimer.Enabled) // idling?
return false; // No
if (Array.BinarySearch(Messages, m.Msg) >= 0)
Program.IdleTimer.Stop();
return false;
}
}
}
我会感谢你们的帮助 您是否尝试在带有触摸屏显示器的计算机上运行此应用程序?你有没有遇到过任何问题?如果你的触摸屏被设置成模仿鼠标,我不明白为什么有什么需要改变……我试过了。它不起作用-/我希望网站上的链接可以通过这种方式点击