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


C# PathGeometry.AddGeometry方法代码示例

本文整理汇总了C#中System.Windows.Media.PathGeometry.AddGeometry方法的典型用法代码示例。如果您正苦于以下问题:C# PathGeometry.AddGeometry方法的具体用法?C# PathGeometry.AddGeometry怎么用?C# PathGeometry.AddGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.PathGeometry的用法示例。


在下文中一共展示了PathGeometry.AddGeometry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateAnimation

        /// <summary>
        /// Create the animation and add it to the master timeline
        /// </summary>
        protected override void CreateAnimation()
        {
            var geometry = new PathGeometry();
            geometry.AddGeometry(Geometry.Parse("M 10,100 C 10,300 300,-200 300,100"));

            var animationX = new DoubleAnimationUsingPath
                {
                    PathGeometry = geometry,
                    Duration = new Duration(this.AnimationConfiguration.Duration),
                    Source = PathAnimationSource.X
                };

            var animationY = new DoubleAnimationUsingPath
            {
                PathGeometry = geometry,
                Duration = new Duration(this.AnimationConfiguration.Duration),
                Source = PathAnimationSource.Y
            };

            Storyboard.SetTargetProperty(animationX, new PropertyPath(Canvas.LeftProperty));
            Storyboard.SetTargetProperty(animationY, new PropertyPath(Canvas.TopProperty));

            animationX.Freeze();
            animationY.Freeze();

            this.MasterStoryboard.Children.Add(animationX);
            this.MasterStoryboard.Children.Add(animationY);
        }
开发者ID:modulexcite,项目名称:WPF-Saveable-Code-Based-Animations,代码行数:31,代码来源:PathFollowerAnimation.cs

示例2: OnRender

		protected override void OnRender(DrawingContext drawingContext) {
			base.OnRender(drawingContext);
			if (hexBox.Selection == null || hexBox.VisibleBytesPerLine < 1)
				return;

			ulong selStart = hexBox.Selection.Value.StartOffset;
			ulong selEnd = hexBox.Selection.Value.EndOffset;
			int lines = hexBox.VisibleLinesPerPage;
			ulong bpl = (ulong)hexBox.VisibleBytesPerLine;
			ulong visibleStart = hexBox.TopOffset;
			ulong visibleEnd = NumberUtils.AddUInt64(NumberUtils.AddUInt64(visibleStart, NumberUtils.MulUInt64(bpl, NumberUtils.SubUInt64((ulong)lines, 1))), NumberUtils.SubUInt64(bpl, 1));
			if (selStart > visibleEnd || selEnd < visibleStart)
				return;

			ulong offset = Math.Max(selStart, visibleStart);
			ulong endOffset = Math.Min(selEnd, visibleEnd);
			double x = -hexBox.CharacterWidth * hexBox.LeftColumn;
			double y = (offset - hexBox.TopOffset) / bpl * hexBox.CharacterHeight;
			var path = new PathGeometry();
			double hexByteX = hexBox.GetHexByteColumnIndex() * hexBox.CharacterWidth;
			double asciiX = hexBox.GetAsciiColumnIndex() * hexBox.CharacterWidth;
			while (offset <= endOffset) {
				ulong byteIndex = hexBox.GetLineByteIndex(offset);
				ulong count = Math.Min(bpl - byteIndex, endOffset - offset + 1);

				double dx = byteIndex * hexBox.CharacterWidth;
				var rectGeo = new RectangleGeometry(new Rect(x + dx * 3 + hexByteX + hexBox.CharacterWidth, y, count * hexBox.CharacterWidth * 3 - hexBox.CharacterWidth, hexBox.CharacterHeight));
				rectGeo.Freeze();
				path.AddGeometry(rectGeo);

				if (hexBox.ShowAscii) {
					rectGeo = new RectangleGeometry(new Rect(x + dx + asciiX, y, count * hexBox.CharacterWidth, hexBox.CharacterHeight));
					rectGeo.Freeze();
					path.AddGeometry(rectGeo);
				}

				if (offset + bpl - byteIndex < offset)
					break;
				offset += bpl - byteIndex;
				y += hexBox.CharacterHeight;
			}

			path.Freeze();
			drawingContext.DrawGeometry(Background, null, path);
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:45,代码来源:SelectionLayer.cs

示例3: Convert

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            PathGeometry pathData = new PathGeometry();

            if ((Status)value == Status.Connected)
            {
                pathData.AddGeometry(Geometry.Parse(""));
            }
            else if ((Status)value == Status.Disconnected)
            {
                pathData.AddGeometry(Geometry.Parse("F1 M 58.5832,55.4172L 17.4169,55.4171C 15.5619,53.5621 15.5619,50.5546 17.4168,48.6996L 35.201,15.8402C 37.056,13.9852 40.0635,13.9852 41.9185,15.8402L 58.5832,48.6997C 60.4382,50.5546 60.4382,53.5622 58.5832,55.4172 Z M 34.0417,25.7292L 36.0208,41.9584L 39.9791,41.9583L 41.9583,25.7292L 34.0417,25.7292 Z M 38,44.3333C 36.2511,44.3333 34.8333,45.7511 34.8333,47.5C 34.8333,49.2489 36.2511,50.6667 38,50.6667C 39.7489,50.6667 41.1666,49.2489 41.1666,47.5C 41.1666,45.7511 39.7489,44.3333 38,44.3333 Z"));
            }
            else
            {
                pathData.AddGeometry(Geometry.Parse("F1 M 37.2083,49.0833C 39.3945,49.0833 41.1667,50.8555 41.1667,53.0417C 41.1667,55.2278 39.3945,57 37.2083,57C 35.0222,57 33.25,55.2278 33.25,53.0417C 33.25,50.8555 35.0222,49.0833 37.2083,49.0833 Z M 38,17.4167C 44.9956,17.4167 50.6666,21.9416 50.6666,28.5C 50.6666,30.875 49.0833,34.8333 45.9167,36.4167C 42.75,38 41.1667,40.1267 41.1667,42.75L 41.1667,45.9167L 33.25,45.9167L 33.25,43.5417C 33.25,38.1571 38,34.8333 39.5833,33.25C 42.75,30.0833 42.75,29.644 42.75,28.5C 42.75,25.8767 40.6233,23.75 38,23.75C 35.3766,23.75 33.25,25.8767 33.25,28.5L 33.25,30.875L 25.3333,30.875L 25.3333,29.2917C 25.3333,22.7333 31.0044,17.4167 38,17.4167 Z"));
            }

            return pathData;
        }
