/// <summary>
        /// Provides the state control which corresponds to the state provided
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        public StateControl getStateControl(State state)
        {
            StateControl retVal = null;

            if (state != null)
            {
                if (states.ContainsKey(state))
                {
                    retVal = states[state];
                }
            }

            return(retVal);
        }
        /// <summary>
        /// Refreshes the control according to the state machine
        /// </summary>
        public void RefreshControl()
        {
            try
            {
                refreshingControl = true;
                SuspendLayout();

                foreach (StateControl control in states.Values)
                {
                    control.Parent = null;
                }
                states.Clear();

                foreach (TransitionControl control in transitions.Values)
                {
                    control.Parent = null;
                }
                transitions.Clear();

                if (stateMachine != null)
                {
                    Text = stateMachine.Name;
                    foreach (State state in stateMachine.States)
                    {
                        StateControl stateControl = new StateControl();
                        states[state]       = stateControl;
                        stateControl.Parent = this;
                        stateControl.State  = state;
                    }
                    foreach (DataDictionary.Rules.Transition transition in stateMachine.Transitions)
                    {
                        TransitionControl transitionControl = new TransitionControl();
                        transitions[transition]      = transitionControl;
                        transitionControl.Parent     = this;
                        transitionControl.Transition = transition;
                    }
                    UpdateTransitionPosition();
                }
            }
            finally
            {
                refreshingControl = false;
                ResumeLayout(true);
            }

            Refresh();
        }
        /// <summary>
        /// Selects a model element
        /// </summary>
        /// <param name="model"></param>
        public void Select(object model)
        {
            if (StateDiagramWindow != null)
            {
                StateDiagramWindow.Select(model);
            }
            else
            {
                if (model is StateControl)
                {
                    StateControl control = model as StateControl;
                    MDIWindow.Select(control.State);
                }
                else if (model is TransitionControl)
                {
                    TransitionControl control = model as TransitionControl;
                    MDIWindow.Select(control.Transition.RuleCondition);
                }
            }

            Refresh();
        }
        /// <summary>
        /// Refreshes the control according to the state machine
        /// </summary>
        public void RefreshControl()
        {
            try
            {
                refreshingControl = true;
                SuspendLayout();

                foreach (StateControl control in states.Values)
                {
                    control.Parent = null;
                }
                states.Clear();

                foreach (TransitionControl control in transitions.Values)
                {
                    control.Parent = null;
                }
                transitions.Clear();

                if (stateMachine != null)
                {
                    Text = stateMachine.Name;
                    foreach (State state in stateMachine.States)
                    {
                        StateControl stateControl = new StateControl();
                        states[state] = stateControl;
                        stateControl.Parent = this;
                        stateControl.State = state;
                    }
                    foreach (DataDictionary.Rules.Transition transition in stateMachine.Transitions)
                    {
                        TransitionControl transitionControl = new TransitionControl();
                        transitions[transition] = transitionControl;
                        transitionControl.Parent = this;
                        transitionControl.Transition = transition;
                    }
                    UpdateTransitionPosition();
                }
            }
            finally
            {
                refreshingControl = false;
                ResumeLayout(true);
            }

            Refresh();
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="control"></param>
 public StateEditor(StateControl control)
 {
     this.control = control;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="control"></param>
 public StateEditor(StateControl control)
 {
     this.control = control;
 }