1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media;
- using System.Windows.Shapes;
- namespace FlowChartModule.绘制模块
- {
- public class Connection_Line
- {
- PathGeometry pathGeometry = new PathGeometry();
- PathFigure pathFigure = new PathFigure();
- BezierSegment bezierSegment = new BezierSegment();
- public BezierCurveModel curveModel = new BezierCurveModel();
- [JsonIgnore]
- public Path path = new Path();
- private Element startelement=null;
- private Element endelement=null;
- [JsonIgnore]
- public Element Startelement { get => startelement; set => startelement = value; }
- [JsonIgnore]
- public Element Endelement { get => endelement; set => endelement = value ; }
- public Connection_Line(Canvas canvas)
- {
-
- }
- public void Drewbezier(Canvas canvas)
- {
- // 绘制贝塞尔曲线
-
- path.Stroke = Brushes.Blue;
- path.StrokeThickness = 2;
- pathFigure.StartPoint = curveModel.StartPoint;
- bezierSegment.Point1 = curveModel.ControlPoint1;
- bezierSegment.Point2 = curveModel.ControlPoint2;
- bezierSegment.Point3 = curveModel.EndPoint;
- pathFigure.Segments.Add(bezierSegment);
- pathGeometry.Figures.Add(pathFigure);
- path.Data = pathGeometry;
- path.Tag = canvas.Children.Count;
- canvas.Children.Add(path);
- }
- public void DrewbezierRef(Canvas canvas)
- {
- // 绘制贝塞尔曲线
- canvas.Children.Remove(path);
- pathGeometry = new PathGeometry();
- pathFigure = new PathFigure();
- bezierSegment = new BezierSegment();
- path.Stroke = Brushes.Blue;
- path.StrokeThickness = 2;
- pathFigure.StartPoint = curveModel.StartPoint;
- bezierSegment.Point1 = curveModel.ControlPoint1;
- bezierSegment.Point2 = curveModel.ControlPoint2;
- bezierSegment.Point3 = curveModel.EndPoint;
- pathFigure.Segments.Add(bezierSegment);
- pathGeometry.Figures.Add(pathFigure);
- path.Data = pathGeometry;
- path.Tag = canvas.Children.Count;
- canvas.Children.Add(path);
- }
-
- }
- }
|