public MainWindow() { InitializeComponent(); //ui_line.Start = new Point(0, 0); //ui_line.End = new Point(50, 50); //测试数据 actor = new Actor(diagram) { acName = "abc" }; Activity activity = new Activity(actor) { ActivityName = "ddd", Pos = 100 }; actor.AddAactivity(activity); Actor act = new Actor(diagram) { acName = "cba" }; Activity activity1 = new Activity(act) { ActivityName = "1231", Pos = 300 }; act.AddAactivity(activity1); diagram.AddActors(actor); diagram.AddActors(act); Transfer transtar = new Transfer(activity,activity1); diagram.AddTransfer(transtar); ui_Diagram.DataContext = diagram; //ui_ActorListBox.ItemsSource = diagram.Actors; //ui_Transfer.ItemsSource = diagram.Transfer; }
//活动鼠标释放事件 private void Activity_MouseUp(object sender, MouseEventArgs e) { if (lineStart == null) { return; } FrameworkElement startElement = sender as FrameworkElement; Activity lineEnd = startElement.DataContext as Activity; Transfer trans = new Transfer(lineStart, lineEnd); diagram.AddTransfer(trans); lineStart = null; }
//添加转移线 public void AddTransfer(Transfer transfer) { transfers.Add(transfer); }