本文整理汇总了C#中System.Windows.Rect.TopRight方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.TopRight方法的具体用法?C# Rect.TopRight怎么用?C# Rect.TopRight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Rect
的用法示例。
在下文中一共展示了Rect.TopRight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_MouseLeftButtonUp
void Page_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if(_dragged != null)
{
//Set correct Z-index
Rect r = new Rect(Canvas.GetLeft(_dragged), Canvas.GetTop(_dragged), _dragged.Width, _dragged.Height);
var t = from uc in _objects
where uc != _dragged && (
uc.ContainsPoint(r.TopLeft()) || uc.ContainsPoint(r.TopRight()) ||
uc.ContainsPoint(r.BottomLeft()) || uc.ContainsPoint(r.BottomRight()))
orderby Canvas.GetZIndex(uc) descending
select uc;
int z;
if(t.Count() > 0)
z = Canvas.GetZIndex(t.FirstOrDefault()) + 1;
else
z = 0;
Canvas.SetZIndex(_dragged, z);
}
_dragged = null;
}
示例2: SnapTopRightCorner
/// <summary>
/// Snaps the upper right corner of the specified rectangle to the nearest bounds.
/// </summary>
/// <param name="rect">The rectangle.</param>
/// <returns>New position.</returns>
public Point SnapTopRightCorner(Rect rect)
{
Point point = rect.TopRight();
if (SnapinEnabled)
{
Distance minDistance = new Distance();
foreach (var bound in SnapinBounds)
{
Distance distance = new Distance()
{
X = DistanceBetweenRightEdgeAndRectangle(rect, bound),
Y = DistanceBetweenTopEdgeAndRectangle(rect, bound)
};
minDistance = Distance.Min(distance, minDistance);
}
point = point.Add(minDistance);
}
return point;
}