本文整理汇总了C#中System.Windows.Controls.UIElementCollection.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# UIElementCollection.OfType方法的具体用法?C# UIElementCollection.OfType怎么用?C# UIElementCollection.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.UIElementCollection
的用法示例。
在下文中一共展示了UIElementCollection.OfType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
///// <summary>
///// If the point is in a hall, just return it. Else, move the point so that it is
///// inside the nearest hall.
///// </summary>
///// <param name="p"></param>
///// <returns></returns>
//public Point RebasePointToHall(Point testPoint)
//{
// // We have the hall outlines,
// Tuple<Point, double> prevNearestWall = null;
// foreach (var x in elements.Where(p => p.IsHall.Value))
// {
// var nearestWall = x.GetClosestWallIntersection(testPoint);
// if (nearestWall.Item2 <= 0)
// {
// return testPoint;
// }
// else if (prevNearestWall == null || nearestWall.Item2 < prevNearestWall.Item2)
// {
// prevNearestWall = nearestWall;
// }
// }
// return prevNearestWall.Item1;
//}
//public Point? GetRoomLocation(int room)
//{
// Point loc;
// return (RoomLocations.TryGetValue(room, out loc) ? (Point?)loc : null);
//}
public async Task Render(UIElementCollection childCollection, Transform textRotation,
Action<BoundingRectangle, double, double> mapBounds,
Func<Action, Task> dispatcher, RoomInfo location,
FrameworkElement overlay)
{
// Use the whole object to allow the overlay to render in the meantime.
if (overlay.ActualWidth == 0 || overlay.ActualHeight == 0)
{
#if NETFX_CORE
EventHandler<object> foo = null;
foo = (object sender, object e) =>
#else
EventHandler foo = null;
foo = (object sender, EventArgs e) =>
#endif
{
mapBounds(buildingBounds, overlay.ActualWidth, overlay.ActualHeight);
overlay.LayoutUpdated -= foo;
};
overlay.LayoutUpdated += foo;
}
else
{
await dispatcher(() => mapBounds(buildingBounds, overlay.ActualWidth, overlay.ActualHeight));
}
// Do the rooms first
foreach (var description in elements
.Where(p => p.Parent == ParentType.Labels || p.Parent == ParentType.Rooms)
.Where(p => p.Type != ElementType.Text))
{
await this.checkRunActions(50, () => RenderElement(childCollection, textRotation, description), dispatcher);
}
// Then the text on top
foreach (var description in elements
.Where(p => p.Parent == ParentType.Labels || p.Parent == ParentType.Rooms)
.Where(p => p.Type == ElementType.Text))
{
await this.checkRunActions(50, () => RenderElement(childCollection, textRotation, description), dispatcher);
}
// Highlight the correct room
await this.checkRunActions(1, () =>
{
var roomElement = childCollection.OfType<Path>().FirstOrDefault(p => ToInt(p.Tag as string) == location.Room);
if (roomElement != null)
{
roomElement.Fill = new SolidColorBrush(Colors.Magenta);
}
}, dispatcher);
foreach (var description in elements.Where(p => p.Parent == ParentType.Background))
{
// Fewer because these paths are more complex
// await this.checkRunActions(50, () => RenderElement(childCollection, textRotation, description), dispatcher);
}
await this.checkRunActions(0, () => { }, dispatcher);
}