本文整理汇总了C#中Visual.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Visual.Equals方法的具体用法?C# Visual.Equals怎么用?C# Visual.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Visual
的用法示例。
在下文中一共展示了Visual.Equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeVisible
public Rect MakeVisible(Visual visual, Rect rectangle)
{
InvalidateMeasure();
UpdateLayout();
TabControl ic = ItemsControl.GetItemsOwner(this) as TabControl;
if (ic == null) return Rect.Empty;
int index = -1;
var tabsCount = ic.GetTabsCount();
for (int i = 0; i < tabsCount; i++)
{
if (visual.Equals(ic.GetTabItem(i)))
{
index = i;
break;
}
}
if (index > -1)
{
if (index < FirstVisibleIndex)
FirstVisibleIndex = index;
else if (index > LastVisibleIndex)
{
while (index > LastVisibleIndex)
FirstVisibleIndex++;
}
InvalidateArrange();
}
return Rect.Empty;
}
示例2: MakeVisible
public Rect MakeVisible(Visual visual, Rect rectangle)
{
ItemsControl ic = ItemsControl.GetItemsOwner(this);
if (ic == null) return Rect.Empty;
int index = -1;
for (int i = 0; i < ic.Items.Count; i++)
{
if (visual.Equals(ic.Items[i]))
{
index = i;
break;
}
}
if (index > -1)
{
if (index < FirstVisibleIndex)
FirstVisibleIndex = index;
else if (index > LastVisibleIndex)
{
while (index > LastVisibleIndex)
FirstVisibleIndex++;
}
InvalidateMeasure();
UpdateLayout();
}
return Rect.Empty;
}
示例3: MakeVisible
/// <summary>
/// Forces content to scroll until the coordinate space of a <see cref="T:System.Windows.Media.Visual" /> object is visible.
/// </summary>
/// <param name="visual">A <see cref="T:System.Windows.Media.Visual" /> that becomes visible.</param>
/// <param name="rectangle">A bounding rectangle that identifies the coordinate space to make visible.</param>
/// <returns>A <see cref="T:System.Windows.Rect" /> that is visible.</returns>
public Rect MakeVisible(Visual visual, Rect rectangle)
{
if (rectangle.IsEmpty || visual == null
|| visual.Equals(this) || !IsAncestorOf(visual))
{ return Rect.Empty; }
rectangle = visual.TransformToAncestor(this).TransformBounds(rectangle);
if (rectangle.IsEmpty)
{
return rectangle;
}
var scaleX = CanHorizontallyScroll ? (rectangle.Width * .6) : 0;
var scaleY = CanVerticallyScroll ? (rectangle.Height * .6) : 0;
rectangle.Inflate(scaleX, scaleY);
var rect = new Rect(HorizontalOffset, VerticalOffset, ViewportWidth, ViewportHeight);
rectangle.X += rect.X;
rectangle.Y += rect.Y;
rect.X = ComputeScrollOffsetWithMinimalScroll(rect.Left, rect.Right, rectangle.Left, rectangle.Right);
rect.Y = ComputeScrollOffsetWithMinimalScroll(rect.Top, rect.Bottom, rectangle.Top, rectangle.Bottom);
SetHorizontalOffset(rect.X);
SetVerticalOffset(rect.Y);
rectangle.Intersect(rect);
rectangle.X -= rect.X;
rectangle.Y -= rect.Y;
return rectangle;
}