本文整理汇总了C#中System.Windows.Media.Geometry.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# Geometry.Freeze方法的具体用法?C# Geometry.Freeze怎么用?C# Geometry.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Geometry
的用法示例。
在下文中一共展示了Geometry.Freeze方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CameraPicture
internal CameraPicture()
{
_geometry = new CombinedGeometry()
{
Geometry1 = new RectangleGeometry(new Rect(0, 3, 14, 8), 1, 1),
Geometry2 = new PathGeometry()
{
Figures = new PathFigureCollection()
{
new PathFigure()
{
StartPoint = new Point(16,5),
IsClosed = false,
Segments = new PathSegmentCollection()
{
new LineSegment(new Point(20,2),true),
new LineSegment(new Point(20,12),true),
new LineSegment(new Point(16,9),true),
}
}
}
}
};
_geometry.Freeze();
_brushes = new Dictionary<Brush, Brush>();
}
示例2: DoorPicture
internal DoorPicture()
{
_pen = new Pen(Brushes.Black, 2);
_pen.Freeze();
_geometry = new PathGeometry()
{
Figures = new PathFigureCollection()
{
new PathFigure()
{
IsClosed = true,
IsFilled = true,
Segments = new PathSegmentCollection()
{
new LineSegment(new Point(-40,0),true),
new LineSegment(new Point(-40,100),true),
new LineSegment(new Point(0,100),true),
}
}
}
};
_geometry.Freeze();
_geometryDrawing = new GeometryDrawing()
{
Brush = new SolidColorBrush(Colors.DarkOrange),
Pen = _pen,
Geometry = new PathGeometry()
{
Figures = new PathFigureCollection()
{
new PathFigure()
{
IsClosed = true,
IsFilled = true,
Segments = new PathSegmentCollection()
{
new LineSegment(new Point(20,40),true),
new LineSegment(new Point(20,140),true),
new LineSegment(new Point(0,100),true),
}
}
}
}
};
_geometryDrawing.Freeze();
_brushes = new Dictionary<Brush, Brush>();
}
示例3: DrawHighlight
private void DrawHighlight(Geometry g, VisualToolset visualTools, SnapshotSpan span) {
if (g.CanFreeze) {
g.Freeze();
}
var dv = new DrawingVisual();
DrawingContext dContext = dv.RenderOpen();
dContext.DrawGeometry(visualTools.Brush, visualTools.Pen, g);
dContext.Close();
var uiElement = new DrawingVisualHost(dv);
_layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, new object(), uiElement, null);
}
示例4: drawForeground
/// <summary>前景を描画する</summary>
private void drawForeground()
{
bool update = false;
// fps
if (_fpsText == null || _app.FrameRate != _prevFps)
{
_prevFps = _app.FrameRate;
_fpsText = new FormattedText(
"fps: " + _app.FrameRate.ToString(),
System.Globalization.CultureInfo.CurrentCulture,
System.Globalization.CultureInfo.CurrentCulture.TextInfo.IsRightToLeft ?
FlowDirection.RightToLeft : FlowDirection.LeftToRight,
_typeface, SystemFonts.MessageFontSize, SystemColors.WindowFrameBrush);
_fpsStroke = _fpsText.BuildGeometry(Config.Instance.FpsLocation);
_fpsStroke.Freeze();
update = true;
}
if (_cntText == null || _prevCnt != _model.Sph.ParticleCount)
{
_prevCnt = _model.Sph.ParticleCount;
_cntText = new FormattedText(
"count: " + _model.Sph.ParticleCount.ToString(),
System.Globalization.CultureInfo.CurrentCulture,
System.Globalization.CultureInfo.CurrentCulture.TextInfo.IsRightToLeft ?
FlowDirection.RightToLeft : FlowDirection.LeftToRight,
_typeface, SystemFonts.MessageFontSize, SystemColors.WindowFrameBrush);
update = true;
}
// 窓一覧
if (_winUpdateTime < _model.WinEnum.LastUpdateTime)
{
_winUpdateTime = _model.WinEnum.LastUpdateTime;
_winText = new FormattedText(
_model.WinEnum.WindowString,
System.Globalization.CultureInfo.CurrentCulture,
System.Globalization.CultureInfo.CurrentCulture.TextInfo.IsRightToLeft ?
FlowDirection.RightToLeft : FlowDirection.LeftToRight,
_typeface, SystemFonts.MessageFontSize, SystemColors.WindowFrameBrush);
update = true;
}
if (!update) return;
using (DrawingContext dc = foreDrawing.Open())
{
// 透明で塗りつぶし
dc.DrawRectangle(Brushes.Transparent, null, _scrRect);
//_pourSrc.Draw(dc);
// FPS
dc.DrawGeometry(Brushes.White, _txtStrokePen, _fpsStroke);
dc.DrawText(_fpsText, Config.Instance.FpsLocation);
dc.DrawText(_cntText, Config.Instance.ParticleCountLocation);
// 窓一覧
dc.DrawText(_winText, Config.Instance.WinEnumLocation);
}
}
示例5: SetLine
public void SetLine(ITextViewLine line, double width) {
if (line == null)
throw new ArgumentNullException(nameof(line));
var newRect = new Rect(PEN_THICKNESS / 2, PEN_THICKNESS / 2, Math.Max(0, width - PEN_THICKNESS), Math.Max(0, line.TextHeight + WpfTextViewLine.DEFAULT_BOTTOM_SPACE - PEN_THICKNESS));
if (geometry != null && newRect == geometryRect)
return;
geometryRect = newRect;
if (geometryRect.Height == 0 || geometryRect.Width == 0)
geometry = null;
else {
geometry = new RectangleGeometry(geometryRect);
if (geometry.CanFreeze)
geometry.Freeze();
}
InvalidateVisual();
}
示例6: CalcGeometryAndBoundsWithTransform
//.........这里部分代码省略.........
if (stylusTipMatrixType == MatrixTypes.TRANSFORM_IS_UNKNOWN)
{
//probably a skew is thrown in, we need to fall back to being very conservative
//about how many strokeNodes we prune
angleTolerance = 10d;
}
else if (strokeNodeBounds.Height > 40d || strokeNodeBounds.Width > 40d)
{
//if the strokeNode gets above a certain size, we need to lay down more strokeNodes
//to prevent visual artifacts
angleTolerance = 20d;
}
bool directionChanged = delta > angleTolerance && delta < (360d - angleTolerance);
double prevArea = lastRect.Height * lastRect.Width;
double currArea = strokeNodeBounds.Height * strokeNodeBounds.Width;
bool areaChangedOverThreshold = false;
if ((Math.Min(prevArea, currArea) / Math.Max(prevArea, currArea)) <= 0.70d)
{
//the min area is < 70% of the max area
areaChangedOverThreshold = true;
}
lastRect = strokeNodeBounds;
//render the stroke node for the first two nodes and last two nodes always
if (index <= 1 || index >= iterator.Count - 2 || directionChanged || areaChangedOverThreshold)
{
//special case... the direction has changed and we need to
//insert a stroke node in the StreamGeometry before we render the current one
if (directionChanged && !previousPreviousNodeRendered && index > 1 && index < iterator.Count - 1)
{
//insert a stroke node for the previous node
strokeNodePoints.Clear();
strokeNode.GetPreviousContourPoints(strokeNodePoints);
AddFigureToStreamGeometryContext(context, strokeNodePoints, strokeNode.IsEllipse/*isBezierFigure*/);
previousPreviousNodeRendered = true;
}
//render the stroke node
strokeNodePoints.Clear();
strokeNode.GetContourPoints(strokeNodePoints);
AddFigureToStreamGeometryContext(context, strokeNodePoints, strokeNode.IsEllipse/*isBezierFigure*/);
}
if (!directionChanged)
{
previousPreviousNodeRendered = false;
}
//add the end points of the connecting quad
Quad quad = strokeNode.GetConnectingQuad();
if (!quad.IsEmpty)
{
connectingQuadPoints[abIndex++] = quad.A;
connectingQuadPoints[abIndex++] = quad.B;
connectingQuadPoints.Add(quad.D);
connectingQuadPoints.Add(quad.C);
}
if (strokeNode.IsLastNode)
{
Debug.Assert(index == iterator.Count - 1);
if (abIndex > 0)
{
//we added something to the connecting quad points.
//now we need to do three things
//1) Shift the dc points down to the ab points
int cbStartIndex = iterator.Count * 2;
int cbEndIndex = connectingQuadPoints.Count - 1;
for (int i = abIndex, j = cbStartIndex; j <= cbEndIndex; i++, j++)
{
connectingQuadPoints[i] = connectingQuadPoints[j];
}
//2) trim the exess off the end of the array
int countToRemove = cbStartIndex - abIndex;
connectingQuadPoints.RemoveRange((cbEndIndex - countToRemove) + 1, countToRemove);
//3) reverse the dc points to make them cd points
for (int i = abIndex, j = connectingQuadPoints.Count - 1; i < j; i++, j--)
{
Point temp = connectingQuadPoints[i];
connectingQuadPoints[i] = connectingQuadPoints[j];
connectingQuadPoints[j] = temp;
}
//now render away!
AddFigureToStreamGeometryContext(context, connectingQuadPoints, false/*isBezierFigure*/);
}
}
}
}
finally
{
context.Close();
geometry.Freeze();
}
}
示例7: CalcGeometryAndBounds
//.........这里部分代码省略.........
// which is at prevStrokeNode
//
prevStrokeNode.GetPointsAtEndOfSegment(pathFigureABSide, pathFigureDCSide);
#endif
//render
ReverseDCPointsRenderAndClear(context, pathFigureABSide, pathFigureDCSide, polyLinePoints, isEllipse, false/*clear the point collections*/);
}
else
{
// we've only seen two points to render
Debug.Assert(pathFigureDCSide.Count == 0);
//contains all the logic to render two stroke nodes
RenderTwoStrokeNodes( context,
prevPrevStrokeNode,
prevPrevStrokeNodeBounds,
prevStrokeNode,
prevStrokeNodeBounds,
pathFigureABSide,
pathFigureDCSide,
polyLinePoints
#if DEBUG_RENDERING_FEEDBACK
,debugDC,
feedbackSize,
showFeedback
#endif
);
}
}
else
{
if (calculateBounds)
{
bounds.Union(prevPrevStrokeNodeBounds);
}
// we only have a single point to render
Debug.Assert(pathFigureABSide.Count == 0);
prevPrevStrokeNode.GetContourPoints(pathFigureABSide);
AddFigureToStreamGeometryContext(context, pathFigureABSide, prevPrevStrokeNode.IsEllipse/*isBezierFigure*/);
}
}
else if (prevStrokeNode.IsValid && strokeNode.IsValid)
{
if (calculateBounds)
{
bounds.Union(prevStrokeNodeBounds);
bounds.Union(strokeNodeBounds);
}
// typical case, we hit the end of the stroke
// see if we need to start a stroke, or just end one
if (pathFigureABSide.Count > 0)
{
#if DEBUG_RENDERING_FEEDBACK
strokeNode.GetPointsAtEndOfSegment(pathFigureABSide, pathFigureDCSide, debugDC, feedbackSize, showFeedback);
#else
strokeNode.GetPointsAtEndOfSegment(pathFigureABSide, pathFigureDCSide);
#endif
//render
ReverseDCPointsRenderAndClear(context, pathFigureABSide, pathFigureDCSide, polyLinePoints, isEllipse, false/*clear the point collections*/);
if (FuzzyContains(strokeNodeBounds, prevStrokeNodeBounds, 70d) != RectCompareResult.NoItersection)
{
//render a complete stroke node or we can get artifacts
strokeNode.GetContourPoints(polyLinePoints);
AddFigureToStreamGeometryContext(context, polyLinePoints, strokeNode.IsEllipse/*isBezierFigure*/);
}
}
else
{
Debug.Assert(pathFigureDCSide.Count == 0);
//contains all the logic to render two stroke nodes
RenderTwoStrokeNodes( context,
prevStrokeNode,
prevStrokeNodeBounds,
strokeNode,
strokeNodeBounds,
pathFigureABSide,
pathFigureDCSide,
polyLinePoints
#if DEBUG_RENDERING_FEEDBACK
,debugDC,
feedbackSize,
showFeedback
#endif
);
}
}
}
finally
{
context.Close();
geometry.Freeze();
}
}
}
示例8: MakeAdornment
private UIElement MakeAdornment(SnapshotSpan span, Geometry spanGeometry, int depth)
{
var brush = GetRainbowBrush(depth);
if ( spanGeometry.CanFreeze ) {
spanGeometry.Freeze();
}
Path path = new Path();
path.Data = spanGeometry;
path.Stroke = brush;
path.StrokeThickness = 1.3;
path.Fill = MakeBackgroundBrush(brush);
return path;
}
示例9: GetYouTubeVector
public static Geometry GetYouTubeVector()
{
if (_youtubeVector == null)
{
//from https://www.youtube.com/yt/brand/de/downloads.html
_youtubeVector =
Geometry.Parse(
"F1 M 405.272,491.704 L 405.225,204.704 L 681.225,348.704 L 405.272,491.704 Z M 1011.248,154.985 C 1011.248,154.985 1001.267,84.596 970.642,53.599 C 931.800,12.916 888.262,12.714 868.296,10.332 C 725.359,0.000 510.946,0.000 510.946,0.000 L 510.502,0.000 C 510.502,0.000 296.094,0.000 153.152,10.332 C 133.185,12.714 89.663,12.916 50.807,53.599 C 20.181,84.596 10.215,154.985 10.215,154.985 C 10.215,154.985 0.000,237.645 0.000,320.304 L 0.000,397.797 C 0.000,480.455 10.215,563.114 10.215,563.114 C 10.215,563.114 20.181,633.504 50.807,664.501 C 89.663,705.185 140.703,703.898 163.435,708.162 C 245.153,715.998 510.725,718.423 510.725,718.423 C 510.725,718.423 725.359,718.100 868.296,707.768 C 888.262,705.386 931.800,705.185 970.642,664.501 C 1001.267,633.504 1011.248,563.114 1011.248,563.114 C 1011.248,563.114 1021.449,480.455 1021.449,397.797 L 1021.449,320.304 C 1021.449,237.645 1011.248,154.985 1011.248,154.985 Z");
_youtubeVector.Freeze();
}
return _youtubeVector;
}
示例10: ConstructCaretGeometry
private void ConstructCaretGeometry()
{
PathGeometry geometry = new PathGeometry();
geometry.AddGeometry(new RectangleGeometry(new Rect(0, 0, base.Width, base.Height)));
if (InputLanguageManager.Current.CurrentInputLanguage.TextInfo.IsRightToLeft)
{
PathFigure figure = new PathFigure();
figure.StartPoint = new Point(0, 0);
figure.Segments.Add(new LineSegment(new Point(-2, 0), true));
figure.Segments.Add(new LineSegment(new Point(0, base.Height / 10), true));
figure.IsClosed = true;
geometry.Figures.Add(figure);
}
_caretGeometry = geometry;
if (_caretGeometry.CanFreeze)
{
_caretGeometry.Freeze();
}
base.InvalidateVisual();
}