开发者ID:killnine,项目名称:MvvmTest,代码行数:19,代码来源:StatusToImageConverter.cs

示例4: GetAllToTogether

        public string GetAllToTogether(string[] paths)
        {
            PathGeometry result = new PathGeometry();
            foreach (var item in paths)
            {
                result.AddGeometry (  PathGeometry.Parse(item));

            }

            return result.ToString();
        }
开发者ID:waynebaby,项目名称:Code-For-Fun,代码行数:11,代码来源:TextToPathService.cs

示例5: GetAsPathGeometry

        internal override PathGeometry GetAsPathGeometry()
        {
            PathGeometry pg = new PathGeometry();
            pg.AddGeometry(this);

            pg.FillRule = FillRule;

            Debug.Assert(pg.CanFreeze);

            return pg;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:11,代码来源:GeometryGroup.cs

示例6: DrawCircle

        public void DrawCircle(Point center, DrawingContext drawingContext, Size windowSize, bool drawCircle)
        {
            var rectangle = new Rect(center.X - Radius, center.Y - Radius, Radius * 2, Radius * 2);
            var path = new PathGeometry();
            path.AddGeometry(new EllipseGeometry(rectangle));
            drawingContext.PushClip(path);
            var windowRect = new Rect(windowSize);
            drawingContext.DrawImage(Bitmap, windowRect);

            if (drawCircle)
                drawingContext.DrawEllipse(Brushes.Transparent, new Pen(Brushes.Red, 1.5), center, Radius, Radius);
        }
开发者ID:shimins,项目名称:Eyetracking,代码行数:12,代码来源:CircleImage.cs

示例7: CreateAutoShape

        private void CreateAutoShape(object sender, RoutedEventArgs e)
        {
            PathGeometry sendingPath = new PathGeometry(); 
            PathFigure pathFigure = new PathFigure();
            pathFigure.StartPoint = new Point(47.7778, 48.6667);
            pathFigure.IsClosed = true;
            LineSegment lineSegment1 = new LineSegment();
            lineSegment1.Point = new Point(198, 48.6667);
            pathFigure.Segments.Add(lineSegment1);
            LineSegment lineSegment2 = new LineSegment();
            lineSegment2.Point = new Point(198, 102);
            pathFigure.Segments.Add(lineSegment2);
            BezierSegment bezierSegment1 = new BezierSegment();
            bezierSegment1.Point1 = new Point(174.889, 91.3334);
            bezierSegment1.Point2 = new Point(157.111, 79.7778);
            bezierSegment1.Point3 = new Point(110.889, 114.444);
            pathFigure.Segments.Add(bezierSegment1);
            BezierSegment bezierSegment2 = new BezierSegment();
            bezierSegment2.Point1 = new Point(64.667, 149.111);
            bezierSegment2.Point2 = new Point(58.4444, 130.444);
            bezierSegment2.Point3 = new Point(47.7778, 118.889);
            pathFigure.Segments.Add(bezierSegment2);
            sendingPath.Figures.Add(pathFigure);

            PathGeometry pathGeometry = new PathGeometry();
            if (sendingPath.FillRule != null)
                pathGeometry.FillRule = sendingPath.FillRule;
            else pathGeometry.FillRule = FillRule.Nonzero;
            pathGeometry.Figures = sendingPath.Figures;

            var newThumb = new SandRibbonInterop.AutoShape();
            var safePathGeometry = (Geometry)(new GeometryConverter().ConvertFromString(pathGeometry.ToString()));
            var safePathData = new PathGeometry();
            safePathData.AddGeometry(safePathGeometry);
            newThumb.PathData = safePathData;
            newThumb.Background = Brushes.LightGreen;
            newThumb.Foreground = Brushes.Green;
            newThumb.StrokeThickness = 5;
            newThumb.Height = 100;
            newThumb.Width = 100;
            
            Commands.AddAutoShape.Execute(newThumb);
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:43,代码来源:SimpleToolBox.xaml.cs

示例8: OnRefresh

        protected override void OnRefresh()
        {
            LineDecoration lineDecoration = Visual as LineDecoration;
            if (lineDecoration != null)
            {
                _pathPen = new Pen(new SolidColorBrush(lineDecoration.LineColor), lineDecoration.Thickness);
                _path = new PathGeometry();

                Point startPoint = new Point(lineDecoration.Start.X - lineDecoration.Left, lineDecoration.Start.Y - lineDecoration.Top);
                Point endPoint = new Point(lineDecoration.End.X - lineDecoration.Left, lineDecoration.End.Y - lineDecoration.Top);

                if (lineDecoration.Curve)
                {
                    // Create a vector representing the direction of the line
                    Vector v1 = lineDecoration.End - lineDecoration.Start;
                    double length = v1.Length;

                    // Normalize so it can be used to construct control points
                    v1.Normalize();

                    // Create a matrix to rotate arm perpendicular
                    Matrix m1 = new Matrix();
                    m1.Rotate(-90);

                    Point curvePoint1 = (startPoint + (v1 * (length * lineDecoration.CurveStart))) + ((v1 * (length * lineDecoration.CurveDepth)) * m1);
                    Point curvePoint2 = (endPoint - (v1 * (length * lineDecoration.CurveStart))) + ((v1 * (length * lineDecoration.CurveDepth)) * m1);

                    //_path.Figures.Add(QuadraticBezierFromIntersection(startPoint, curvePoint1, endPoint));
                    _path.Figures.Add(BezierFromIntersection(startPoint,curvePoint1,curvePoint2,endPoint));
                }
                else
                {
                    LineGeometry line = new LineGeometry(startPoint, endPoint);
                    _path.AddGeometry(line);
                }                
            }
        }
开发者ID:Heliflyer,项目名称:helios,代码行数:37,代码来源:LineDecorationRenderer.cs

示例9: 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

示例10: AddPath

		public void AddPath (IGraphicsPath path, bool connect = false)
		{
			if (path.IsEmpty)
				return;

			var wpfPath = path.ToWpf ();
			if (!wpfPath.Transform.Value.IsIdentity) {
				var newpath = new swm.PathGeometry ();
				newpath.AddGeometry (wpfPath);
				wpfPath = newpath;
			}
			var en = wpfPath.Figures.GetEnumerator ();
			if (connect) {
				// merge current figure (if any) and first figure of new path, if they are not closed paths
				if (figure != null && !figure.IsClosed && en.MoveNext ()) {
					var firstFigure = en.Current;
					if (!firstFigure.IsClosed) {
						figure.Segments.Add (new swm.LineSegment (firstFigure.StartPoint, true));
						foreach (var seg in firstFigure.Segments)
							figure.Segments.Add (seg);
					} else {
						Control.Figures.Add (firstFigure);
					}
				}
			}
			swm.PathFigure pathFigure = null;
			while (en.MoveNext ()) {
				pathFigure = en.Current;
				Control.Figures.Add (pathFigure);
			}
			
			// continue with last figure of new path if not closed
			if (pathFigure != null && !pathFigure.IsClosed)
				figure = pathFigure;
			else
				figure = null;
		}
开发者ID:gene-l-thomas,项目名称:Eto,代码行数:37,代码来源:GraphicsPathHandler.cs

示例11: ConstructSteinterGeometry

        /// <summary>
        /// 构造steiner树的几何图形
        /// </summary>
        /// <param name="st">steinertree类</param>
        /// <param name="gm">GraphManager类</param>
        /// <param name="radius">每个点的半径</param>
        /// <param name="fontsize">每个点说明文字的大小</param>
        /// <returns>几何图形组。[0]为点集,[1]为边集</returns>
        public PathGeometry[] ConstructSteinterGeometry(SteinerTree st, GraphManager gm, int radius, int fontsize)
        {
            steinertreeShape = new PathGeometry();
            steinertreeLine = new PathGeometry();
            //i即要绘制的节点
            foreach (int i in st.steinerTreeNode)
            {
                steinertreeShape.AddGeometry(new EllipseGeometry((Point)gm.arrayPos.GetValue(i), radius, radius));
                Point ptext = new Point(((Point)gm.arrayPos.GetValue(i)).X - H_GAP, ((Point)gm.arrayPos.GetValue(i)).Y - V_GAP);
                steinertreeShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptext, fontsize).BuildGeometry());
            }
            //画线
            foreach (edge i in st.steinerTreeEdge)
            {
                steinertreeLine.AddGeometry(new LineGeometry((Point)gm.arrayPos.GetValue(i.x), (Point)gm.arrayPos.GetValue(i.y)));
            }

            return new PathGeometry[] { steinertreeShape, steinertreeLine };
        }
