void activity_连接事件(object sender, EventArgs e) { ActivityControl act = sender as ActivityControl; LinkEventArgs c = e as LinkEventArgs; AddActivityPath("", c.起点, act.Name, c.路由条件, ""); }
public void AddActivity(ActivityControl activity) { if (string.IsNullOrEmpty(activity.Name)) { activity_n = activity_n + 1; activity.Name = "activity" + activity_n.ToString(); } if (NameList.Exists(p => p == activity.Name)) { return; } this.myDesigner.Children.Add(activity); ActivityControlList.Add(activity); activity.刷新事件 += new EventHandler(activity_刷新事件); activity.连接事件 += new EventHandler(activity_连接事件); activity.设计器 = this; activity.显示分支选项(); RefurbishActivityPath(); }
public void AddActivity(ActivityControl activity) { if (string.IsNullOrEmpty(activity.Name)) { activity_n = activity_n + 1; activity.Name = "activity" + activity_n.ToString(); } if (NameList.Exists(p => p == activity.Name)) { return; } this.myDesigner.Children.Add(activity); ActivityControlList.Add(activity); activity.刷新事件 += new EventHandler(activity_刷新事件); activity.连接事件 += new EventHandler(activity_连接事件); activity.设计器 = this; activity.显示分支选项(); RefurbishActivityPath(); }
void DrawActivityPath(ActivityControl startingActivity, ActivityControl targetingActivity, Path pathObject, ActivityPath activityPath) { int i = startingActivity.分支集合.FindIndex(p => p == activityPath.路由); int l = 0; for (int n = 0; n <= i; n++) { l = startingActivity.分支集合[n].Length + l; } //double x1 = Canvas.GetLeft(起点) + 起点.Width - 15; double x1=0; double y1=0; switch (activityPath.路由) { case "开始状态": x1 = Canvas.GetLeft(startingActivity) + startingActivity.Width / 2; y1 = Canvas.GetTop(startingActivity) + startingActivity.Height; break; case "回归": x1 = Canvas.GetLeft(startingActivity) + startingActivity.Width / 2; y1 = Canvas.GetTop(startingActivity) + startingActivity.Height; break; default: x1 = Canvas.GetLeft(startingActivity) + 6 + (l * 11) + i * 5; y1 = Canvas.GetTop(startingActivity) + startingActivity.Height - 10; break; } double x4 = Canvas.GetLeft(targetingActivity) + 20; double y4 = Canvas.GetTop(targetingActivity); double x2 = x1; double y2 = y1 + 100; double x3 = x4; double y3 = y4 - 100; PathFigure 形状子部分 = new PathFigure(); PathSegmentCollection 串线 = new PathSegmentCollection(); PathFigureCollection 形状集合 = new PathFigureCollection(); PathGeometry 形状 = new PathGeometry(); 形状子部分.StartPoint = new Point(x1, y1); 形状子部分.Segments = 串线; 形状集合.Add(形状子部分); 形状.Figures = 形状集合; pathObject.Data = 形状; pathObject.Stroke = System.Windows.Media.Brushes.Black; pathObject.StrokeThickness = 1; //BezierSegment b = new BezierSegment(); //b.Point1 = new Point(x2, y2); //b.Point2 = new Point(x3, y3); //b.Point3 = new Point(x4, y4); LineSegment b = new LineSegment(); b.Point = new Point(x4, y4); 串线.Add(b); 串线.Add(new LineSegment() { Point = new Point() { Y = y4 - 10, X = x4 + 5 } }); 串线.Add(new LineSegment() { Point = new Point() { Y = y4 - 10, X = x4 + 4 } }); 串线.Add(new LineSegment() { Point = new Point() { Y = y4, X = x4 } }); 串线.Add(new LineSegment() { Point = new Point() { Y = y4 - 10, X = x4 - 5 } }); 串线.Add(new LineSegment() { Point = new Point() { Y = y4 - 10, X = x4 - 6 } }); Canvas.SetLeft(activityPath.标签, x1 + (x4 - x1) / 2); Canvas.SetTop(activityPath.标签, y4 - (y4 - y1) / 2); }
void DrawActivityPath(ActivityControl startingActivity, ActivityControl targetingActivity, Path pathObject, ActivityPath activityPath) { int i = startingActivity.分支集合.FindIndex(p => p == activityPath.路由); int l = 0; for (int n = 0; n <= i; n++) { l = startingActivity.分支集合[n].Length + l; } //double x1 = Canvas.GetLeft(起点) + 起点.Width - 15; double x1 = 0; double y1 = 0; switch (activityPath.路由) { case "开始状态": x1 = Canvas.GetLeft(startingActivity) + startingActivity.Width / 2; y1 = Canvas.GetTop(startingActivity) + startingActivity.Height; break; case "回归": x1 = Canvas.GetLeft(startingActivity) + startingActivity.Width / 2; y1 = Canvas.GetTop(startingActivity) + startingActivity.Height; break; default: x1 = Canvas.GetLeft(startingActivity) + 6 + (l * 11) + i * 5; y1 = Canvas.GetTop(startingActivity) + startingActivity.Height - 10; break; } double x4 = Canvas.GetLeft(targetingActivity) + 20; double y4 = Canvas.GetTop(targetingActivity); double x2 = x1; double y2 = y1 + 100; double x3 = x4; double y3 = y4 - 100; PathFigure 形状子部分 = new PathFigure(); PathSegmentCollection 串线 = new PathSegmentCollection(); PathFigureCollection 形状集合 = new PathFigureCollection(); PathGeometry 形状 = new PathGeometry(); 形状子部分.StartPoint = new Point(x1, y1); 形状子部分.Segments = 串线; 形状集合.Add(形状子部分); 形状.Figures = 形状集合; pathObject.Data = 形状; pathObject.Stroke = System.Windows.Media.Brushes.Black; pathObject.StrokeThickness = 1; //BezierSegment b = new BezierSegment(); //b.Point1 = new Point(x2, y2); //b.Point2 = new Point(x3, y3); //b.Point3 = new Point(x4, y4); LineSegment b = new LineSegment(); b.Point = new Point(x4, y4); 串线.Add(b); 串线.Add(new LineSegment() { Point = new Point() { Y = y4 - 10, X = x4 + 5 } }); 串线.Add(new LineSegment() { Point = new Point() { Y = y4 - 10, X = x4 + 4 } }); 串线.Add(new LineSegment() { Point = new Point() { Y = y4, X = x4 } }); 串线.Add(new LineSegment() { Point = new Point() { Y = y4 - 10, X = x4 - 5 } }); 串线.Add(new LineSegment() { Point = new Point() { Y = y4 - 10, X = x4 - 6 } }); Canvas.SetLeft(activityPath.标签, x1 + (x4 - x1) / 2); Canvas.SetTop(activityPath.标签, y4 - (y4 - y1) / 2); }