AddAactivity() public method

public AddAactivity ( Activity activity ) : void
activity Activity
return void
        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;
        }
Beispiel #2
0
        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 Grid_MouseDown(object sender, MouseEventArgs e)
        {
            Grid  grid = sender as Grid;
            Point p    = Mouse.GetPosition(grid);
            Actor act  = grid.DataContext as Actor;

            if (tool == "添加活动")
            {
                if (p.X <= grid.Width)
                {
                    Activity activity = new Activity(act)
                    {
                        ActivityName = "新活动", Pos = p.X
                    };
                    act.AddAactivity(activity);
                    tool = "";
                }
                else
                {
                    MessageBox.Show("请点击相应的执行者!");
                }
            }
        }