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


C# Media.Geometry类代码示例

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


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

示例1: Read

        ///<summary>
        /// Converts a flat path to a <see cref="IGeometry"/>.
        ///</summary>
        /// <param name="pathIt">The path iterator of the path to convert</param>
        /// <returns>A Geometry representing the path</returns>
        public IGeometry Read(WpfGeometry pathIt)
        {
            var pathPtSeq = ToCoordinates(pathIt);

            var polys = new List<IGeometry>();
            var seqIndex = 0;
            while (seqIndex < pathPtSeq.Count)
            {
                // assume next seq is shell
                // TODO: test this
                var pts = pathPtSeq[seqIndex];
                var shell = _geometryFactory.CreateLinearRing(pts);
                seqIndex++;

                var holes = new List<ILinearRing>();
                Coordinate[] holePts;
                // add holes as long as rings are CCW
                while (seqIndex < pathPtSeq.Count && IsHole(holePts = pathPtSeq[seqIndex]))
                {
                    var hole = _geometryFactory.CreateLinearRing(holePts);
                    holes.Add(hole);
                    seqIndex++;
                }
                var holeArray = holes.ToArray();//GeometryFactory.ToLinearRingArray(holes);
                polys.Add(_geometryFactory.CreatePolygon(shell, holeArray));
            }
            return _geometryFactory.BuildGeometry(polys);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:33,代码来源:WpfGeometryReader.cs

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

示例3: DrawGeometry

        /// <summary>
        ///     DrawGeometry -
        ///     Draw a Geometry with the provided Brush and/or Pen.
        ///     If both the Brush and Pen are null this call is a no-op.
        /// </summary>
        /// <param name="brush">
        ///     The Brush with which to fill the Geometry.
        ///     This is optional, and can be null, in which case no fill is performed.
        /// </param>
        /// <param name="pen">
        ///     The Pen with which to stroke the Geometry.
        ///     This is optional, and can be null, in which case no stroke is performed.
        /// </param>
        /// <param name="geometry"> The Geometry to fill and/or stroke. </param>
        public override void DrawGeometry(
            Brush brush,
            Pen pen,
            Geometry geometry)
        {
            if (IsCurrentLayerNoOp ||(geometry == null) || geometry.IsEmpty())
            {
                return;
            }

            if (brush != null)
            {
                _contains |= geometry.FillContains(_point);
            }

            // If we have a pen and we haven't yet hit, try the widened geometry.
            if ((pen != null) && !_contains)
            {
                _contains |= geometry.StrokeContains(pen, _point);
            }

            // If we've hit, stop walking.
            if (_contains)
            {
                StopWalking();
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:41,代码来源:HitTestWithPointDrawingContextWalker.cs

示例4: GetPositionedCodeTag

 private UIElement GetPositionedCodeTag(ITextViewLine line, IWpfTextViewLineCollection textViewLines, Geometry geometry)
 {
     int lineNumber = _view.TextSnapshot.GetLineNumberFromPosition(line.Start.Position) + 1;
     UIElement codeTagElement = CodeLine.ElementAt(lineNumber, GetFilename);
     PlaceVisualNextToGeometry(geometry, codeTagElement);
     return codeTagElement;
 }
开发者ID:halllo,项目名称:MTSS12,代码行数:7,代码来源:CodeTagsEditorAdornment.cs

示例5: ConvertGeometry

        public static Telerik.Windows.Documents.Fixed.Model.Graphics.GeometryBase ConvertGeometry(Geometry geometry)
        {
#if SILVERLIGHT
            var cloner = new Telerik.Windows.Controls.GeometryCloneConverter();
            geometry = (Geometry)cloner.Convert(geometry, null, null, null);
#endif

            PathGeometry pathGeometry = geometry as PathGeometry;
            if (pathGeometry != null)
            {
                return ConvertPathGeometry(pathGeometry);
            }

            RectangleGeometry rectangleGeometry = geometry as RectangleGeometry;
            if (rectangleGeometry != null)
            {
                return ConvertRectangleGeometry(rectangleGeometry);
            }

            EllipseGeometry ellipseGeometry = geometry as EllipseGeometry;
            if (ellipseGeometry != null)
            {
                return ConvertEllipseGeometry(ellipseGeometry);
            }

#if WPF
            StreamGeometry streamGeometry = geometry as StreamGeometry;
            if (streamGeometry != null)
            {
                return ConvertStreamGeometry(streamGeometry);
            }
#endif

            return null;
        }
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:35,代码来源:PdfGeometryHelper.cs

示例6: MeasureOverride

        protected override Size MeasureOverride(Size constraint)
        {
            var midX = X1 + ((X2 - X1) / 2);

            _geometry = new PathGeometry
            {
                Figures =
                {
                    new PathFigure
                    {
                        IsFilled = false,
                        StartPoint = new Point(X1, Y1),
                        Segments =
                        {
                            new BezierSegment
                            {
                                Point1 = new Point(midX, Y1),
                                Point2 = new Point(midX, Y2),
                                Point3 = new Point(X2, Y2),
                                IsStroked = true
                            }
                        }
                    }
                }
            };

            return base.MeasureOverride(constraint);
        }
开发者ID:4ux-nbIx,项目名称:gemini,代码行数:28,代码来源:BezierLine.cs

示例7: UpdateMarkersVisual

 void UpdateMarkersVisual(Geometry geometry)
 {
     DrawingContext context = markers.RenderOpen();
     context.DrawRectangle(Brushes.Red, new Pen(Brushes.Red, 1), new Rect(30, 30, 30, 30));
     
     context.Close();
 }
开发者ID:goutkannan,项目名称:ironlab,代码行数:7,代码来源:MarkersVisualHost.cs

示例8: ScoreFromGeometries

 /// <summary>
 /// Calculates the score from the shape the players have to fill and their overall shadow.
 /// </summary>
 /// <param name="shapeToFill">The shape players have to fill.</param>
 /// <param name="peoplesShadows">The players' overall shadow.</param>
 /// <returns>The players' score.</returns>
 public int ScoreFromGeometries(Geometry shapeToFill, Geometry peoplesShadows)
 {
     double fillScore = Geometry.Combine(shapeToFill, peoplesShadows, GeometryCombineMode.Intersect, null).GetArea();
     double penalties = Geometry.Combine(peoplesShadows, shapeToFill, GeometryCombineMode.Exclude, null).GetArea();
     double score = fillScore * 15 - (penalties / 50);
     return score > 0 ? (int)score : 0;
 }
开发者ID:Cedric-Paris,项目名称:KinectGameShape,代码行数:13,代码来源:ScoreManager.cs

示例9: GetGraphics

        public override GraphicsResult GetGraphics(IWpfTextView view, Geometry geometry)
        {
            Initialize(view);

            // We clip off a bit off the start of the line to prevent a half-square being
            // drawn.
            var clipRectangle = geometry.Bounds;
            clipRectangle.Offset(2, 0);

            var line = new Line
            {
                X1 = geometry.Bounds.Left,
                Y1 = geometry.Bounds.Bottom - _graphicsTagPen.Thickness,
                X2 = geometry.Bounds.Right,
                Y2 = geometry.Bounds.Bottom - _graphicsTagPen.Thickness,
                Clip = new RectangleGeometry { Rect = clipRectangle }
            };
            // RenderOptions.SetEdgeMode(line, EdgeMode.Aliased);

            ApplyPen(line, _graphicsTagPen);

            // Shift the line over to offset the clipping we did.
            line.RenderTransform = new TranslateTransform(-_graphicsTagPen.Thickness, 0);
            return new GraphicsResult(line, null);
        }
开发者ID:TyOverby,项目名称:roslyn,代码行数:25,代码来源:SuggestionTag.cs

示例10: DrawGeometry

        //public void DrawEllipse(Brush brush, Pen pen, Point center, AnimationClock centerAnimations, double radiusX, AnimationClock radiusXAnimations, double radiusY, AnimationClock radiusYAnimations);

        public void DrawGeometry(Brush brush, Pen pen, Geometry geometry)
        {
            Path path = new Path();
            SetupShape(path, 0, 0, Double.NaN, Double.NaN, brush, pen);
            path.Data = geometry;
            ActiveCanvas.Children.Add(path);
        }
开发者ID:Sl0vi,项目名称:PDFsharp,代码行数:9,代码来源:AgDrawingContext.cs

示例11: PuzzlePiece

 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="pieceNumber">Which piece number this piece contains.</param>
 /// <param name="pieceShape">The shape of the pieces.</param>
 /// <param name="brush">The image and viewbox to use as this piece's visual.</param>
 public PuzzlePiece(int pieceNumber, Geometry pieceShape, VisualBrush brush) 
 {
     clipShape = pieceShape;
     imageBrush = brush;
     pieces = new HashSet<int>();
     pieces.Add(pieceNumber);
 }
开发者ID:AnthonyB28,项目名称:Marist_Map,代码行数:13,代码来源:PuzzlePiece.cs

示例12: CreateText

        /// <summary>
        /// Create the outline geometry based on the formatted text.
        /// </summary>
        public void CreateText()
        {
            FontStyle fontStyle = FontStyles.Normal;
            FontWeight fontWeight = FontWeights.Medium;

            if (Bold == true) fontWeight = FontWeights.Bold;
            if (Italic == true) fontStyle = FontStyles.Italic;

            // Create the formatted text based on the properties set.
            FormattedText formattedText = new FormattedText(
                Text,
                CultureInfo.GetCultureInfo("en-us"),
                FlowDirection.LeftToRight,
                new Typeface(Font, fontStyle, fontWeight, FontStretches.Normal),
                FontSize,
                Brushes.Black // This brush does not matter since we use the geometry of the text. 
                );

            // Build the geometry object that represents the text.
            _textGeometry = formattedText.BuildGeometry(new Point(0, 0));




            //set the size of the custome control based on the size of the text
            this.MinWidth = formattedText.Width;
            this.MinHeight = formattedText.Height;

        }
开发者ID:step4u,项目名称:CallService,代码行数:32,代码来源:OutlinedText.cs

示例13: GetGraphics

        /// <summary>
        /// Creates a very long line at the bottom of bounds.
        /// </summary>
        public override GraphicsResult GetGraphics(IWpfTextView view, Geometry bounds)
        {
            Initialize(view);

            var border = new Border()
            {
                BorderBrush = _graphicsTagBrush,
                BorderThickness = new Thickness(0, 0, 0, bottom: 1),
                Height = 1,
                Width = view.ViewportWidth
            };
            EventHandler viewportWidthChangedHandler = (s, e) =>
            {
                border.Width = view.ViewportWidth;
            };

            view.ViewportWidthChanged += viewportWidthChangedHandler;

            // Subtract rect.Height to ensure that the line separator is drawn
            // at the bottom of the line, rather than immediately below.
            // This makes the line separator line up with the outlining bracket.
            Canvas.SetTop(border, bounds.Bounds.Bottom - border.Height);

            return new GraphicsResult(border,
                () => view.ViewportWidthChanged -= viewportWidthChangedHandler);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:29,代码来源:LineSeparatorTag.cs

示例14: PointRelativeToOrigin

        public Point PointRelativeToOrigin(Geometry.Shapes.Point point)
        {
            m_Converter.GeometryPoint = point;
            m_Converter.Convert();

            return m_Converter.Point;
        }
开发者ID:tschroedter,项目名称:Selkie.WPF,代码行数:7,代码来源:PathSegmentHelper.cs

示例15: PostInfoDisplay

        public PostInfoDisplay(double textRightEdge,
            double viewRightEdge,
            Geometry newTextGeometry,
            string body)
        {
            if (brush == null)
            {
                brush = new SolidColorBrush(Color.FromArgb(0x20, 0x48, 0x3d, 0x8b));
                brush.Freeze();
                Brush penBrush = new SolidColorBrush(Colors.DarkSlateBlue);
                penBrush.Freeze();
                solidPen = new Pen(penBrush, 0.5);
                solidPen.Freeze();
                dashPen = new Pen(penBrush, 0.5);
                dashPen.DashStyle = DashStyles.Dash;
                dashPen.Freeze();
            }

            this.textGeometry = newTextGeometry;

            TextBlock tb = new TextBlock();
            tb.Text = "Blog Entry: " + body;

            const int MarginWidth = 8;
            this.postGrid = new Grid();
            this.postGrid.RowDefinitions.Add(new RowDefinition());
            this.postGrid.RowDefinitions.Add(new RowDefinition());
            ColumnDefinition cEdge = new ColumnDefinition();
            cEdge.Width = new GridLength(MarginWidth);
            ColumnDefinition cEdge2 = new ColumnDefinition();
            cEdge2.Width = new GridLength(MarginWidth);
            this.postGrid.ColumnDefinitions.Add(cEdge);
            this.postGrid.ColumnDefinitions.Add(new ColumnDefinition());
            this.postGrid.ColumnDefinitions.Add(cEdge2);

            System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle();
            rect.RadiusX = 6;
            rect.RadiusY = 3;
            rect.Fill = brush;
            rect.Stroke = Brushes.DarkSlateBlue;

            Size inf = new Size(double.PositiveInfinity, double.PositiveInfinity);
            tb.Measure(inf);
            this.postGrid.Width = tb.DesiredSize.Width + 2 * MarginWidth;

            Grid.SetColumn(rect, 0);
            Grid.SetRow(rect, 0);
            Grid.SetRowSpan(rect, 1);
            Grid.SetColumnSpan(rect, 3);
            Grid.SetRow(tb, 0);
            Grid.SetColumn(tb, 1);
            this.postGrid.Children.Add(rect);
            this.postGrid.Children.Add(tb);

            Canvas.SetLeft(this.postGrid, Math.Max(viewRightEdge - this.postGrid.Width - 20.0, textRightEdge + 20.0));
            Canvas.SetTop(this.postGrid, textGeometry.GetRenderBounds(solidPen).Top);

            this.Children.Add(this.postGrid);
        }
开发者ID:detroitpro,项目名称:ProStudioSearch,代码行数:59,代码来源:PostInfoDisplay.cs


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