本文整理汇总了C#中PathSegmentCollection.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# PathSegmentCollection.Freeze方法的具体用法?C# PathSegmentCollection.Freeze怎么用?C# PathSegmentCollection.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathSegmentCollection
的用法示例。
在下文中一共展示了PathSegmentCollection.Freeze方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBackgound
/// <summary>
/// Draw the hatches and the transparent area where isn't covering the elements.
/// </summary>
/// <param name="drawingContext"></param>
private void DrawBackgound(DrawingContext drawingContext)
{
PathGeometry hatchGeometry = null;
Geometry rectGeometry = null;
int count = _elementsBounds.Count;
if ( count != 0 )
{
// Create a union collection of the element regions.
for ( int i = 0; i < count; i++ )
{
Rect hatchRect = _elementsBounds[i];
if ( hatchRect.IsEmpty )
{
continue;
}
hatchRect.Inflate(HatchBorderMargin / 2, HatchBorderMargin / 2);
if ( hatchGeometry == null )
{
PathFigure path = new PathFigure();
path.StartPoint = new Point(hatchRect.Left, hatchRect.Top);
PathSegmentCollection segments = new PathSegmentCollection();
PathSegment line = new LineSegment(new Point(hatchRect.Right, hatchRect.Top), true);
line.Freeze();
segments.Add(line);
line = new LineSegment(new Point(hatchRect.Right, hatchRect.Bottom), true);
line.Freeze();
segments.Add(line);
line = new LineSegment(new Point(hatchRect.Left, hatchRect.Bottom), true);
line.Freeze();
segments.Add(line);
line = new LineSegment(new Point(hatchRect.Left, hatchRect.Top), true);
line.Freeze();
segments.Add(line);
segments.Freeze();
path.Segments = segments;
path.IsClosed = true;
path.Freeze();
hatchGeometry = new PathGeometry();
hatchGeometry.Figures.Add(path);
}
else
{
rectGeometry = new RectangleGeometry(hatchRect);
rectGeometry.Freeze();
hatchGeometry = Geometry.Combine(hatchGeometry, rectGeometry, GeometryCombineMode.Union, null);
}
}
}
// Then, create a region which equals to "SelectionFrame - element1 bounds - element2 bounds - ..."
GeometryGroup backgroundGeometry = new GeometryGroup( );
GeometryCollection geometryCollection = new GeometryCollection();
// Add the entile rectanlge to the group.
rectGeometry = new RectangleGeometry(new Rect(0, 0, RenderSize.Width, RenderSize.Height));
rectGeometry.Freeze();
geometryCollection.Add(rectGeometry);
// Add the union of the element rectangles. Then the group will do oddeven operation.
Geometry outlineGeometry = null;
if ( hatchGeometry != null )
{
hatchGeometry.Freeze();
outlineGeometry = hatchGeometry.GetOutlinedPathGeometry();
outlineGeometry.Freeze();
if ( count == 1 && ((InkCanvasInnerCanvas)AdornedElement).InkCanvas.GetSelectedStrokes().Count == 0 )
{
geometryCollection.Add(outlineGeometry);
}
}
geometryCollection.Freeze();
backgroundGeometry.Children = geometryCollection;
backgroundGeometry.Freeze();
// Then, draw the region which may contain holes so that the elements cannot be covered.
// After that, the underneath elements can receive the messages.
#if DEBUG_OUTPUT
// Draw the debug feedback
drawingContext.DrawGeometry(new SolidColorBrush(Color.FromArgb(128, 255, 255, 0)), null, backgroundGeometry);
#else
//.........这里部分代码省略.........