Tag: mousedown

定时器,单击,mousedown,mouseup事件不能一起工作

寻找一些问题的帮助我有 对不起,如果这个问题已被提出,我找不到类似的东西。 这个想法是当点击图片框时将图像更改为ON。 如果图片框保持2秒以上以打开新表格并将图片框保留为OFF。 但是,如果点击图片框然后保持2秒然后返回我需要图片框状态保持为ON。 这是我到目前为止所尝试的。 我相信为了正常工作我需要阻止MouseUp事件发生。 有什么方法可以在Tick发生时停止MouseUp吗? 有没有更简单/更好的方法来做到这一点? 任何帮助,将不胜感激。 private void time_HoldDownInternal_Tick(object sender, EventArgs e) { time_HoldDownInternal.Enabled = false; time_HoldDownInternal.Interval = 1000; form1show.Visible = true; } private void pb_pictureBoxTest_MouseDown(object sender, MouseEventArgs e) { mainMenuVariables.mousedown = true; time_HoldDownInternal.Enabled = true; } private void pb_pictureBoxTest_MouseUp(object sender, MouseEventArgs e) { mainMenuVariables.mousedown = false; //MessageBox.Show(“mouse up”); time_HoldDownInternal.Enabled = […]

MouseDown和Click冲突

我在form_MouseDown事件上有一个Drag()方法。 我在表单上也有一个点击事件。 问题是,如果我单击表单,MouseDown事件将被触发,它永远不会有机会触发click事件。 解决这个问题的最佳方法是什么? 如果表单实际被拖动,我正在考虑计算像素,但必须有更好的方法。 有什么建议?

何时隧道和冒泡事件在WPF中有用?

我理解冒泡和隧道是如何工作的。 但是,我对使用它们很困惑。 原因如下: 我想处理鼠标点击事件。 要冒泡它,有MouseDown并且为了隧道它,有PreviewMouseDown 。 但是, MouseDown并不一定意味着用户单击了该控件。 可能是用户按下按钮并离开它以取消点击。 如果没有点击按钮,我不想改变任何东西。 所以我的问题是,Bubbling / Tunneling策略有用吗?

鼠标放在两块拼图之间

我正在winforms中构建一个益智游戏,我想识别任何一块上的mousedown,并用鼠标移动它。 问题在于,当我触摸拼图的透明部分时,我想validation那个拼图背后是否有任何一块,如果是,那么启动另一块的鼠标,得到它? 我也能够识别出mousedown是否在图像上,或者它是否发生在拼图的透明部分。 我的问题是获得将鼠标事件传递给后面的部分的最佳方法。 提前谢谢了。 更新1 以下是拼图的类: class Peça : DrawingArea { private Point _Offset = Point.Empty; public Image imagem { get; set; } protected override void OnDraw() { Rectangle location = new Rectangle(0, 0, imagem.Width, imagem.Height); this.graphics.DrawImage(imagem, location); } protected override void OnMouseMove(MouseEventArgs e) { if (_Offset != Point.Empty) { Point newlocation = this.Location; […]

WPF:Canvas吞咽MouseDownEvent?

任何人都可以向我解释为什么在这个简单的例子中MouseDown事件没有到达ScrollViewer ? 代码背后: using System; using System.Windows; using System.Windows.Input; namespace MouseDownTest { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); scrollViewer.AddHandler(MouseDownEvent, new RoutedEventHandler(ScrollViewer_Test)); } private void ScrollViewer_Test(object sender, RoutedEventArgs routedEventArgs) { Console.WriteLine(“ScrollViewer_Test”); } private void Canvas_MouseDown(object sender, MouseButtonEventArgs e) { Console.WriteLine(“Canvas_MouseDown”); } private void Canvas_PreviewMouseDown(object sender, MouseButtonEventArgs e) { Console.WriteLine(“Canvas_PreviewMouseDown”); } private […]

做出延迟的mousedown事件

我有一个datagridview,哪些单元格有一个click事件。 单元格还具有以下mouseDown事件: if (e.Button == MouseButtons.Left && e.Clicks == 1) { string[] filesToDrag = { “c:/install.log” }; gridOperations.DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Copy); } 每当我尝试单击一个单元格时,mousedown事件会立即触发并尝试拖动单元格。 如果用户将鼠标按下1秒钟,我怎样才能使mousedown事件触发? 谢谢!

如何在C#中使用鼠标绘制和移动形状

我是C#编程的新手,想要求一些帮助。 我正在尝试使用鼠标左键移动我在Windows应用程序表单上绘制的颜色填充矩形,我正在尝试使用鼠标右键将其拖放到另一个位置。 目前我已设法绘制矩形,但右键单击是拖动整个表单。 这是我的代码: public partial class Form1 : Form { private Point MouseDownLocation; public Form1() { InitializeComponent(); this.DoubleBuffered = true; } Rectangle rec = new Rectangle(0, 0, 0, 0); protected override void OnPaint(PaintEventArgs e) { e.Graphics.FillRectangle(Brushes.DeepSkyBlue, rec); } protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { rec = new Rectangle(eX, eY, […]

通过在C#中使用鼠标拖动控件来移动控件

我试图通过拖动它来移动名为pictureBox1的控件。 问题是,当它移动时,它会一直从一个位置移动到鼠标周围的另一个位置,但它确实跟着它…这是我的代码。 如果你能帮助我,我真的很感激 public partial class Form1 : Form { public Form1() { InitializeComponent(); } bool selected = false; private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { selected = true; } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (selected == true) { pictureBox1.Location = e.Location; } } private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { selected […]