Wie kann ich die Mausbewegungsgeschwindigkeit in Windows Formularsteuerung in Mausereignissen finden. Basierend auf der Mausbewegungsgeschwindigkeit muss ich das Steuerelement bewegen. Wie die Maus mit der linken Maustaste bewegen, basierend auf der Mausgeschwindigkeit muss ich meine Kontrolle bewegen?Wie finden Sie die Mausbewegungsgeschwindigkeit in Windows Form?
Antwort
Ich würde es so machen:
startet einen Timer, wenn die Maus zum ersten Mal bewegt wird und speichern Sie die Startposition. Wenn es weitergeht, schauen Sie, ob die Bewegung in einer geraden Linie ist, wenn nicht, stoppen Sie den Timer und wenden Sie dann eine Formel an, um die gesamte zurückgelegte Strecke zu berechnen und sie durch die benötigte Zeit zu teilen. Wenn es mehr als eine "gerade Linie" gibt, können Sie einen Durchschnittswert (Summe/Überhöhung) verwenden.
Vielleicht Codebeispiel von Microsoft können Ihnen helfen:
using System;
using System.Windows.Forms;
using System.Reflection;
namespace SystemInfoBrowser
{
public partial class SystemInfoBrowserForm : System.Windows.Forms.Form
{
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.TextBox textBox1;
public SystemInfoBrowserForm()
{
this.SuspendLayout();
InitForm();
// Add each property of the SystemInformation class to the list box.
Type t = typeof(System.Windows.Forms.SystemInformation);
PropertyInfo[] pi = t.GetProperties();
for (int i = 0; i < pi.Length; i++)
listBox1.Items.Add(pi[i].Name);
textBox1.Text = "The SystemInformation class has " + pi.Length.ToString() + " properties.\r\n";
// Configure the list item selected handler for the list box to invoke a
// method that displays the value of each property.
listBox1.SelectedIndexChanged += new EventHandler(listBox1_SelectedIndexChanged);
this.ResumeLayout(false);
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
// Return if no list item is selected.
if (listBox1.SelectedIndex == -1) return;
// Get the property name from the list item.
string propname = listBox1.Text;
if (propname == "PowerStatus")
{
// Cycle and display the values of each property of the PowerStatus property.
textBox1.Text += "\r\nThe value of the PowerStatus property is:";
Type t = typeof(System.Windows.Forms.PowerStatus);
PropertyInfo[] pi = t.GetProperties();
for (int i = 0; i < pi.Length; i++)
{
object propval = pi[i].GetValue(SystemInformation.PowerStatus, null);
textBox1.Text += "\r\n PowerStatus." + pi[i].Name + " is: " + propval.ToString();
}
}
else
{
// Display the value of the selected property of the SystemInformation type.
Type t = typeof(System.Windows.Forms.SystemInformation);
PropertyInfo[] pi = t.GetProperties();
PropertyInfo prop = null;
for (int i = 0; i < pi.Length; i++)
if (pi[i].Name == propname)
{
prop = pi[i];
break;
}
object propval = prop.GetValue(null, null);
textBox1.Text += "\r\nThe value of the " + propname + " property is: " + propval.ToString();
}
}
private void InitForm()
{
// Initialize the form settings
this.listBox1 = new System.Windows.Forms.ListBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.Location = new System.Drawing.Point(8, 16);
this.listBox1.Size = new System.Drawing.Size(172, 496);
this.listBox1.TabIndex = 0;
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(188, 16);
this.textBox1.Multiline = true;
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox1.Size = new System.Drawing.Size(420, 496);
this.textBox1.TabIndex = 1;
this.ClientSize = new System.Drawing.Size(616, 525);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.listBox1);
this.Text = "Select a SystemInformation property to get the value of";
}
}
}
Aus Microsoft ist und verwendet die Systeminformation Klasse einige Eigenschaften zu zeigen, es zeigt Ihnen auch das Mousespeed, die erreicht von 1 - 20 und sollte standardmäßig auf 10 eingestellt werden. Sie müssen nur die Codeteile für nur diese Eigenschaft extrahieren und Sie sollten eingestellt werden.
Ich brauche die Maus Bewegungsgeschwindigkeit in OnMouseMove Override-Methode, wie kann ich das finden? – Jagadeesan
- 1. Wie finden Sie die Audiolatenz? (Windows/OSX)
- 2. Finden Sie die offenen Formulare in C# Windows-Anwendung
- 3. Python: Wie finden Sie die einfachste Form der Teilbarkeit
- 4. So finden Sie die mobile Vervielfältigung in Form mit PHP
- 5. Zeichnen Form in Windows Form Anwendung
- 6. Wordpress - Finden Sie die Form-Handler-Datei mit dem Routenaktion
- 7. wie alle Panels in Windows-Form ausblenden?
- 8. Windows Form Chat Tutorial
- 9. Master-Formulare in Windows Form
- 10. Benutzeranmeldung in vb.net Windows Form
- 11. jQuery finden Eltern Form
- 12. Contols Schnittpunkt in Windows Form
- 13. MMC Snap in Windows Form
- 14. von Windows Form Webformular
- 15. C# - Windows Form Design
- 16. Windows Form Vererbung
- 17. Wie finden Sie Windows Taskbar Standort und Größe?
- 18. Windows Form mit String Tabelle
- 19. Wie finden Sie den aktuellen Benutzer in einer Windows-Umgebung?
- 20. Wie finden Sie, welches Programm Port 80 in Windows verwendet?
- 21. Windows Form "Loch"
- 22. Wie finden Sie die Anruferfunktion?
- 23. Grafik Button States in C# Windows Form
- 24. C# Windows Form Databinding
- 25. Wie benutzerdefinierte tabcontrol wie Einstellung von Dropbox in Windows Form?
- 26. Windows Terminal - Windows Form zum Einbetten cmd
- 27. Windows Form Fullscreen
- 28. Windows Form, C#, Hintergrundbild
- 29. SubSonic und app.config in Windows Form
- 30. How to Pause backgroundWorker in Windows Form
Sie können diese Arbeit nicht zuverlässig machen Es ist einfach nicht nötig, Sie kümmern sich überhaupt nicht um Geschwindigkeit, wenn Sie einfach durch die neue Mausposition neu zu positionieren. Wenn Sie aus irgendeinem Grund für einige Zeit kein neues Update erhalten haben, funktioniert es immer noch korrekt. –
Für einen einfachen Zug: Verwenden Sie keine Mausgeschwindigkeit. Benutze Position. – PMBjornerud
Ich habe den Touch-Panning-Vorgang mithilfe von Mausereignissen wie MouseDown, MouseMove und MouseUp implementiert. Die Panning-Operation funktioniert perfekt nach Ihrem Vorschlag, ich habe die Mausposition verwendet. Aber ich muss auch die Swipe-Scrolling-Unterstützung in den gleichen Mausereignissen implementieren, wie kann ich das erreichen? – Jagadeesan