本文整理汇总了C#中MouseButtonEventArgs.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# MouseButtonEventArgs.GetPosition方法的具体用法?C# MouseButtonEventArgs.GetPosition怎么用?C# MouseButtonEventArgs.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MouseButtonEventArgs
的用法示例。
在下文中一共展示了MouseButtonEventArgs.GetPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Control_MouseLeftButtonDown
private void Control_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
isDragging = true;
var draggableControl = sender as UserControl;
clickPosition = e.GetPosition(this);
draggableControl.CaptureMouse();
}
示例2: AllowMouseLeftButtonDown
/// <summary>
/// Check if the control's MouseLeftButtonDown event should be handled.
/// </summary>
/// <param name="e">Event arguments.</param>
/// <returns>
/// A value indicating whether the event should be handled.
/// </returns>
public bool AllowMouseLeftButtonDown(MouseButtonEventArgs e)
{
if (e == null)
{
throw new ArgumentNullException("e");
}
bool enabled = Control.IsEnabled;
if (enabled)
{
// Get the current position and time
DateTime now = DateTime.UtcNow;
Point position = e.GetPosition(Control);
// Compute the deltas from the last click
double timeDelta = (now - LastClickTime).TotalMilliseconds;
Point lastPosition = LastClickPosition;
double dx = position.X - lastPosition.X;
double dy = position.Y - lastPosition.Y;
double distance = dx * dx + dy * dy;
// Check if the values fall under the sequential click temporal
// and spatial thresholds
if (timeDelta < SequentialClickThresholdInMilliseconds &&
distance < SequentialClickThresholdInPixelsSquared)
{
ClickCount++;
}
else
{
ClickCount = 1;
}
// Set the new position and time
LastClickTime = now;
LastClickPosition = position;
// Raise the event
IsPressed = true;
}
else
{
ClickCount = 1;
}
return enabled;
}
示例3: ClassesImg_MouseLeftButtonDown
void ClassesImg_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
System.Windows.Point coo = e.GetPosition(this.ClassesImg);
Pixel p;
if (classes < 4)
{
p = img.GetPixel((uint)coo.X, (uint)coo.Y);
m[classes] = p.R;
if (Combo.SelectedIndex == 0)
{
if (classes == 0)
Class1Mu.Text = m[classes].ToString();
else if (classes == 1)
Class2Mu.Text = m[classes].ToString();
else if (classes == 2)
Class3Mu.Text = m[classes].ToString();
else if (classes == 3)
Class4Mu.Text = m[classes].ToString();
}
else if (Combo.SelectedIndex == 1)
{
if (classes == 0)
{
ClassARMeau.Text = p.R.ToString();
ClassAGMeau.Text = p.G.ToString();
ClassABMeau.Text = p.B.ToString();
}
else if (classes == 1)
{
ClassBRMeau.Text = p.R.ToString();
ClassBGMeau.Text = p.G.ToString();
ClassBBMeau.Text = p.B.ToString();
}
else if (classes == 2)
{
ClassCRMeau.Text = p.R.ToString();
ClassCGMeau.Text = p.G.ToString();
ClassCBMeau.Text = p.B.ToString();
}
else if (classes == 3)
{
ClassDRMeau.Text = p.R.ToString();
ClassDGMeau.Text = p.G.ToString();
ClassDBMeau.Text = p.B.ToString();
}
}
++classes;
}
}