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