开发者ID:xmuliushuo,项目名称:learn,代码行数:27,代码来源:DataGraphGeometry.cs

示例12: ConstructGeometrySimple

        /// <summary>
        /// 从数据图构造几何图形
        /// </summary>
        /// <param name="gm">数据图GraphManager</param>
        /// <param name="radius">每個點的半徑</param>
        /// <param name="fontsize">字体大小</param>
        /// <returns></returns>
        public PathGeometry[] ConstructGeometrySimple(GraphManager gm, int radius, int fontsize)
        {
            #region 画点
            int PCount = 0;
            int ACount = 0;
            int WCount = 0;
            int CCount = 0;
            dataGraphShape = new PathGeometry();
            dataGraphLine = new PathGeometry();

            for (int i = 0; i < gm.nodeNum; i++)
            {
                if (gm.arrayKey.GetValue(i).ToString()[0] == 't')
                {
                    Point centerP = new Point(H_DIST * PCount + H_DIST, 2 * V_DIST);
                    dataGraphShape.AddGeometry(new EllipseGeometry(centerP, radius, radius));
                    gm.arrayPos.SetValue(new Point(H_DIST * PCount + H_DIST, 2 * V_DIST), i);
                    Point ptextP = new Point(H_DIST * PCount + H_DIST - H_GAP, 2 * V_DIST - V_GAP);
                    dataGraphShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptextP, fontsize).BuildGeometry());
                    PCount++;
                }
                if (gm.arrayKey.GetValue(i).ToString()[0] == 'a')
                {
                    Point centerA = new Point(H_DIST * ACount + H_DIST, 4 * V_DIST);
                    dataGraphShape.AddGeometry(new EllipseGeometry(centerA, radius, radius));
                    gm.arrayPos.SetValue(new Point(H_DIST * ACount + H_DIST, 4 * V_DIST), i);
                    Point ptextA = new Point(H_DIST * ACount + H_DIST - H_GAP, 4 * V_DIST - V_GAP);
                    dataGraphShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptextA, fontsize).BuildGeometry());
                    ACount++;
                }
                if (gm.arrayKey.GetValue(i).ToString()[0] == 'C')
                {
                    Point centerC = new Point(H_DIST * CCount + H_DIST, V_DIST);
                    dataGraphShape.AddGeometry(new EllipseGeometry(centerC, radius, radius));
                    gm.arrayPos.SetValue(new Point(H_DIST * CCount + H_DIST, V_DIST), i);
                    Point ptextC = new Point(H_DIST * CCount + H_DIST - H_GAP, V_DIST - V_GAP);
                    dataGraphShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptextC, fontsize).BuildGeometry());
                    CCount++;
                }
                if (gm.arrayKey.GetValue(i).ToString()[0] == 'W')
                {
                    Point centerW = new Point(H_DIST * WCount + H_DIST, 3 * V_DIST);
                    dataGraphShape.AddGeometry(new EllipseGeometry(centerW, radius, radius));
                    gm.arrayPos.SetValue(new Point(H_DIST * WCount + H_DIST, 3 * V_DIST), i);
                    Point ptextW = new Point(H_DIST * WCount + H_DIST - H_GAP, 3 * V_DIST - V_GAP);
                    dataGraphShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptextW, fontsize).BuildGeometry());
                    WCount++;
                }
            }
            #endregion

            #region 画线
            for (int i = 0; i < gm.nodeNum; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    if (gm.graph[i, j] == 1)
                    {
                        dataGraphLine.AddGeometry(new LineGeometry((Point)gm.arrayPos.GetValue(i), (Point)gm.arrayPos.GetValue(j)));
                    }
                }
            }
            #endregion

            return new PathGeometry[] { dataGraphShape, dataGraphLine };
        }
