public static void Draw(Canvas canvas, List<LinePoint> points, Brush stroke, bool clear = true) { if (clear) { canvas.Children.Clear(); } PathFigureCollection myPathFigureCollection = new PathFigureCollection(); PathGeometry myPathGeometry = new PathGeometry(); foreach (LinePoint p in points) { PathFigure myPathFigure = new PathFigure(); myPathFigure.StartPoint = p.StartPoint; LineSegment myLineSegment = new LineSegment(); myLineSegment.Point = p.EndPoint; PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); myPathSegmentCollection.Add(myLineSegment); myPathFigure.Segments = myPathSegmentCollection; myPathFigureCollection.Add(myPathFigure); } myPathGeometry.Figures = myPathFigureCollection; Path myPath = new Path(); myPath.Stroke = stroke == null ? Brushes.Black : stroke; myPath.StrokeThickness = 1; myPath.Data = myPathGeometry; canvas.Children.Add(myPath); }
private void DrawGridLines(double width, double height, double overhangX, double overhangY, double spacingX = 10, double spacingY = 10) { if (width == 0 || height == 0) { return; } PathFigureCollection myPathFigureCollection = new PathFigureCollection(); //horizontal var max = ((height + overhangY) / spacingY); for (int y = 0; y < max; y++) { var yPos = y * spacingY; LineSegment myLineSegment = new LineSegment(); PathFigure myPathFigure = new PathFigure(); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); myPathFigure.StartPoint = new Point(0, yPos); myLineSegment.Point = new Point(width + overhangX, yPos); myPathSegmentCollection.Add(myLineSegment); myPathFigure.Segments = myPathSegmentCollection; if (y > 0 && y < max - 1) { myPathFigureCollection.Add(myPathFigure); } } //vertical max = ((width + overhangX) / spacingX); for (int x = 0; x < max; x++) { var xPos = x * spacingX; LineSegment myLineSegment = new LineSegment(); PathFigure myPathFigure = new PathFigure(); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); myPathFigure.StartPoint = new Point(xPos, 0); myLineSegment.Point = new Point(xPos, height + overhangY); myPathSegmentCollection.Add(myLineSegment); myPathFigure.Segments = myPathSegmentCollection; if (x > 0 && x < max - 1) { myPathFigureCollection.Add(myPathFigure); } } PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; pthGridLines.Stroke = new SolidColorBrush(Colors.CornflowerBlue); pthGridLines.StrokeThickness = 1; pthGridLines.Data = myPathGeometry; }
private Path TwoPathFigures() { // <Snippet38> PathFigure myPathFigure1 = new PathFigure(); myPathFigure1.StartPoint = new Point(10, 100); myPathFigure1.IsClosed = true; LineSegment myLineSegment1 = new LineSegment(); myLineSegment1.Point = new Point(100, 100); LineSegment myLineSegment2 = new LineSegment(); myLineSegment2.Point = new Point(100, 50); PathFigure myPathFigure2 = new PathFigure(); myPathFigure2.StartPoint = new Point(10, 10); myPathFigure2.IsClosed = true; LineSegment myLineSegment3 = new LineSegment(); myLineSegment3.Point = new Point(100, 10); LineSegment myLineSegment4 = new LineSegment(); myLineSegment4.Point = new Point(100, 40); PathSegmentCollection myPathSegmentCollection1 = new PathSegmentCollection(); myPathSegmentCollection1.Add(myLineSegment1); myPathSegmentCollection1.Add(myLineSegment2); myPathFigure1.Segments = myPathSegmentCollection1; PathSegmentCollection myPathSegmentCollection2 = new PathSegmentCollection(); myPathSegmentCollection2.Add(myLineSegment3); myPathSegmentCollection2.Add(myLineSegment4); myPathFigure2.Segments = myPathSegmentCollection2; PathFigureCollection myPathFigureCollection = new PathFigureCollection(); myPathFigureCollection.Add(myPathFigure1); myPathFigureCollection.Add(myPathFigure2); PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; Path myPath = new Path(); myPath.Stroke = Brushes.Black; myPath.StrokeThickness = 1; myPath.Data = myPathGeometry; // </Snippet38> return(myPath); }
/// <summary> /// Allows to draw the subtype menu button. /// </summary> protected void drawSubtypeMenubButton() { // The radius of the circumcercle. double radius = Math.Sqrt(height * height + width * width) / 2; PathFigureCollection segmentPathFigureCollection = new PathFigureCollection(); // more's horizontal line PathSegmentCollection pathSegmentCollection = new PathSegmentCollection(); PathFigure segmentPathFigure1 = new PathFigure(); Point StartPoint = PointOnCircle(radius, 90 - 4, new Point(0, 0)); Point lineStopPoint1 = PointOnCircle(radius, 90 + 4, new Point(0, 0)); segmentPathFigure1.StartPoint = StartPoint; LineSegment lineSegment1 = new LineSegment(lineStopPoint1, true); pathSegmentCollection.Add(lineSegment1); segmentPathFigure1.Segments = pathSegmentCollection; segmentPathFigureCollection.Add(segmentPathFigure1); // more's vertical line pathSegmentCollection = new PathSegmentCollection(); PathFigure segmentPathFigure2 = new PathFigure(); StartPoint = PointOnCircle(radius - 4, 90, new Point(0, 0)); lineStopPoint1 = PointOnCircle(radius + 4, 90, new Point(0, 0)); segmentPathFigure2.StartPoint = StartPoint; lineSegment1 = new LineSegment(lineStopPoint1, true); pathSegmentCollection.Add(lineSegment1); segmentPathFigure2.Segments = pathSegmentCollection; segmentPathFigureCollection.Add(segmentPathFigure2); // button's cercle EllipseGeometry ellipseGeometry = new EllipseGeometry(PointOnCircle(radius, 90, new Point(0, 0)), 7, 7); PathGeometry segmentPathGeometry = new PathGeometry(); segmentPathGeometry.Figures = segmentPathFigureCollection; segmentPathGeometry.AddGeometry(ellipseGeometry); // Set up the segment's drawing (and hit-testing) path and its Tag. subtypesMenuButton = new Path(); subtypesMenuButton.Data = segmentPathGeometry; subtypesMenuButton.Stroke = Brushes.Black; subtypesMenuButton.StrokeThickness = 1; subtypesMenuButton.Fill = Brushes.White; Canvas.SetLeft(subtypesMenuButton, x); Canvas.SetTop(subtypesMenuButton, y); Canvas.SetZIndex(subtypesMenuButton, 1); Canvas.Children.Add(subtypesMenuButton); // adding an handler (for debugging only) subtypesMenuButton.MouseDown += new MouseButtonEventHandler(subtypesMenuButton_MouseDown); }
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Debug.Assert(values != null && values.Length == 9, "EdgeRouteToPathConverter should have 10 parameters: pos (1,2), size (3,4) of source; pos (5,6), size (7,8) of target; Tag (9)."); #region Get the inputs //get the position of the source Point sourcePos = new Point() { X = (values[0] != DependencyProperty.UnsetValue ? (double)values[0] : 0.0), Y = (values[1] != DependencyProperty.UnsetValue ? (double)values[1] : 0.0) }; //get the size of the source Size sourceSize = new Size() { Width = (values[2] != DependencyProperty.UnsetValue ? (double)values[2] : 0.0), Height = (values[3] != DependencyProperty.UnsetValue ? (double)values[3] : 0.0) }; //get the position of the target Point targetPos = new Point() { X = (values[4] != DependencyProperty.UnsetValue ? (double)values[4] : 0.0), Y = (values[5] != DependencyProperty.UnsetValue ? (double)values[5] : 0.0) }; //get the size of the target Size targetSize = new Size() { Width = (values[6] != DependencyProperty.UnsetValue ? (double)values[6] : 0.0), Height = (values[7] != DependencyProperty.UnsetValue ? (double)values[7] : 0.0) }; object tag = values[8]; #endregion // // Create the path // Point p1 = GraphConverterHelper.CalculateAttachPoint(sourcePos, sourceSize, targetPos); Point p2 = GraphConverterHelper.CalculateAttachPoint(targetPos, targetSize, sourcePos); var length = (p2 - p1).Length; Vector v = p1 - p2; v = v / v.Length * 10; Vector n = new Vector(-v.Y, v.X) * 0.5; PathFigureCollection pfc = new PathFigureCollection(2); pfc.Add(new PathFigure(p1, new[] { new ArcSegment(p2 + v, new Size(length, length), 0, false, SweepDirection.Clockwise, true) }, false)); pfc.Add(new PathFigure(p2, new[] { new LineSegment(p2 + v - n, true), new LineSegment(p2 + v + n, true) }, true)); return(pfc); }
public Path Poligon()//построение полигона { PathFigure pathFigure = new PathFigure(); PathSegmentCollection segmentCollection = new PathSegmentCollection(); PathFigureCollection figureCollection = new PathFigureCollection(); for (int i = 0; i < myPoligon.Length; i++)//построение полигона { if (i == 0) { pathFigure.StartPoint = new Point(myPoligon[i].X, myPoligon[i].Y); } else { LineSegment line = new LineSegment(); line.Point = new Point(myPoligon[i].X, myPoligon[i].Y); segmentCollection.Add(line);//добавление линий полигона в колекцию } } pathFigure.Segments = segmentCollection; figureCollection.Add(pathFigure);//добавление полигона PathFigure pathFigureBinding = new PathFigure(); PathSegmentCollection segmentCollectionBinding = new PathSegmentCollection(); for (int i = 0; i < myBinding.Length; i++)//построение привязки { if (i == 0) { pathFigureBinding.StartPoint = new Point(myBinding[i].X, myBinding[i].Y); } else { LineSegment line = new LineSegment(); line.Point = new Point(myBinding[i].X, myBinding[i].Y); segmentCollectionBinding.Add(line);//добавление линий привязки в колекцию } } pathFigureBinding.Segments = segmentCollectionBinding; figureCollection.Add(pathFigureBinding); PathGeometry geometry = new PathGeometry(); geometry.Figures = figureCollection; Path path = new Path();//последовательноть линий path.Stroke = Brushes.Black;//цвет линии path.StrokeThickness = 1; //толшина линии path.Data = geometry; return path;//возврат полигона }
async public override void HandleDown(object arg) { if (!(arg is Point)) { return; } _lastPointSet = false; points = new List <Point>(); var coordinate = (Point)arg; await pixelData.preparePaintingAreaCanvasPixel(); initPathInstances(); initPathStrokeSettings(); _pathFigure.StartPoint = coordinate; _pathFigure.Segments = _pathSegmentCollection; _pathFigureCollection.Add(_pathFigure); _pathGeometry.Figures = _pathFigureCollection; _lastPoint = coordinate; _path.Data = _pathGeometry; PocketPaintApplication.GetInstance().PaintingAreaView.addElementToEraserCanvas(_path); var rectangleGeometry = new RectangleGeometry { Rect = new Rect(0, 0, PocketPaintApplication.GetInstance().PaintingAreaCanvas.ActualWidth, PocketPaintApplication.GetInstance().PaintingAreaCanvas.ActualHeight) }; _path.Clip = rectangleGeometry; _path.InvalidateArrange(); _path.InvalidateMeasure(); }
internal void DrawBezier(double thickness, Color color, Point startPoint, Point controlPoint, Point endPoint) { PathFigure myPathFigure = new PathFigure(); myPathFigure.StartPoint = startPoint; BezierSegment myBezierSegment = new BezierSegment(startPoint, endPoint, controlPoint, true); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); myPathSegmentCollection.Add(myBezierSegment); myPathFigure.Segments = myPathSegmentCollection; PathFigureCollection myPathFigureCollection = new PathFigureCollection(); myPathFigureCollection.Add(myPathFigure); PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; DrawingContext drawingContext = drawingVisual.RenderOpen(); mySolidColorBrush.Color = color; //ApplyColortool(color.A); pen.Brush = mySolidColorBrush; pen.Thickness = thickness; drawingContext.DrawGeometry(null, pen, myPathGeometry); drawingContext.Close(); image.Render(drawingVisual); }
public void Sample() { PathFigure myPathFigure = new PathFigure(); myPathFigure.StartPoint = new Point(10, 50); LineSegment myLineSegment = new LineSegment(); myLineSegment.Point = new Point(200, 70); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); myPathSegmentCollection.Add(myLineSegment); myPathFigure.Segments = myPathSegmentCollection; PathFigureCollection myPathFigureCollection = new PathFigureCollection(); myPathFigureCollection.Add(myPathFigure); PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; Path myPath = new Path(); myPath.Stroke = Brushes.Black; myPath.StrokeThickness = 1; myPath.Data = myPathGeometry; }
private Path SimpleQuadraticBezierLine() { // <Snippet34> PathFigure myPathFigure = new PathFigure(); myPathFigure.StartPoint = new Point(10, 100); QuadraticBezierSegment myQuadraticBezierSegment = new QuadraticBezierSegment(); myQuadraticBezierSegment.Point1 = new Point(200, 200); myQuadraticBezierSegment.Point2 = new Point(300, 100); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); myPathSegmentCollection.Add(myQuadraticBezierSegment); myPathFigure.Segments = myPathSegmentCollection; PathFigureCollection myPathFigureCollection = new PathFigureCollection(); myPathFigureCollection.Add(myPathFigure); PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; Path myPath = new Path(); myPath.Stroke = Brushes.Black; myPath.StrokeThickness = 1; myPath.Data = myPathGeometry; // </Snippet34> return(myPath); }
private void AddCircularArcGraph(Point startPoint, Point endPoint, Size size) { PathFigure pf = new PathFigure(); pf.StartPoint = new Point(startPoint.X, startPoint.Y); ArcSegment arcSegment = new ArcSegment(); arcSegment.Point = new Point(endPoint.X, endPoint.Y); arcSegment.Size = size; arcSegment.SweepDirection = SweepDirection.Counterclockwise; PathSegmentCollection psc = new PathSegmentCollection(); psc.Add(arcSegment); pf.Segments = psc; PathFigureCollection pfc = new PathFigureCollection(); pfc.Add(pf); PathGeometry pg = new PathGeometry(); pg.Figures = pfc; var path = new Path(); path.Stroke = Brushes.Black; path.StrokeThickness = 1; path.Data = pg; path.Fill = Brushes.Orange; path.Stretch = Stretch.Fill; var viewportPanel = new ViewportHostPanel(); ViewportPanel.SetViewportBounds(path, new DataRect(0, 0, 50, 50)); viewportPanel.Children.Add(path); plotter.Children.Add(viewportPanel); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var readings = (List <TemperatureReading>)value; var figures = new PathFigureCollection(); var cleanHistory = readings.Where(r => !double.IsNegativeInfinity(r.Temperature)); if (cleanHistory.Count() > 0) { var startTime = cleanHistory.First().Time; var endTime = cleanHistory.Last().Time; var dataHeight = GraphSettings.Max - GraphSettings.Min; var dataWidth = (int)(endTime - startTime).TotalSeconds; var points = new PointCollection(cleanHistory.Select(r => new Point(((r.Time - startTime).TotalSeconds / dataWidth) * GraphSettings.Width, (1 - ((r.Temperature - GraphSettings.Min) / dataHeight)) * GraphSettings.Height))); var figure = new PathFigure() { StartPoint = points.First() }; figure.Segments.Add(new PolyLineSegment(points, true)); figures.Add(figure); } return(figures); }
private Geometry GetDefaultGlyph() { double x1 = columnHeader.ActualWidth - 13; double x2 = x1 + 10; double x3 = x1 + 5; double y1 = (columnHeader.ActualHeight / 2) - 3; double y2 = y1 + 5; if (direction == ListSortDirection.Ascending) { double tmp = y1; y1 = y2; y2 = tmp; } PathSegmentCollection pathSegmentCollection = new PathSegmentCollection { new LineSegment(new Point(x2, y1), true), new LineSegment(new Point(x3, y2), true) }; PathFigure pathFigure = new PathFigure(new Point(x1, y1), pathSegmentCollection, true); PathFigureCollection pathFigureCollection = new PathFigureCollection(); pathFigureCollection.Add(pathFigure); PathGeometry pathGeometry = new PathGeometry(pathFigureCollection); return(pathGeometry); }
private Path[] getLips3() { Path[] lipsParts = new Path[1]; LineSegment line1 = new LineSegment(new Point(CentrePoint.X + Radius * 0.5, CentrePoint.Y + Radius * 0.4), true); PathFigure pathFigure = new PathFigure(); pathFigure.StartPoint = new Point(CentrePoint.X - Radius * 0.5, CentrePoint.Y + Radius * 0.4); pathFigure.Segments.Add(line1); PathFigureCollection pathFigureCollection = new PathFigureCollection(); pathFigureCollection.Add(pathFigure); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures = pathFigureCollection; lipsParts[0] = new Path(); lipsParts[0].Data = pathGeometry; lipsParts[0].StrokeThickness = Radius * 0.1; lipsParts[0].Stroke = new SolidColorBrush(Colors.Black); lipsParts[0].Fill = new SolidColorBrush(Colors.Black); return(lipsParts); }
private Geometry GetDefaultGlyph() { var x1 = _columnHeader.ActualWidth - 13; var x2 = x1 + 10; var x3 = x1 + 5; var y1 = _columnHeader.ActualHeight / 2 - 3; var y2 = y1 + 5; if (_direction == ListSortDirection.Ascending) { var tmp = y1; y1 = y2; y2 = tmp; } var pathSegmentCollection = new PathSegmentCollection(); pathSegmentCollection.Add(new LineSegment(new Point(x2, y1), true)); pathSegmentCollection.Add(new LineSegment(new Point(x3, y2), true)); var pathFigure = new PathFigure(new Point(x1, y1), pathSegmentCollection, true); var pathFigureCollection = new PathFigureCollection(); pathFigureCollection.Add(pathFigure); var pathGeometry = new PathGeometry(pathFigureCollection); return(pathGeometry); }
public override Path getPath() { if (path.Data == null) { PathFigure myPathFigure = new PathFigure(); myPathFigure.StartPoint = new Point(start.x, start.y); LineSegment myLineSegment = new LineSegment(); myLineSegment.Point = new Point(finish.x, finish.y); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); myPathSegmentCollection.Add(myLineSegment); myPathFigure.Segments = myPathSegmentCollection; PathFigureCollection myPathFigureCollection = new PathFigureCollection(); myPathFigureCollection.Add(myPathFigure); PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; path.Stroke = Brushes.Black; path.StrokeThickness = 1; path.Data = myPathGeometry; } return(path); }
public void Draw(EasingFunctionBase easingFunction) { canvas1.Children.Clear(); PathSegmentCollection pathSegments = new PathSegmentCollection(); for (double i = 0; i < 1; i += _samplingInterval) { double x = i * canvas1.Width; double y = easingFunction.Ease(i) * canvas1.Height; var segment = new LineSegment(); segment.Point = new Point(x, y); pathSegments.Add(segment); } var p = new Path(); p.Stroke = new SolidColorBrush(Colors.Black); p.StrokeThickness = 3; PathFigureCollection figures = new PathFigureCollection(); figures.Add(new PathFigure() { Segments = pathSegments }); p.Data = new PathGeometry() { Figures = figures }; canvas1.Children.Add(p); }
private void drawDiamond() { PathFigure myPathFigure = new PathFigure(); myPathFigure.StartPoint = new Point(160 - 15 * Width, 30); LineSegment LineSegment1 = new LineSegment(); LineSegment LineSegment2 = new LineSegment(); LineSegment LineSegment3 = new LineSegment(); LineSegment LineSegment4 = new LineSegment(); LineSegment1.Point = new Point(320 - 30 * Width, 0); LineSegment2.Point = new Point(160 - 15 * Width, -30); LineSegment3.Point = new Point(0, 0); LineSegment4.Point = new Point(160 - 15 * Width, 30); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); myPathSegmentCollection.Add(LineSegment1); myPathSegmentCollection.Add(LineSegment2); myPathSegmentCollection.Add(LineSegment3); myPathSegmentCollection.Add(LineSegment4); myPathFigure.Segments = myPathSegmentCollection; PathFigureCollection myPathFigureCollection = new PathFigureCollection(); myPathFigureCollection.Add(myPathFigure); PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; PathData = myPathGeometry.ToString().Replace(',', '.').Replace(';', ','); }
private PathGeometry GetPath(Point start, Point end) { var pathFigure = new PathFigure() { StartPoint = start }; var segment = new BezierSegment() { Point1 = new Point((end.X - start.X) * 0.6 + start.X, start.Y), Point2 = new Point((end.X - start.X) * 0.4 + start.X, end.Y), Point3 = end }; //var segment = new LineSegment() { Point = end }; var pathSegmentCollection = new PathSegmentCollection(); pathSegmentCollection.Add(segment); pathFigure.Segments = pathSegmentCollection; var pathFigureCollection = new PathFigureCollection(); pathFigureCollection.Add(pathFigure); return(new PathGeometry() { Figures = pathFigureCollection }); }
private void Show_Click(object sender, RoutedEventArgs e) { if (curveButtonPressed && points.Count > 1) { PathFigure pthFigure = new PathFigure(); pthFigure.StartPoint = points[0]; PolyBezierSegment pbzSeg = new PolyBezierSegment(); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); if (points.Count == 2) { pbzSeg.Points.Add(points[1]); pbzSeg.Points.Add(points[1]); pbzSeg.Points.Add(points[1]); } else if (points.Count == 3) { pbzSeg.Points.Add(points[1]); pbzSeg.Points.Add(points[2]); pbzSeg.Points.Add(points[2]); } else if (points.Count % 3 == 1) { for (int i = 1; i < points.Count; i++) { pbzSeg.Points.Add(points[i]); } } else { for (int i = 1; i < points.Count; i++) { pbzSeg.Points.Add(points[i]); } pbzSeg.Points.Add(points[points.Count - 1]); if (points.Count % 3 == 2) { pbzSeg.Points.Add(points[points.Count - 1]); } } myPathSegmentCollection.Add(pbzSeg); pthFigure.Segments = myPathSegmentCollection; PathFigureCollection pthFigureCollection = new PathFigureCollection(); pthFigureCollection.Add(pthFigure); PathGeometry pthGeometry = new PathGeometry(); pthGeometry.Figures = pthFigureCollection; Path arcPath = new Path(); arcPath.Stroke = new SolidColorBrush(Colors.Black); arcPath.StrokeThickness = 3; arcPath.Data = pthGeometry; //arcPath.Fill = new SolidColorBrush(Colors.Yellow); PaintGrid.Children.Add(arcPath); points.Clear(); } }
private void Path_Click(object sender, RoutedEventArgs e) { path.Stroke = Brushes.Black; path.StrokeThickness = 1; BezierSegment bezierCurve1 = new BezierSegment(new Point(0, 0), new Point(0, 50), new Point(50, 90), true); BezierSegment bezierCurve2 = new BezierSegment(new Point(200, -70), new Point(100, 0), new Point(50, 30), true); PathSegmentCollection psc = new PathSegmentCollection(); psc.Add(bezierCurve1); psc.Add(bezierCurve2); PathFigure pf = new PathFigure(); pf.Segments = psc; pf.StartPoint = new Point(50, 30); PathFigureCollection pfc = new PathFigureCollection(); pfc.Add(pf); PathGeometry pg = new PathGeometry(); pg.Figures = pfc; GeometryGroup pathGeometryGroup = new GeometryGroup(); pathGeometryGroup.Children.Add(pg); path.Data = pathGeometryGroup; path.Margin = new Thickness(480, 450, 0, 0); Path.MouseEnter += PaMouseEnter; Scene.Children.Add(path); }
public override Path draw() { Path path = new Path(); PathFigure figure = new PathFigure(); PathGeometry geometry = new PathGeometry(); PathFigureCollection collection = new PathFigureCollection(); figure.StartPoint = ViewerHelper.mapToWPF(vertices[0], parent); foreach (Point vertex in vertices) { figure.Segments.Add(new LineSegment(ViewerHelper.mapToWPF(vertex, parent), true)); } figure.IsClosed = false; collection.Add(figure); geometry.Figures = collection; path.Data = geometry; Binding bind = new Binding(); bind.Source = viewer; bind.Path = new PropertyPath("LineThickness"); path.SetBinding(Path.StrokeThicknessProperty, bind); Brush brush = new SolidColorBrush(ViewerHelper.getColor(layer.lineColor)); path.Stroke = brush; if (arrow) { viewer.mainCanvas.Children.Add(getArrowPath(brush, bind)); } return(path); }
public void Refresh() { var line = this; var pathGeometry1 = new PathGeometry(); var pathFigureCollection1 = new PathFigureCollection(); var pathFigure1 = new PathFigure(); pathFigure1.IsClosed = false; pathFigure1.StartPoint = new Windows.Foundation.Point(line.from_point.X, line.from_point.Y); pathFigureCollection1.Add(pathFigure1); pathGeometry1.Figures = pathFigureCollection1; var pathSegmentCollection1 = new PathSegmentCollection(); var pathSegment1 = new BezierSegment(); pathSegment1.Point1 = new Point(line.from_point.X + 200, line.from_point.Y); pathSegment1.Point2 = new Point(line.to_point.X - 200, line.to_point.Y); pathSegment1.Point3 = new Point(line.to_point.X, line.to_point.Y); pathSegmentCollection1.Add(pathSegment1); pathFigure1.Segments = pathSegmentCollection1; line.UIPath.Data = pathGeometry1; }
public override Path getRendering() { PathFigure myPathFigure = new PathFigure(); myPathFigure.StartPoint = points[0]; PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); for (int i = 1; i < points.Count; i++) { LineSegment myLineSegment = new LineSegment(); myLineSegment.Point = points[i]; myPathSegmentCollection.Add(myLineSegment); } myPathFigure.Segments = myPathSegmentCollection; PathFigureCollection myPathFigureCollection = new PathFigureCollection(); myPathFigureCollection.Add(myPathFigure); PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; Path myPath = new Path(); SolidColorBrush scb = new SolidColorBrush(this.getColor()); myPath.Stroke = scb; myPath.StrokeThickness = this.getThickness(); myPath.Data = myPathGeometry; return(myPath); }
private Path[] getMustache3() { Path[] mustacheParts = new Path[1]; BezierSegment bezierSegment1 = new BezierSegment( new Point(CentrePoint.X - Radius * 0.4, CentrePoint.Y + Radius * 0.2), new Point(CentrePoint.X, CentrePoint.Y - Radius * 0.2), new Point(CentrePoint.X + Radius * 0.4, CentrePoint.Y + Radius * 0.2), true ); LineSegment line1 = new LineSegment(new Point(CentrePoint.X - Radius * 0.4, CentrePoint.Y + Radius * 0.2), true); PathFigure pathFigure = new PathFigure(); pathFigure.StartPoint = new Point(CentrePoint.X - Radius * 0.4, CentrePoint.Y + Radius * 0.2); pathFigure.Segments.Add(bezierSegment1); pathFigure.Segments.Add(line1); PathFigureCollection pathFigureCollection = new PathFigureCollection(); pathFigureCollection.Add(pathFigure); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures = pathFigureCollection; mustacheParts[0] = new Path(); mustacheParts[0].Data = pathGeometry; mustacheParts[0].StrokeThickness = strokeThickness; mustacheParts[0].Stroke = new SolidColorBrush(Colors.Black); mustacheParts[0].Fill = new SolidColorBrush(Colors.Brown); return(mustacheParts); }
private Path SimpleLine() { // <SnippetPathGeometryLineSegmentInline> PathFigure myPathFigure = new PathFigure(); myPathFigure.StartPoint = new Point(10, 50); LineSegment myLineSegment = new LineSegment(); myLineSegment.Point = new Point(200, 70); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); myPathSegmentCollection.Add(myLineSegment); myPathFigure.Segments = myPathSegmentCollection; PathFigureCollection myPathFigureCollection = new PathFigureCollection(); myPathFigureCollection.Add(myPathFigure); PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; Path myPath = new Path(); myPath.Stroke = Brushes.Black; myPath.StrokeThickness = 1; myPath.Data = myPathGeometry; // </SnippetPathGeometryLineSegmentInline> return(myPath); }
private Path[] getEyes3() { Path[] eyeParts = new Path[3]; eyeParts[0] = new Path(); eyeParts[0].Data = new EllipseGeometry(new Point(CentrePoint.X - Radius * 0.3, CentrePoint.Y - Radius * 0.5), Radius * 0.3, Radius * 0.4); eyeParts[0].StrokeThickness = strokeThickness; eyeParts[0].Stroke = new SolidColorBrush(Colors.Black); eyeParts[0].Fill = new SolidColorBrush(Colors.White); eyeParts[1] = new Path(); eyeParts[1].Data = new EllipseGeometry(new Point(CentrePoint.X - Radius * 0.25, CentrePoint.Y - Radius * 0.4), Radius * 0.2, Radius * 0.25); eyeParts[1].StrokeThickness = strokeThickness; eyeParts[1].Stroke = new SolidColorBrush(Colors.Black); eyeParts[1].Fill = new SolidColorBrush(Colors.Black); BezierSegment bezierSegment1 = new BezierSegment( new Point(CentrePoint.X + Radius * 0.1, CentrePoint.Y - Radius * 0.15), new Point(CentrePoint.X + Radius * 0.4, CentrePoint.Y - Radius * 0.7), new Point(CentrePoint.X + Radius * 0.7, CentrePoint.Y - Radius * 0.4), false ); BezierSegment bezierSegment2 = new BezierSegment( new Point(CentrePoint.X + Radius * 0.7, CentrePoint.Y - Radius * 0.4), new Point(CentrePoint.X + Radius * 0.4, CentrePoint.Y - Radius * 0.5), new Point(CentrePoint.X + Radius * 0.15, CentrePoint.Y - Radius * 0.15), false ); BezierSegment bezierSegment3 = new BezierSegment( new Point(CentrePoint.X + Radius * 0.15, CentrePoint.Y - Radius * 0.17), new Point(CentrePoint.X + Radius * 0.3, CentrePoint.Y - Radius * 0.3), new Point(CentrePoint.X + Radius * 0.6, CentrePoint.Y - Radius * 0.25), false ); PathFigure pathFigure = new PathFigure(); pathFigure.StartPoint = new Point(CentrePoint.X + Radius * 0.1, CentrePoint.Y - Radius * 0.15); pathFigure.Segments.Add(bezierSegment1); pathFigure.Segments.Add(bezierSegment2); pathFigure.Segments.Add(bezierSegment3); PathFigureCollection pathFigureCollection = new PathFigureCollection(); pathFigureCollection.Add(pathFigure); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures = pathFigureCollection; eyeParts[2] = new Path(); eyeParts[2].Data = pathGeometry; eyeParts[2].StrokeThickness = strokeThickness; eyeParts[2].Stroke = new SolidColorBrush(Colors.Black); eyeParts[2].Fill = new SolidColorBrush(Colors.Black); return(eyeParts); }
/// <summary> /// 刷新显示指定的图形元素 /// </summary> public override void Update() { if (Start != null && Central != null && End == null) { this.DashStyle = new System.Windows.Media.DashStyle(new double[] { 5, 5 }, 10); DrawingContext dc = this.RenderOpen(); Pen.Freeze(); //冻结画笔,这样能加快绘图速度 List <Vector2D> vs = new List <Vector2D>() { Start, Central }; this.Draw(vs); } else if (Start != null && Central != null && End != null) { //冻结画笔,这样能加快绘图速度 DrawingContext dc = this.RenderOpen(); Pen.Freeze(); ArcSegment arc = new ArcSegment(); var len = this.Central.Distance(this.start); arc.IsLargeArc = false; arc.Size = new System.Windows.Size(KernelProperty.MMToPix(len), KernelProperty.MMToPix(len)); arc.Point = KernelProperty.MMToPix(this.end); PathGeometry paths = new PathGeometry(); PathFigureCollection pfc = new PathFigureCollection(); PathFigure pf = new PathFigure(); pfc.Add(pf); pf.StartPoint = KernelProperty.MMToPix(this.start); pf.Segments.Add(arc); paths.Figures = pfc; dc.DrawGeometry(Brush, Pen, paths); dc.Close(); } }
public static PathGeometry GetTrianglePathGeometry(Point[] pts) { System.Windows.Media.LineSegment lineSeg0 = new System.Windows.Media.LineSegment(pts[1], true); System.Windows.Media.LineSegment lineSeg1 = new System.Windows.Media.LineSegment(pts[2], true); System.Windows.Media.LineSegment lineSeg2 = new System.Windows.Media.LineSegment(pts[0], true); PathSegmentCollection pathsegmentCollection = new PathSegmentCollection(); pathsegmentCollection.Add(lineSeg0); pathsegmentCollection.Add(lineSeg1); pathsegmentCollection.Add(lineSeg2); PathFigure pathFigure = new PathFigure(); pathFigure.StartPoint = pts[0]; pathFigure.Segments = pathsegmentCollection; PathFigureCollection pathFigureCollection = new PathFigureCollection(); pathFigureCollection.Add(pathFigure); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures = pathFigureCollection; return(pathGeometry); }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { if (path.Data == null) { var myPathFigure = new PathFigure(); myPathFigure.StartPoint = new Point(10, 50);; var myLineSegment = new LineSegment(); CurrentPosition = new Point(200, 70); myLineSegment.Point = CurrentPosition; var myPathSegmentCollection = new PathSegmentCollection(); myPathSegmentCollection.Add(myLineSegment); myPathFigure.Segments = myPathSegmentCollection; MyPathFigure = myPathFigure; var myPathFigureCollection = new PathFigureCollection(); myPathFigureCollection.Add(myPathFigure); var myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; path.Data = myPathGeometry; } else { CurrentPosition = CurrentPosition.Change(50, 30); var myLineSegment = new LineSegment() { Point = CurrentPosition }; MyPathFigure.Segments.Add(myLineSegment); } }
/// <summary> /// This function allows to draw the right arc of the object. /// </summary> protected void drawRightArc() { // The radius of the circumcercle. double radius = Math.Sqrt(height * height + width * width) / 2; PathSegmentCollection pathSegmentCollection = new PathSegmentCollection(); PathFigure segmentPathFigure = new PathFigure(); Point arcStartPoint = PointOnCircle(radius, arcRight_angleLow, new Point(x, y)); Point arcStopPoint = PointOnCircle(radius, arcRight_angleHigh, new Point(x, y)); segmentPathFigure.StartPoint = arcStartPoint; ArcSegment arcSegment = new ArcSegment(arcStopPoint, new Size(radius, radius), 0, false, SweepDirection.Counterclockwise, true); pathSegmentCollection.Add(arcSegment); segmentPathFigure.Segments = pathSegmentCollection; PathFigureCollection segmentPathFigureCollection = new PathFigureCollection(); segmentPathFigureCollection.Add(segmentPathFigure); PathGeometry segmentPathGeometry = new PathGeometry(); segmentPathGeometry.Figures = segmentPathFigureCollection; // Set up the segment's drawing (and hit-testing) path. arcRight = new Path(); arcRight.Stroke = Brushes.Black; arcRight.StrokeThickness = 1; arcRight.Fill = Brushes.Transparent; arcRight.Data = segmentPathGeometry; Canvas.SetLeft(arcRight, 0); Canvas.SetTop(arcRight, 0); Canvas.SetZIndex(arcRight, 1); Canvas.Children.Add(arcRight); }
/// <summary> /// Given a list of points, return a WPF PathGeometry. This is a helper method /// that can be used to create a simple Geometry composed of straight lines. /// </summary> /// <param name="points"></param> /// <returns></returns> public static PathGeometry GeometryFromPoints(Point[] points) { PolyLineSegment pls = new PolyLineSegment(); foreach (Point p in points) { pls.Points.Add(p); } PathSegmentCollection segs = new PathSegmentCollection(); segs.Add(pls); PathFigure fig = new PathFigure() { Segments = segs, StartPoint = points[points.Length - 1] }; PathFigureCollection figs = new PathFigureCollection(); figs.Add(fig); return(new PathGeometry() { Figures = figs }); }
private static Path getPathFromSegment(Point startPoint, PathSegment seg) { PathFigure myPathFigure2 = new PathFigure(); myPathFigure2.StartPoint = new Point(startPoint.X, startPoint.Y); PathSegmentCollection myPathSegmentCollection2 = new PathSegmentCollection(); myPathSegmentCollection2.Add(seg); myPathFigure2.Segments = myPathSegmentCollection2; PathFigureCollection myPathFigureCollection2 = new PathFigureCollection(); myPathFigureCollection2.Add(myPathFigure2); PathGeometry myPathGeometry2 = new PathGeometry(); myPathGeometry2.Figures = myPathFigureCollection2; Path myPath2 = new Path(); myPath2.Data = myPathGeometry2; return(myPath2); }
public Character(char c, int line, int position) { #region set defalt properties Height = CHAR_HEIGHT; Width = (c == '\t') ? CHAR_WIDTH * 4 : CHAR_WIDTH; #endregion #region initialize children // border border = new Border(); // text text = new TextBlock(); text.FontFamily = new FontFamily("Courier New"); text.FontSize = 13; text.Foreground = new SolidColorBrush(Colors.Black); text.Text = c.ToString(); // path path = new Path(); var pg = new PathGeometry(); var pfc = new PathFigureCollection(); var pf = new PathFigure(); pf.StartPoint = new Point(0, 12); pf.Segments = new PathSegmentCollection(); pf.Segments.Add(new LineSegment() { Point = new Point(2, 14)}); pf.Segments.Add(new LineSegment() { Point = new Point(4, 12)}); pf.Segments.Add(new LineSegment() { Point = new Point(6, 14)}); pf.Segments.Add(new LineSegment() { Point = new Point(8, 12)}); pfc.Add(pf); pg.Figures = pfc; path.Data = pg; path.Stroke = new SolidColorBrush(Colors.Red); path.StrokeThickness = 0.5; path.Visibility = Visibility.Collapsed; #endregion #region add children border.Child = text; Children.Add(border); Children.Add(path); #endregion Line = line; Position = position; DoubleClickHelper.Attach(this, OnDoubleClick); }
public PointOfViewIndicator() { _activePositionBrush = Brushes.Red; _lineBrush = Brushes.DarkGray; _linePen = new Pen(_lineBrush, 1d); PathSegmentCollection segments = new PathSegmentCollection(4); segments.Add(new LineSegment(new Point(0, 10), false)); segments.Add(new LineSegment(new Point(5, 0), false)); segments.Add(new LineSegment(new Point(10, 10), false)); segments.Add(new LineSegment(new Point(5, 5), false)); PathFigureCollection figures = new PathFigureCollection(); figures.Add(new PathFigure(new Point(5, 5), segments, true)); _arrowPath = new PathGeometry(figures); }
/// <summary> /// transform a list of coordinate in a scatterviewitem /// </summary> /// <param name="coord"></param> public ScatterViewItem createScatterViewItem(List<int> coord) { ScatterViewItem myShape = new ScatterViewItem(); //create the pathGeometry if (coord != null) { PathFigure myPathFigure = new PathFigure(); myPathFigure.StartPoint = new Point(coord[0], coord[1]); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); for (int i = 2; i < coord.Count(); i = i + 2) { LineSegment myLineSegment = new LineSegment(); myLineSegment.Point = new Point(coord[i], coord[i + 1]); myPathSegmentCollection.Add(myLineSegment); } myPathFigure.Segments = myPathSegmentCollection; PathFigureCollection myPathFigureCollection = new PathFigureCollection(); myPathFigureCollection.Add(myPathFigure); PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; //create the path System.Windows.Shapes.Path myPath = new System.Windows.Shapes.Path(); myPath.Stroke = Brushes.Black; myPath.StrokeThickness = 1; myPath.Data = myPathGeometry; myPath.Fill = new SolidColorBrush(Colors.Blue); //create the scatterViewItem myShape.Content = myPath; myShape.Width = this.max(coord); myShape.Height = this.max(coord); } return myShape; }
public void EndCollect() { if (this.PathGenerated != null && _psCollection.Count > 0) { PathGeometry pg = new PathGeometry(); pg.FillRule = FillRule.Nonzero; PathFigureCollection figs = new PathFigureCollection(); pg.Figures = figs; //닫힌 Path를 형성함 PathSegmentCollection pscol2 = _psCollection.Clone(); PathSegment last = pscol2.Last(); pscol2.Insert(0, last); PathFigure fig = new PathFigure(); fig.Segments = pscol2; fig.IsClosed = true; figs.Add(fig); this.PathGenerated(pg); } }
public static Geometry BorderFromPoints(double haw, double hah, double taw,double tah,double arcvalue) { //double Margin = 10; //double before = Margin + arcvalue; double startheaderxmargin = 20; double yupmargin = hah / 2; double ymargin = 5; double xmargin = 2; PathFigure myPathFigure = new PathFigure(); myPathFigure.StartPoint = new Point(haw + startheaderxmargin, yupmargin); Size ArcSize = new Size(arcvalue, arcvalue); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); myPathSegmentCollection.Add(new LineSegment(new Point(taw - arcvalue, yupmargin), true)); myPathSegmentCollection.Add(new ArcSegment(new Point(taw - xmargin, yupmargin + arcvalue), ArcSize, 90, false, SweepDirection.Clockwise, true)); myPathSegmentCollection.Add(new LineSegment(new Point(taw - xmargin, tah - arcvalue - ymargin), true)); myPathSegmentCollection.Add(new ArcSegment(new Point(taw - arcvalue - xmargin, tah - ymargin), ArcSize, 90, false, SweepDirection.Clockwise, true)); myPathSegmentCollection.Add(new LineSegment(new Point(arcvalue, tah - ymargin), true)); myPathSegmentCollection.Add(new ArcSegment(new Point(0, tah - ymargin - arcvalue), ArcSize, 90, false, SweepDirection.Clockwise, true)); myPathSegmentCollection.Add(new LineSegment(new Point(0, arcvalue + yupmargin), true)); myPathSegmentCollection.Add(new ArcSegment(new Point(arcvalue / 2, yupmargin + arcvalue / 2), ArcSize, 45, false, SweepDirection.Clockwise, true)); myPathFigure.Segments = myPathSegmentCollection; PathFigureCollection myPathFigureCollection = new PathFigureCollection(); myPathFigureCollection.Add(myPathFigure); PathGeometry pg = new PathGeometry(); pg.Figures = myPathFigureCollection; return pg; }
internal void Show(GitFileStatusTracker tracker) { this.tracker = tracker; loading.Visibility = Visibility.Visible; var dispatcher = Dispatcher.CurrentDispatcher; Action act = () => { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); try { IList<GraphNode> commits = null; string hash = null; if (tracker != null && tracker.HasGitRepository) { this.tracker.RepositoryGraph.IsSimplified = showSimplifiedGraph; commits = tracker.RepositoryGraph.Nodes; hash = GetHashCode(commits); } bool changed = lastHash == null ? hash != null : !lastHash.Equals(hash); if (changed) { lastHash = hash; canvasContainer.Children.Clear(); maxX = maxY = 0; if (changed && commits != null && commits.Count > 0) { maxX = commits.Count(); maxY = commits.Max(c => c.X); for (int i = commits.Count() - 1; i >= 0; i--) { var commit = commits[i]; #region Add commit box var box = new CommitBox(); box.DataContext = new { Id = commit.Id, ShortId = commit.Id.Substring(0, 7), Comments = commit.Message, Author = commit.CommitterName, Date = commit.CommitDateRelative, }; double left = GetScreenX(maxX - commit.Y); double top = GetScreenY(commit.X); Canvas.SetLeft(box, left); Canvas.SetTop(box, top); Canvas.SetZIndex(box, 10); this.canvasContainer.Children.Add(box); #endregion #region Add Branches var m = 0; foreach (var name in commit.Refs.Where(r => r.Type == RefTypes.Branch || r.Type == RefTypes.HEAD)) { var control = new CommitHead { DataContext = new { Text = name }, }; Canvas.SetLeft(control, left + CommitBox.WIDTH + 4); Canvas.SetTop(control, top + m++ * 30); this.canvasContainer.Children.Add(control); } #endregion #region Add Tags m = 0; foreach (var name in commit.Refs.Where(r => r.Type == RefTypes.Tag)) { var control = new CommitTag { DataContext = new { Text = name }, }; Canvas.SetLeft(control, left + m++ * 100); // TODO: get width of the control Canvas.SetTop(control, top - 24); this.canvasContainer.Children.Add(control); } #endregion #region Add Remote Branches m = 0; foreach (var name in commit.Refs.Where(r => r.Type == RefTypes.RemoteBranch)) { var control = new CommitRemote { DataContext = new { Text = name }, }; Canvas.SetLeft(control, left + m++ * 100); // TODO: get width of the control Canvas.SetTop(control, top + CommitBox.HEIGHT + 4); this.canvasContainer.Children.Add(control); } #endregion } #region Add commit links var links = tracker.RepositoryGraph.Links; foreach (var link in links) { // current node double x1 = link.Y1; double y1 = link.X1; // parent node double x2 = link.Y2; double y2 = link.X2; bool flip = links.Any(lnk => lnk.X1 == x2 && lnk.Y2 == y2 && lnk.X1 == lnk.X2); x1 = GetScreenX(maxX - x1); y1 = GetScreenY(y1) + CommitBox.HEIGHT / 2; x2 = GetScreenX(maxX - x2) + CommitBox.WIDTH; y2 = GetScreenY(y2) + CommitBox.HEIGHT / 2; if (y1 == y2) { var line = new Line { Stroke = new SolidColorBrush(Color.FromArgb(255, 153, 182, 209)), StrokeThickness = 4, }; line.X1 = x1; line.Y1 = y1; line.X2 = x2; line.Y2 = y2; this.canvasContainer.Children.Add(line); } else if (y1 > y2 && !flip) { var x3 = x2 - CommitBox.WIDTH / 2; var path = new System.Windows.Shapes.Path { Stroke = new SolidColorBrush(Color.FromArgb(255, 153, 182, 209)), StrokeThickness = 4, }; PathSegmentCollection pscollection = new PathSegmentCollection(); pscollection.Add(new LineSegment(new Point(x2, y1), true)); BezierSegment curve = new BezierSegment( new Point(x2, y1), new Point(x3, y1), new Point(x3, y2), true); pscollection.Add(curve); PathFigure pf = new PathFigure { StartPoint = new Point(x1, y1), Segments = pscollection, }; PathFigureCollection pfcollection = new PathFigureCollection(); pfcollection.Add(pf); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures = pfcollection; path.Data = pathGeometry; this.canvasContainer.Children.Add(path); } else { var x3 = x1 + CommitBox.WIDTH / 2; var path = new System.Windows.Shapes.Path { Stroke = new SolidColorBrush(Color.FromArgb(255, 153, 182, 209)), StrokeThickness = 4, }; PathSegmentCollection pscollection = new PathSegmentCollection(); BezierSegment curve = new BezierSegment( new Point(x3, y1), new Point(x3, y2), new Point(x1, y2), true); pscollection.Add(curve); pscollection.Add(new LineSegment(new Point(x2, y2), true)); PathFigure pf = new PathFigure { StartPoint = new Point(x3, y1), Segments = pscollection, }; PathFigureCollection pfcollection = new PathFigureCollection(); pfcollection.Add(pf); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures = pfcollection; path.Data = pathGeometry; this.canvasContainer.Children.Add(path); } } #endregion } AdjustCanvasSize(this.Scaler.ScaleX); } } catch (Exception ex) { Log.WriteLine("History Graph Show: {0}", ex.ToString()); } loading.Visibility = Visibility.Collapsed; stopwatch.Stop(); Debug.WriteLine("**** HistoryGraph Refresh: " + stopwatch.ElapsedMilliseconds); service.NoRefresh = false; service.lastTimeRefresh = DateTime.Now; //important!! }; dispatcher.BeginInvoke(act, DispatcherPriority.ApplicationIdle); }
private static Shape Worm(double dSize) { Path path = new Path(); path.StrokeThickness = iStrokeThickness; path.StrokeLineJoin = PenLineJoin.Round; /* string[] arrStrPoints = new string[10]; double dBringToStartX = -(dSize / 8); double dBringToStartY = -(dSize / 5); arrStrPoints[0] = (dBringToStartX + 2 * (dSize / 5)).ToString() + "," + (dBringToStartY + dSize / 4).ToString() + " "; arrStrPoints[1] = (dBringToStartX + 3 * (dSize / 5)).ToString() + "," + (dBringToStartY + (dSize / 4) - (dSize / 10)).ToString() + " "; arrStrPoints[2] = (dBringToStartX + dSize / 5).ToString() + "," + (dBringToStartY + dSize / 4).ToString() + " "; arrStrPoints[3] = dBringToStartX.ToString() + "," + (dBringToStartY + dSize / 4).ToString() + " "; arrStrPoints[4] = (dBringToStartX + 2 * (dSize / 5)).ToString() + "," + (dBringToStartY + dSize).ToString() + " "; arrStrPoints[5] = (dBringToStartX + dSize / 5).ToString() + "," + (dBringToStartY + dSize).ToString() + " "; arrStrPoints[6] = (dBringToStartX + dSize / 5).ToString() + "," + (dBringToStartY + dSize / 4).ToString() + " "; arrStrPoints[7] = (dBringToStartX + 3 * (dSize / 5)).ToString() + "," + (dBringToStartY + dSize).ToString() + " "; arrStrPoints[8] = (dBringToStartX + 2 * (dSize / 5)).ToString() + "," + (dBringToStartY + dSize).ToString() + " "; arrStrPoints[9] = dBringToStartX.ToString() + "," + (dBringToStartY + dSize + (dSize / 10)).ToString() + " "; string sGeometry = "M " + arrStrPoints[0]; sGeometry += "C " + arrStrPoints[0] + arrStrPoints[1] + arrStrPoints[2]; sGeometry += "C " + arrStrPoints[3] + arrStrPoints[4] + arrStrPoints[5]; sGeometry += "M " + arrStrPoints[0]; sGeometry += "C " + arrStrPoints[6] + arrStrPoints[7] + arrStrPoints[8]; sGeometry += "C " + arrStrPoints[8] + arrStrPoints[9] + arrStrPoints[5]; path.Data = Geometry.Parse(sGeometry); */ QuadraticBezierSegment pBezierSegment = new QuadraticBezierSegment(); PointCollection pointsCollection = new PointCollection(); pointsCollection.Add(new Point(0, 20)); pointsCollection.Add(new Point(-10, 10)); pointsCollection.Add(new Point(0, 0)); pointsCollection.Add(new Point(10, 0)); pointsCollection.Add(new Point(20, 40)); pointsCollection.Add(new Point(30, 50)); pointsCollection.Add(new Point(20, 60)); pointsCollection.Add(new Point(10, 60)); PathSegmentCollection pathSegmentCollection = new PathSegmentCollection(); pathSegmentCollection.Add(new QuadraticBezierSegment(bez3pts1(pointsCollection[0], pointsCollection[1], pointsCollection[2]), pointsCollection[2], true)); pathSegmentCollection.Add(new QuadraticBezierSegment(bez3pts1(pointsCollection[2], pointsCollection[3], pointsCollection[4]), pointsCollection[4], true)); pathSegmentCollection.Add(new QuadraticBezierSegment(bez3pts1(pointsCollection[4], pointsCollection[5], pointsCollection[6]), pointsCollection[6], true)); pathSegmentCollection.Add(new QuadraticBezierSegment(bez3pts1(pointsCollection[6], pointsCollection[7], pointsCollection[0]), pointsCollection[0], true)); PathFigure pathFigure = new PathFigure(); pathFigure.StartPoint = pointsCollection[0]; pathFigure.IsClosed = true; pathFigure.Segments = pathSegmentCollection; PathFigureCollection pathFigureCollection = new PathFigureCollection(); pathFigureCollection.Add(pathFigure); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures = pathFigureCollection; path.Data = pathGeometry; /* GraphicsPath p = new GraphicsPath(); System.Drawing.Point[] wormArray = new System.Drawing.Point[6]; wormArray[0] = new System.Drawing.Point(0, 0); wormArray[1] = new System.Drawing.Point(iSize / 10, 2 * (iSize / 5)); wormArray[2] = new System.Drawing.Point(iSize / 10, 9 * (iSize / 10)); wormArray[3] = new System.Drawing.Point(3 * (iSize / 5), iSize); wormArray[4] = new System.Drawing.Point((iSize / 2), 3 * (iSize / 5)); wormArray[5] = new System.Drawing.Point((iSize / 2), (iSize / 10)); for (int i = 0; i < 6; i++) { wormArray[i].X += x; wormArray[i].Y += y; } p.AddClosedCurve(wormArray); */ return path; }
// Create an ESRI polyline based on a densified representation of WPFs ArcSegment public static ESRI.ArcGIS.Client.Geometry.Polyline ConstructArcSegment(ESRI.ArcGIS.Client.Geometry.MapPoint startPoint, ESRI.ArcGIS.Client.Geometry.MapPoint endPoint, double radius, bool isMinor, SweepDirection direction) { if (endPoint == null) return null; // WPF ArcSegment has issue with high coordinates values. // Bring coordinates down to 0,0 and translate back to real world later. double startX = startPoint.X; double startY = startPoint.Y; double absRadius = Math.Abs(radius); // We need to switch the curve direction, b/c we are starting with the end point if (radius > 0) direction = direction == SweepDirection.Clockwise ? SweepDirection.Counterclockwise : SweepDirection.Clockwise; Size radiusAspect = new Size(absRadius, absRadius); Point myEndPoint = new Point(endPoint.X - startX, endPoint.Y - startY); bool isLargeArc = !isMinor; ArcSegment wpfArcSegment = new ArcSegment(myEndPoint, radiusAspect, 0, isLargeArc, direction, false); // compose one or more segments into a collection var pathcoll = new PathSegmentCollection(); pathcoll.Add(wpfArcSegment); // create a figure based on the set of segments var pathFigure = new PathFigure(); pathFigure.Segments = pathcoll; pathFigure.IsClosed = false; // compose a collection of figures var figureCollection = new PathFigureCollection(); figureCollection.Add(pathFigure); // create a path-geometry using the figures collection var geometryPath = new PathGeometry(figureCollection); ESRI.ArcGIS.Client.Geometry.PointCollection pointCollection = new ESRI.ArcGIS.Client.Geometry.PointCollection(); double numSegments = 1.0 / 50; // Default 50 Point point, tangent; Point pointA, pointB; geometryPath.GetPointAtFractionLength(0, out pointA, out tangent); geometryPath.GetPointAtFractionLength(numSegments, out pointB, out tangent); double partDistance = LineLength(pointA.X, pointA.Y, pointB.X, pointB.Y); if (partDistance > 1.0) numSegments /= partDistance; if (1 / numSegments > 160) // cap it at 160 vertexes numSegments = 1.0 / 160; // Server is having issue with 185+ vertexes (180 seems ok) for (double fraction = 0.0; fraction < 1.0; fraction += numSegments) { geometryPath.GetPointAtFractionLength(fraction, out point, out tangent); pointCollection.Add(new ESRI.ArcGIS.Client.Geometry.MapPoint(point.X + startX, point.Y + startY)); } pointCollection.Add(endPoint); // faction 1 can be skipped, so add it here. ESRI.ArcGIS.Client.Geometry.Polyline polyline = new ESRI.ArcGIS.Client.Geometry.Polyline(); polyline.Paths.Add(pointCollection); return polyline; }
internal override PathFigureCollection GetTransformedFigureCollection(Transform transform) { // Combine the transform argument with the internal transform Transform combined = new MatrixTransform(GetCombinedMatrix(transform)); PathFigureCollection result = new PathFigureCollection(); GeometryCollection children = Children; if (children != null) { for (int i = 0; i < children.Count; i++) { PathFigureCollection pathFigures = children.Internal_GetItem(i).GetTransformedFigureCollection(combined); if (pathFigures != null) { int count = pathFigures.Count; for (int j = 0; j < count; ++j) { result.Add(pathFigures[j]); } } } } return result; }
public void EndPoint() { var pathfig = new PathFigure(); pathfig.StartPoint = this.start.Value; pathfig.Segments = this.segments; var pathfigcoll = new PathFigureCollection(); pathfigcoll.Add(pathfig); var pathgeo = new PathGeometry(); pathgeo.Figures = pathfigcoll; this.path.Data = pathgeo; }
public void plotPoints(List<Point> pointslist) { setAxes(); setXaxisTitle(Xtitle); setYaxisTitle(Ytitle); setPlotTitle(Plottitle); GeometryGroup s = new GeometryGroup(); PathGeometry pg = new PathGeometry(); PathFigureCollection pfc = new PathFigureCollection(); PathFigure pf = new PathFigure(); PathSegmentCollection psc = new PathSegmentCollection(); Point stpoint = pointslist[0]; stpoint.X = origin.X + spanX * stpoint.X; stpoint.Y = origin.Y - spanY * stpoint.Y; pf.StartPoint = stpoint; EllipseGeometry elg = new EllipseGeometry(stpoint, 2, 2); s.Children.Add(elg); string pointText = pointToText(stpoint); setText(pointText, stpoint); for (int i = 1; i < pointslist.Count; i++) { Point point = pointslist[i]; point.X = origin.X + spanX * point.X; point.Y = origin.Y - spanY * point.Y; LineSegment ls = new LineSegment(point, true); elg = new EllipseGeometry(point, 2, 2); setText(pointToText(point), point); s.Children.Add(elg); psc.Add(ls); } pf.Segments = psc; pfc.Add(pf); pg.Figures = pfc; Path p = new Path(); Path p1 = new Path(); p.Data = pg; p.Stroke = Brushes.Green; p1.Data = s; p1.Fill = Brushes.Blue; activeCanvas.Children.Add(p); activeCanvas.Children.Add(p1); activeCanvas.ClipToBounds = true; }
public LineGraph() { if(Settings == null) Settings = new LineGraphSettings(); filters.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(filters_CollectionChanged); path = new Path(); geom = new PathGeometry(); figures = new PathFigureCollection(); figure = new PathFigure(); segments = new PathSegmentCollection(); figure.Segments = segments; figures.Add(figure); geom.Figures = figures; path.Data = geom; path.StrokeLineJoin = PenLineJoin.Round; path.StrokeThickness = settings.LineThickness; path.SetBinding(Path.StrokeProperty, new System.Windows.Data.Binding() { Source = this, Path = new PropertyPath("LineColor") }); Filters.Add(new Microsoft.Research.DynamicDataDisplay.Filters.FrequencyFilter()); }
/// <summary> /// Returns new PathFigureCollection by easing startValue to endValue using a time percentage 0 -> 1. /// </summary> public static PathFigureCollection EaseValue(PathFigureCollection startValue, PathFigureCollection endValue, double percent) { var collection = new PathFigureCollection(); for (var i = 0; i < endValue.Count; i++ ) { collection.Add(EaseValue(startValue[i], endValue[i], percent)); } return collection; }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { Debug.Assert( values != null && values.Length == 12, "EdgeRouteToPathConverter should have 10 parameters: pos (0, 1), size (2, 3) of source; pos (4, 5), size (6, 7) of target; routeInformation (8); directed (9); angle (10) of source; angle (11) of target." ); var sourcePos = new Point { X = values[0] != DependencyProperty.UnsetValue ? (double) values[0] : 0.0, Y = values[1] != DependencyProperty.UnsetValue ? (double) values[1] : 0.0 }; //get the size of the source var sourceSize = new Size { Width = values[2] != DependencyProperty.UnsetValue ? (double) values[2] : 0.0, Height = values[3] != DependencyProperty.UnsetValue ? (double) values[3] : 0.0 }; //get the position of the target var targetPos = new Point { X = values[4] != DependencyProperty.UnsetValue ? (double) values[4] : 0.0, Y = values[5] != DependencyProperty.UnsetValue ? (double) values[5] : 0.0 }; //get the size of the target var targetSize = new Size { Width = values[6] != DependencyProperty.UnsetValue ? (double) values[6] : 0.0, Height = values[7] != DependencyProperty.UnsetValue ? (double) values[7] : 0.0 }; //get the route informations Point[] routeInformation = values[8] != DependencyProperty.UnsetValue ? (Point[]) values[8] : null; bool directed = values[9] == DependencyProperty.UnsetValue || (bool) values[9]; double sourceAngle = values[10] != DependencyProperty.UnsetValue ? (double) values[10] : 0.0; double targetAngle = values[11] != DependencyProperty.UnsetValue ? (double) values[11] : 0.0; if (double.IsNaN(sourcePos.X) || double.IsNaN(sourcePos.Y) || double.IsNaN(targetPos.X) || double.IsNaN(targetPos.Y)) return DependencyProperty.UnsetValue; bool hasRouteInfo = routeInformation != null && routeInformation.Length > 0; Point p1 = CalculateAttachPoint(sourceAngle, sourcePos, sourceSize, hasRouteInfo ? routeInformation[0] : targetPos); Point p2 = CalculateAttachPoint(targetAngle, targetPos, targetSize, hasRouteInfo ? routeInformation[routeInformation.Length - 1] : sourcePos); var edgeFigure = new PathFigure {StartPoint = p1}; if (hasRouteInfo) { edgeFigure.Segments.Add(new LineSegment(routeInformation[0], true)); var pts = new List<Point>(routeInformation.Length + 2) {p1}; pts.AddRange(routeInformation); pts.Add(p2); for (int i = 1; i < pts.Count - 1; i++) ConnectLinePoints(edgeFigure, pts[i - 1], pts[i], pts[i + 1], 5); } else { edgeFigure.Segments.Add(new LineSegment(p2, true)); } var pfc = new PathFigureCollection {edgeFigure}; if (directed) { Point pLast = hasRouteInfo ? routeInformation[routeInformation.Length - 1] : p1; Vector v = pLast - p2; v = v / v.Length * 5; Vector n = new Vector(-v.Y, v.X) * 0.3; var arrowFigure = new PathFigure(p2, new PathSegment[] { new LineSegment(p2 + v - n, true), new LineSegment(p2 + v + n, true) }, true); pfc.Add(arrowFigure); } return pfc; }
public object Convert( object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture ) { Debug.Assert( values != null && values.Length == 9, "EdgeRouteToPathConverter should have 9 parameters: pos (1,2), size (3,4) of source; pos (5,6), size (7,8) of target; routeInformation (9)." ); #region Get the inputs //get the position of the source Point sourcePos = new Point() { X = ( values[0] != DependencyProperty.UnsetValue ? (double)values[0] : 0.0 ), Y = ( values[1] != DependencyProperty.UnsetValue ? (double)values[1] : 0.0 ) }; //get the size of the source Size sourceSize = new Size() { Width = ( values[2] != DependencyProperty.UnsetValue ? (double)values[2] : 0.0 ), Height = ( values[3] != DependencyProperty.UnsetValue ? (double)values[3] : 0.0 ) }; //get the position of the target Point targetPos = new Point() { X = ( values[4] != DependencyProperty.UnsetValue ? (double)values[4] : 0.0 ), Y = ( values[5] != DependencyProperty.UnsetValue ? (double)values[5] : 0.0 ) }; //get the size of the target Size targetSize = new Size() { Width = ( values[6] != DependencyProperty.UnsetValue ? (double)values[6] : 0.0 ), Height = ( values[7] != DependencyProperty.UnsetValue ? (double)values[7] : 0.0 ) }; //get the route informations Point[] routeInformation = ( values[8] != DependencyProperty.UnsetValue ? (Point[])values[8] : null ); #endregion bool hasRouteInfo = routeInformation != null && routeInformation.Length > 0; // // Create the path // Point p1 = GraphConverterHelper.CalculateAttachPoint( sourcePos, sourceSize, ( hasRouteInfo ? routeInformation[0] : targetPos ) ); Point p2 = GraphConverterHelper.CalculateAttachPoint( targetPos, targetSize, ( hasRouteInfo ? routeInformation[routeInformation.Length - 1] : sourcePos ) ); PathSegment[] segments = new PathSegment[1 + ( hasRouteInfo ? routeInformation.Length : 0 )]; if ( hasRouteInfo ) //append route points for ( int i = 0; i < routeInformation.Length; i++ ) segments[i] = new LineSegment( routeInformation[i], true ); Point pLast = ( hasRouteInfo ? routeInformation[routeInformation.Length - 1] : p1 ); Vector v = pLast - p2; v = v / v.Length * 5; Vector n = new Vector( -v.Y, v.X ) * 0.3; segments[segments.Length - 1] = new LineSegment( p2 + v, true ); PathFigureCollection pfc = new PathFigureCollection( 2 ); pfc.Add( new PathFigure( p1, segments, false ) ); pfc.Add( new PathFigure( p2, new PathSegment[] { new LineSegment(p2 + v - n, true), new LineSegment(p2 + v + n, true)}, true ) ); return pfc; }
private void plotLogPoints() { double spanX = Math.Log(2); double spanY = Math.Log(2); setLogAxes(); GeometryGroup s = new GeometryGroup(); PathGeometry pg = new PathGeometry(); PathFigureCollection pfc = new PathFigureCollection(); PathFigure pf = new PathFigure(); PathSegmentCollection psc = new PathSegmentCollection(); Point stpoint = pointslist[0]; stpoint.X = Math.Round(origin.X + spanX * stpoint.X, 2); stpoint.Y = Math.Round(origin.Y - spanY * stpoint.Y, 2); pf.StartPoint = stpoint; EllipseGeometry elg = new EllipseGeometry(stpoint, 2, 2); s.Children.Add(elg); setText(pointToText(stpoint), stpoint); for (int i = 1; i < pointslist.Count; i++) { Point point = pointslist[i]; point.X = Math.Round(origin.X + spanX * point.X, 2); point.Y = Math.Round(origin.Y - spanY * point.Y, 2); LineSegment ls = new LineSegment(point, true); elg = new EllipseGeometry(point, 2, 2); setText(pointToText(point), point); s.Children.Add(elg); psc.Add(ls); spanX = Math.Log(i + 1) * 10; spanY = Math.Log(i + 1) * 10; } pf.Segments = psc; pfc.Add(pf); pg.Figures = pfc; Path p = new Path(); Path p1 = new Path(); p.Data = pg; p.Stroke = Brushes.Green; p1.Data = s; p1.Fill = Brushes.Blue; activeCanvas.Children.Add(p); activeCanvas.Children.Add(p1); activeCanvas.ClipToBounds = true; }
public static PathGeometry GenerateBezierCurve(Point[] points) { PathFigure pathFigure = new PathFigure(); PointCollection pointCollection = new PointCollection(points.Length); pathFigure.StartPoint = new Point(points[0].X, points[0].Y); PathGeometry myPathGeometry = new PathGeometry(); PathSegment pathSegment; if (points.Length == 2) { pathSegment = new LineSegment(); ((LineSegment)pathSegment).Point = new Point(points[1].X, points[1].Y); } else if (points.Length == 3) { pathSegment = new QuadraticBezierSegment(); ((QuadraticBezierSegment)pathSegment).Point1 = new Point(points[1].X, points[1].Y); ((QuadraticBezierSegment)pathSegment).Point2 = new Point(points[2].X, points[2].Y); } else if (points.Length == 4) { for (int i = 1; i < points.Length; i++) { pointCollection.Add(points[i]); } pathSegment = new PolyBezierSegment(); ((PolyBezierSegment)pathSegment).Points = pointCollection; } else { return null; } PathSegmentCollection pathSegmentCollection = new PathSegmentCollection(); pathSegmentCollection.Add(pathSegment); pathFigure.Segments = pathSegmentCollection; PathFigureCollection pathFigureCollection = new PathFigureCollection(); pathFigureCollection.Add(pathFigure); myPathGeometry.Figures = pathFigureCollection; return myPathGeometry; }
/// <summary> /// Draw a polygon filled with a gradient of colours. /// </summary> /// <param name="brush"> /// A previously created gradient or image brush (LDShapes.BrushGradient LDShapes.BrushImage). /// </param> /// <param name="points"> /// An array of coordinates for the polygon corners with the form points[i][1] = x, points[i][2] = y. /// /// The number of points must be 3 or more. /// </param> /// <returns> /// None. /// </returns> public static void BrushPolygon(Primitive brush, Primitive points) { Type GraphicsWindowType = typeof(GraphicsWindow); DrawingGroup _mainDrawing; try { _mainDrawing = (DrawingGroup)GraphicsWindowType.GetField("_mainDrawing", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null); InvokeHelper ret = new InvokeHelper(delegate { try { foreach (GradientBrush i in brushes) { if (i.name == brush) { PointCollection _points = getPoints(points); if (_points.Count < 3) return; DrawingContext drawingContext = _mainDrawing.Append(); PathFigure pathFigure = new PathFigure(); pathFigure.IsClosed = true; pathFigure.StartPoint = _points[0]; for (int j = 1; j < _points.Count; j++) { pathFigure.Segments.Add(new LineSegment(_points[j], true)); } PathFigureCollection pathFigureCollection = new PathFigureCollection(); pathFigureCollection.Add(pathFigure); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures = pathFigureCollection; pathGeometry.Freeze(); drawingContext.DrawGeometry(i.getBrush(), null, pathGeometry); drawingContext.Close(); GraphicsWindowType.GetMethod("AddRasterizeOperationToQueue", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).Invoke(null, new object[] { }); } } } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); } }); FastThread.Invoke(ret); } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); } }
//Plot method for displaying value into 2D points in a line graph public void plotPoints(int[] plist, Canvas can) { pointslist=transformValuesToPoints(plist); activeCanvas = can; setAxes(); GeometryGroup s = new GeometryGroup(); PathGeometry pg = new PathGeometry(); PathFigureCollection pfc = new PathFigureCollection(); PathFigure pf = new PathFigure(); PathSegmentCollection psc = new PathSegmentCollection(); Point stpoint = pointslist[0]; stpoint.X = origin.X + spanX * stpoint.X; stpoint.Y = origin.Y - spanY * stpoint.Y; pf.StartPoint = stpoint; EllipseGeometry elg = new EllipseGeometry(stpoint, 2, 2); s.Children.Add(elg); setText(ref origin, can, ref stpoint); for (int i = 1; i < pointslist.Count; i++) { Point point = pointslist[i]; point.X = origin.X + spanX * point.X; point.Y = origin.Y - spanY * point.Y; LineSegment ls = new LineSegment(point, true); elg = new EllipseGeometry(point, 2, 2); setText(ref origin, can, ref point); s.Children.Add(elg); psc.Add(ls); } pf.Segments = psc; pfc.Add(pf); pg.Figures = pfc; Path p = new Path(); Path p1 = new Path(); p.Data = pg; p.Stroke = Brushes.Green; p1.Data = s; p1.Fill = Brushes.Blue; activeCanvas.Children.Add(p); activeCanvas.Children.Add(p1); activeCanvas.ClipToBounds = true; }
//public tiposDibujo duración {get; set;} public static Path dibujarGráficoLínea(prodParaDibujar producto, Point coordInicio, double separaciónX) { PathFigure myPathFigure = new PathFigure(); myPathFigure.StartPoint = coordInicio; //new Point(valorX, 100); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); for (int i = 0; i < producto.valores.Count; i++) { LineSegment myLineSegment = new LineSegment(); myLineSegment.Point = new Point(coordInicio.X + separaciónX, myPathFigure.StartPoint.Y - producto.valores[i]*10); myPathSegmentCollection.Add(myLineSegment); coordInicio.X = myLineSegment.Point.X; } myPathFigure.Segments = myPathSegmentCollection; PathFigureCollection myPathFigureCollection = new PathFigureCollection(); myPathFigureCollection.Add(myPathFigure); PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; Path myPath = new Path(); myPath.Stroke = Brushes.Green; myPath.StrokeThickness = 2; myPath.Data = myPathGeometry; return myPath; }
private static void RenderAllStrokes(InkCanvas canvas, Panel parent) { // Get the InkStroke objects. IReadOnlyList<InkStroke> inkStrokes = canvas.InkPresenter.StrokeContainer.GetStrokes(); List<Windows.UI.Xaml.Shapes.Path> retVal = new List<Windows.UI.Xaml.Shapes.Path>(); // Process each stroke. foreach (InkStroke inkStroke in inkStrokes) { PathGeometry pathGeometry = new PathGeometry(); PathFigureCollection pathFigures = new PathFigureCollection(); PathFigure pathFigure = new PathFigure(); PathSegmentCollection pathSegments = new PathSegmentCollection(); // Create a path and define its attributes. Windows.UI.Xaml.Shapes.Path path = new Windows.UI.Xaml.Shapes.Path(); path.Stroke = new SolidColorBrush(inkStroke.DrawingAttributes.Color); path.StrokeThickness = inkStroke.DrawingAttributes.Size.Height; if (inkStroke.DrawingAttributes.DrawAsHighlighter) { path.Opacity = .4d; } // Get the stroke segments. IReadOnlyList<InkStrokeRenderingSegment> segments; segments = inkStroke.GetRenderingSegments(); // Process each stroke segment. bool first = true; foreach (InkStrokeRenderingSegment segment in segments) { // The first segment is the starting point for the path. if (first) { pathFigure.StartPoint = segment.BezierControlPoint1; first = false; } // Copy each ink segment into a bezier segment. BezierSegment bezSegment = new BezierSegment(); bezSegment.Point1 = segment.BezierControlPoint1; bezSegment.Point2 = segment.BezierControlPoint2; bezSegment.Point3 = segment.Position; // Add the bezier segment to the path. pathSegments.Add(bezSegment); } // Build the path geometerty object. pathFigure.Segments = pathSegments; pathFigures.Add(pathFigure); pathGeometry.Figures = pathFigures; // Assign the path geometry object as the path data. path.Data = pathGeometry; // Render the path by adding it as a child of the Canvas object. parent.Children.Add(path); } }
private Path StrokeToPath(Stroke oStroke) { PathFigure myPathFigure = null; LineSegment myLineSegment = null; PathFigureCollection myPathFigureCollection = new PathFigureCollection(); PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); if (oStroke == null) return null; // Number of points. int n = oStroke.StylusPoints.Count; if (n == 0) return null; // Start point is first point from sytluspoints collection (M, item 0). myPathFigure = new PathFigure(); myPathFigure.StartPoint = new Point(oStroke.StylusPoints[0].X, oStroke.StylusPoints[0].Y); myPathFigureCollection.Add(myPathFigure); // Make small line segment L if there is only one point in the Stroke (workaround). // Data with only M is not shown. if (n == 1) { myLineSegment = new LineSegment(); myLineSegment.Point = new Point(oStroke.StylusPoints[0].X + 1, oStroke.StylusPoints[0].Y + 1); myPathSegmentCollection.Add(myLineSegment); } // The other points are line segments (L, items 1..n-1). for (int i = 1; i < n; i++) { myLineSegment = new LineSegment(); myLineSegment.Point = new Point(oStroke.StylusPoints[i].X, oStroke.StylusPoints[i].Y); myPathSegmentCollection.Add(myLineSegment); } myPathFigure.Segments = myPathSegmentCollection; PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures = myPathFigureCollection; Path oPath = new Path(); // Add the data to the Path. oPath.Data = myPathGeometry; // <-| // Copy Stroke properties to Path. // ---------------------------------------- // Stroke color. Color oC = oStroke.DrawingAttributes.Color; // Stroke color. SolidColorBrush oBr = new SolidColorBrush(); oBr.Color = oC; oPath.Stroke = oBr; // Stroke thickness. double dW = oStroke.DrawingAttributes.Width; // Width of stylus. double dH = oStroke.DrawingAttributes.Height; // Height of stylus. oPath.StrokeThickness = dW; // Attribute FitToCurve. // FitToCurve has no effect on the points, oStroke.StylusPoints is used. // See also oStroke.GetBezierStylusPoints(). // See also test with GetAllPoints(). // Stroke has no Fill property in attributes. // oPath.Fill = mySolidColorBrush; // ---------------------------------------- return oPath; }
private PathGeometry GetPath(Point start, Point end) { var pathFigure = new PathFigure() { StartPoint = start }; var lineSegment = new LineSegment() { Point = end }; var pathSegmentCollection = new PathSegmentCollection(); pathSegmentCollection.Add(lineSegment); pathFigure.Segments = pathSegmentCollection; var pathFigureCollection = new PathFigureCollection(); pathFigureCollection.Add(pathFigure); return new PathGeometry() { Figures = pathFigureCollection }; }
//changed by rushabh private void plotLogPoints() { setlogAxes(); setXaxisTitle(Xtitle); setYaxisTitle(Ytitle); setPlotTitle(Plottitle); GeometryGroup s = new GeometryGroup(); PathGeometry pg = new PathGeometry(); PathFigureCollection pfc = new PathFigureCollection(); PathFigure pf = new PathFigure(); PathSegmentCollection psc = new PathSegmentCollection(); Point stpoint = pointslist[0]; Point pt = new Point(); //stpoint.X = Math.Round(origin.X + spanX * stpoint.X, 2); //stpoint.Y = Math.Round(origin.Y - spanY * stpoint.Y, 2); pt.X = Math.Round(origin.X + spanX * stpoint.X, 2); pt.Y = Math.Round(origin.Y - spanY * Math.Log10(stpoint.Y), 2); pf.StartPoint = pt; EllipseGeometry elg = new EllipseGeometry(pt, 2, 2); s.Children.Add(elg); setText(stpoint.X.ToString() + "," + stpoint.Y.ToString(), pt); for (int i = 1; i < pointslist.Count; i++) { Point point = pointslist[i]; point.X = Math.Round(point.X, 2); point.Y = Math.Round(point.Y, 2); pt.X = Math.Round(origin.X + spanX * point.X, 2); pt.Y = Math.Round(origin.Y - spanY * Math.Log10(point.Y), 2); LineSegment ls = new LineSegment(pt, true); elg = new EllipseGeometry(pt, 2, 2); setText(point.X.ToString() + "," + point.Y.ToString(), pt); s.Children.Add(elg); psc.Add(ls); } pf.Segments = psc; pfc.Add(pf); pg.Figures = pfc; Path p = new Path(); Path p1 = new Path(); p.Data = pg; p.Stroke = Brushes.Green; p1.Data = s; p1.Fill = Brushes.Blue; activeCanvas.Children.Add(p); activeCanvas.Children.Add(p1); activeCanvas.ClipToBounds = true; }
internal override PathFigureCollection GetTransformedFigureCollection(Transform transform) { Point [] points = GetPointList(); // Get the combined transform argument with the internal transform Matrix matrix = GetCombinedMatrix(transform); if (!matrix.IsIdentity) { for (int i=0; i<points.Length; i++) { points[i] *= matrix; } } PathFigureCollection figureCollection = new PathFigureCollection(); figureCollection.Add( new PathFigure( points[0], new PathSegment[]{ new BezierSegment(points[1], points[2], points[3], true, true), new BezierSegment(points[4], points[5], points[6], true, true), new BezierSegment(points[7], points[8], points[9], true, true), new BezierSegment(points[10], points[11], points[12], true, true)}, true ) ); return figureCollection; }
public void Draw() { PathFigure path = new PathFigure(); PathFigureCollection pathColl = new PathFigureCollection(); PolyLineSegment points = new PolyLineSegment(); PathSegmentCollection pathSeg = new PathSegmentCollection(); PathGeometry pathGeo = new PathGeometry(); Pen thinPen = new Pen(Brushes.Transparent, 0.0001); points.Points = tail.GetPoints(); path.StartPoint = startingPoint; pathSeg.Add(points); path.StartPoint = points.Points.ElementAt(0); path.Segments = pathSeg; pathColl.Add(path); pathGeo.Figures = pathColl; myPath.Data = pathGeo; }