private void selectState(StateMachine sm, State state) { if (sm.SelectedState != null) sm.SelectedState.Selected = false; sm.SelectedState = state; if (sm.SelectedState != null) sm.SelectedState.Selected = true; }
private void Props_Executed_ObjectBuilder(object sender, ExecutedRoutedEventArgs e) { App app = (App)App.Current; if (e.Parameter is Element) { Element stateMachine = e.Parameter as Element; if (stateMachine.Semantic == Element.ElementSemantic.STATEMACHINE) { Parameter transitions = null; foreach (Parameter param in stateMachine.Parameters) { if (param.Semantic == ParameterSemantic.TRANSITIONS) { transitions = param; break; } } if (transitions != null) { StateMachine sm = new StateMachine(stateMachine.Name, transitions, stateMachine.ParentGameObject.Elements); app.StateMachineWin.DataContext = sm; app.StateMachineWin.Show(); } } } }
private void deleteState(StateMachine sm, State state) { // copy transitions ObservableCollection<Transition> transitions = new ObservableCollection<Transition>(state.Transitions); // delete transitions from this state foreach (Transition t in transitions) { sm.Transitions.Remove(t); state.Transitions.Remove(t); } // delete transitions to this state foreach (State s in sm.States) { // copy transitions ObservableCollection<Transition> transitions2 = new ObservableCollection<Transition>(s.Transitions); foreach (Transition t2 in transitions2) { if (t2.To == state) { s.Transitions.Remove(t2); sm.Transitions.Remove(t2); } } } // delete state sm.States.Remove(state); }