本文整理汇总了C#中IInputElement.CaptureMouse方法的典型用法代码示例。如果您正苦于以下问题:C# IInputElement.CaptureMouse方法的具体用法?C# IInputElement.CaptureMouse怎么用?C# IInputElement.CaptureMouse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IInputElement
的用法示例。
在下文中一共展示了IInputElement.CaptureMouse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterBorderEvents
//.........这里部分代码省略.........
{
case WindowBorderEdge.Left:
cursorOffset.X = cursorLocation.X;
break;
case WindowBorderEdge.TopLeft:
cursorOffset.X = cursorLocation.X;
cursorOffset.Y = cursorLocation.Y;
break;
case WindowBorderEdge.Top:
cursorOffset.Y = cursorLocation.Y;
break;
case WindowBorderEdge.TopRight:
cursorOffset.X = (Width - cursorLocation.X);
cursorOffset.Y = cursorLocation.Y;
break;
case WindowBorderEdge.Right:
cursorOffset.X = (Width - cursorLocation.X);
break;
case WindowBorderEdge.BottomRight:
cursorOffset.X = (Width - cursorLocation.X);
cursorOffset.Y = (Height - cursorLocation.Y);
break;
case WindowBorderEdge.Bottom:
cursorOffset.Y = (Height - cursorLocation.Y);
break;
case WindowBorderEdge.BottomLeft:
cursorOffset.X = cursorLocation.X;
cursorOffset.Y = (Height - cursorLocation.Y);
break;
}
_cursorOffset = cursorOffset;
border.CaptureMouse();
}
};
#endregion
#region MouseMove
//border.PreviewMouseMove
border.MouseMove += (sender, e) =>
{
if (WindowState != WindowState.Maximized && border.IsMouseCaptured && ResizeMode == ResizeMode.CanResize)
{
var cursorLocation = e.GetPosition(this);
var nHorizontalChange = (cursorLocation.X - _cursorOffset.X);
var pHorizontalChange = (cursorLocation.X + _cursorOffset.X);
var nVerticalChange = (cursorLocation.Y - _cursorOffset.Y);
var pVerticalChange = (cursorLocation.Y + _cursorOffset.Y);
switch (borderEdge)
{
case WindowBorderEdge.Left:
if (Width - nHorizontalChange <= MinWidth) break;
Left += nHorizontalChange;
Width -= nHorizontalChange;
break;
case WindowBorderEdge.TopLeft:
if (!(Width - nHorizontalChange <= MinWidth))
{
Left += nHorizontalChange;
Width -= nHorizontalChange;
}
if (!(Height - nVerticalChange <= MinHeight))