示例#1
0
 private void AddTransition()
 {
     if (SelectedFigure != null && SelectedFigure is State)
     {
         Figure tempState = getFigureByPoint(panel1.PointToClient(Control.MousePosition));
         if (tempState != null && tempState is State)
         {
             TransitionNameForm tnf = new TransitionNameForm();
             tnf.ShowDialog();
             if (Program.NewTransitionName != null)
             {
                 foreach(Transition t in findAllTrasitionsFromState((SelectedFigure as State).Name))
                 {
                     if(t.Name == Program.NewTransitionName)
                     {
                         Program.NewTransitionName = null;
                         MessageBox.Show("Данное имя уже используется в другом переходе из состояния начала", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         return;
                     }
                 }
                 TransitionList.Add(new Transition(SelectedFigure as State, tempState as State, Program.NewTransitionName));
                 Program.NewTransitionName = null;
                 if ((SelectedFigure as State).Name == (tempState as State).Name)
                 {
                     TransitionList[TransitionList.Count - 1].InfList.Add(new InfPoint(tempState.X - 20, tempState.Y - 40));
                     TransitionList[TransitionList.Count - 1].InfList.Add(new InfPoint(tempState.X + 20, tempState.Y - 40));
                 }
             }
             SelectedFigure = null;
             tempState = null;
         }
     }
 }
示例#2
0
 private void renameTransitionClick(object sender, System.EventArgs e)
 {
     for (int i = 0; i < TransitionList.Count; i++)
     {
         if ((SelectedFigure as State).Name == TransitionList[i].Start.Name && SelectedTransitionMenu == TransitionList[i].Name)
         {
             TransitionNameForm tnf = new TransitionNameForm();
             tnf.ShowDialog();
             if (Program.NewTransitionName != null)
             {
                 foreach (Transition t in findAllTrasitionsFromState((SelectedFigure as State).Name))
                 {
                     if (t.Name == Program.NewTransitionName)
                     {
                         Program.NewTransitionName = null;
                         MessageBox.Show("Данное имя уже используется в другом переходе из состояния начала", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         return;
                     }
                 }
             }
             TransitionList[i].Name = Program.NewTransitionName; Program.NewTransitionName = null; break; }
     }
     Draw();
 }