开发者ID:xmuliushuo,项目名称:learn,代码行数:73,代码来源:DataGraphGeometry.cs

示例13: BuildSpanGeometry

 private PathGeometry BuildSpanGeometry(SnapshotSpan span)
 {
     PathGeometry path = new PathGeometry();
       path.FillRule = FillRule.Nonzero;
       foreach ( var line in this.view.TextViewLines ) {
     if ( line.Start > span.End ) break;
     if ( LineIntersectsSpan(line, span) ) {
       var lineGeometry = BuildLineGeometry(span, line);
       path.AddGeometry(lineGeometry);
     }
       }
       return path;
 }
开发者ID:ssatta,项目名称:viasfora,代码行数:13,代码来源:RainbowHighlight.cs

示例14: GetTightBoundingGeometryFromTextPositions

        /// <summary>
        /// <see cref="TextViewBase.GetTightBoundingGeometryFromTextPositions"/>
        /// </summary>
        internal override Geometry GetTightBoundingGeometryFromTextPositions(ITextPointer startPosition, ITextPointer endPosition)
        {
            PathGeometry boundingGeometry = new PathGeometry();
            Debug.Assert(startPosition != null && this.Contains(startPosition));
            Debug.Assert(endPosition != null && this.Contains(endPosition));
            Dictionary<FixedPage, ArrayList> highlights = new Dictionary<FixedPage,ArrayList>();
            FixedTextPointer startftp = this.Container.VerifyPosition(startPosition);
            FixedTextPointer endftp = this.Container.VerifyPosition(endPosition);
            
            this.Container.GetMultiHighlights(startftp, endftp, highlights, FixedHighlightType.TextSelection, null, null);

            ArrayList highlightList;

            highlights.TryGetValue(this.FixedPage, out highlightList);

            if (highlightList != null)
            {
                foreach (FixedHighlight fh in highlightList)
                {
                    if (fh.HighlightType == FixedHighlightType.None)
                    {
                        continue;
                    }

                    Rect backgroundRect = fh.ComputeDesignRect();

                    if (backgroundRect == Rect.Empty)
                    {
                        continue;
                    }

                    GeneralTransform transform = fh.Element.TransformToAncestor(this.FixedPage);

                    Transform t = transform.AffineTransform;
                    if (t == null)
                    {
                        t = Transform.Identity;
                    }

                    Glyphs g = fh.Glyphs;

                    if (fh.Element.Clip != null)
                    {
                        Rect clipRect = fh.Element.Clip.Bounds;
                        backgroundRect.Intersect(clipRect);
                    }
                    
                    Geometry thisGeometry = new RectangleGeometry(backgroundRect);
                    thisGeometry.Transform = t;

                    backgroundRect = transform.TransformBounds(backgroundRect);

                    boundingGeometry.AddGeometry(thisGeometry);
                }
            }

            return boundingGeometry;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:61,代码来源:FixedTextView.cs

示例15: SizeGeometry

        public static void SizeGeometry(PathGeometry pg, Size size)
        {
            if (size.Height > 0 && size.Height > 0)
            {
                PathFigure[] sizeFigures =
                {
                    new PathFigure(new Point(size.Width, size.Height), Enumerable.Empty<PathSegment>(), true),
                    new PathFigure(new Point(0,0), Enumerable.Empty<PathSegment>(), true),
                };

                var newGeo = new PathGeometry(sizeFigures.Concat(pg.Figures), pg.FillRule, null);//pg.Transform do not add transform here, it will recalculate all the Points
                pg.Clear();
                pg.AddGeometry(newGeo);
                //return new PathGeometry(sizeFigures.Concat(pg.Figures), pg.FillRule, pg.Transform);
            }
        }
开发者ID:JuniperPhoton,项目名称:SvgToXAML,代码行数:16,代码来源:ConverterLogic.cs


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