当前位置: 首页>>代码示例>>C#>>正文


C# Geometry.Freeze方法代码示例

本文整理汇总了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>();
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:26,代码来源:CameraPicture.cs

示例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>();
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:47,代码来源:DoorPicture.cs

示例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);
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:14,代码来源:HistorySelectionTextAdornment.cs

示例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);
            }
        }
开发者ID:hirekoke,项目名称:FloWin,代码行数:61,代码来源:MainWindow.xaml.cs

示例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();
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:16,代码来源:CurrentLineHighlighter.cs

示例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();
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:101,代码来源:StrokeRenderer.cs

示例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();
                }
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:101,代码来源:StrokeRenderer.cs

示例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;
        }
开发者ID:ssatta,项目名称:viasfora,代码行数:16,代码来源:RainbowHighlight.cs

示例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;
        }
开发者ID:caesay,项目名称:Hurricane,代码行数:13,代码来源:YouTubeService.cs

示例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();
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:20,代码来源:CaretElement.cs


注:本文中的System.Windows.Media.Geometry.Freeze方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。