static IEnumerable <UIElement> GetAllChildStateDesigners(UIElement stateDesigner)
        {
            List <UIElement> children = new List <UIElement>();
            StateDesigner    designer = stateDesigner as StateDesigner;

            if (designer != null && designer.StateContainerEditor != null)
            {
                children.AddRange(designer.StateContainerEditor.modelItemToUIElement.Values);
                foreach (UIElement child in designer.StateContainerEditor.modelItemToUIElement.Values)
                {
                    children.AddRange(GetAllChildStateDesigners(child));
                }
            }
            return(children);
        }
Пример #2
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.stateDesigner = ((Wxwinter.BPM.Machine.Design.StateDesigner)(target));
                return;

            case 2:

            #line 15 "..\..\..\Design\StateDesigner.xaml"
                ((System.Windows.Input.CommandBinding)(target)).CanExecute += new System.Windows.Input.CanExecuteRoutedEventHandler(this.OnSetAsInitialCanExecute);

            #line default
            #line hidden

            #line 15 "..\..\..\Design\StateDesigner.xaml"
                ((System.Windows.Input.CommandBinding)(target)).Executed += new System.Windows.Input.ExecutedRoutedEventHandler(this.OnSetAsInitialExecute);

            #line default
            #line hidden
                return;

            case 3:

            #line 20 "..\..\..\Design\StateDesigner.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Loaded += new System.Windows.RoutedEventHandler(this.OnStateSpecificMenuItemLoaded);

            #line default
            #line hidden
                return;

            case 5:
                this.stateContentPresenter = ((System.Windows.Controls.ContentPresenter)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #3
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.stateDesigner = ((Wxwinter.BPM.Machine.Design.StateDesigner)(target));
     return;
     case 2:
     
     #line 15 "..\..\..\Design\StateDesigner.xaml"
     ((System.Windows.Input.CommandBinding)(target)).CanExecute += new System.Windows.Input.CanExecuteRoutedEventHandler(this.OnSetAsInitialCanExecute);
     
     #line default
     #line hidden
     
     #line 15 "..\..\..\Design\StateDesigner.xaml"
     ((System.Windows.Input.CommandBinding)(target)).Executed += new System.Windows.Input.ExecutedRoutedEventHandler(this.OnSetAsInitialExecute);
     
     #line default
     #line hidden
     return;
     case 3:
     
     #line 20 "..\..\..\Design\StateDesigner.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Loaded += new System.Windows.RoutedEventHandler(this.OnStateSpecificMenuItemLoaded);
     
     #line default
     #line hidden
     return;
     case 5:
     this.stateContentPresenter = ((System.Windows.Controls.ContentPresenter)(target));
     return;
     }
     this._contentLoaded = true;
 }
        // referenceConnector is used when we are re-linking the connector.
        internal ConnectorCreationResult CreateConnectorGesture(ConnectionPoint sourceConnectionPoint, ConnectionPoint destConnectionPoint, Connector referenceConnector, bool isConnectorStartMoved)
        {
            Debug.Assert(this.IsOutmostStateContainerEditor(), "Should only be called by the outmost editor.");
            Debug.Assert(sourceConnectionPoint != null, "sourceConnectionPoint is null.");
            Debug.Assert(destConnectionPoint != null, "destConnectionPoint is null.");
            ConnectorCreationResult result = ConnectorCreationResult.OtherFailure;

            if (destConnectionPoint.PointType != ConnectionPointType.Outgoing && sourceConnectionPoint.PointType != ConnectionPointType.Incoming)
            {
                if (sourceConnectionPoint.ParentDesigner is StateDesigner)
                {
                    bool      sameDestination        = false;
                    ModelItem refTransitionModelItem = null;
                    if (referenceConnector != null)
                    {
                        refTransitionModelItem = StateContainerEditor.GetConnectorModelItem(referenceConnector);
                        ModelItem destStateModelItem = ((StateDesigner)destConnectionPoint.ParentDesigner).ModelItem;
                        if (refTransitionModelItem != null && refTransitionModelItem.Properties[TransitionDesigner.ToPropertyName].Value == destStateModelItem)
                        {
                            sameDestination = true;
                        }
                    }

                    // We do not allow transitions to composite states unless we don't change the transition destination
                    // (e.g., we are moving the start of a connector).
                    if (!sameDestination && !((StateDesigner)destConnectionPoint.ParentDesigner).IsSimpleState())
                    {
                        result = ConnectorCreationResult.CannotCreateTransitionToCompositeState;
                    }
                    // We do not allow transitions from an ancestor to its descendant
                    else if (StateContainerEditor.IsDescendantStateOf(((StateDesigner)destConnectionPoint.ParentDesigner).ModelItem, ((StateDesigner)sourceConnectionPoint.ParentDesigner).ModelItem))
                    {
                        result = ConnectorCreationResult.CannotCreateTransitionFromAncestorToDescendant;
                    }
                    else
                    {
                        using (EditingScope es = (EditingScope)this.ModelItem.BeginEdit(SR.CreateTransition))
                        {
                            if (refTransitionModelItem != null)
                            {
                                this.CreateTransition(sourceConnectionPoint, destConnectionPoint, refTransitionModelItem, isConnectorStartMoved);
                            }
                            else
                            {
                                this.CreateTransition(sourceConnectionPoint, destConnectionPoint, null, false);
                            }
                            result = ConnectorCreationResult.Success;
                            es.Complete();
                        }
                    }
                }
                else if (sourceConnectionPoint.ParentDesigner is InitialNode)
                {
                    StateDesigner destDesigner = (StateDesigner)destConnectionPoint.ParentDesigner;
                    // We only allow simple states to be set as the initial state
                    if (!destDesigner.IsSimpleState())
                    {
                        result = ConnectorCreationResult.CannotSetCompositeStateAsInitialState;
                    }
                    else if (destDesigner.IsFinalState())
                    {
                        result = ConnectorCreationResult.CannotSetFinalStateAsInitialState;
                    }
                    else
                    {
                        ModelItem destModelItem = destDesigner.ModelItem;
                        using (EditingScope es = (EditingScope)this.ModelItem.BeginEdit(SR.SetInitialState))
                        {
                            this.StateMachineModelItem.Properties[StateMachineDesigner.InitialStatePropertyName].SetValue(destModelItem);
                            PointCollection connectorViewState = new PointCollection(ConnectorRouter.Route(this.panel, sourceConnectionPoint, destConnectionPoint));
                            this.StoreConnectorLocationViewState(this.StateMachineModelItem, connectorViewState, true);
                            result = ConnectorCreationResult.Success;
                            es.Complete();
                        }
                    }
                }
            }
            return(result);
        }
 bool IsCreatingConnectorFromAncestorToDescendantStates(StateDesigner designer)
 {
     StateContainerEditor outmostEditor = this.GetOutmostStateContainerEditor();
     // Creating a new connector
     if (outmostEditor.activeSrcConnectionPoint != null)
     {
         StateDesigner sourceDesigner = outmostEditor.activeSrcConnectionPoint.ParentDesigner as StateDesigner;
         if (sourceDesigner != null)
         {
             if (StateContainerEditor.IsDescendantStateOf(designer.ModelItem, sourceDesigner.ModelItem))
             {
                 return true;
             }
         }
     }
     // Moving a connector
     else if (outmostEditor.panel.connectorEditor != null)
     {
         if (outmostEditor.panel.connectorEditor.IsConnectorEndBeingMoved)
         {
             if (StateContainerEditor.IsDescendantStateOf(designer.ModelItem,
                 StateContainerEditor.GetParentStateModelItemForTransition(StateContainerEditor.GetConnectorModelItem(outmostEditor.panel.connectorEditor.Connector))))
             {
                 return true;
             }
         }
         else if (outmostEditor.panel.connectorEditor.IsConnectorStartBeingMoved)
         {
             if (StateContainerEditor.IsDescendantStateOf(StateContainerEditor.GetConnectorModelItem(outmostEditor.panel.connectorEditor.Connector).Properties[TransitionDesigner.ToPropertyName].Value, designer.ModelItem))
             {
                 return true;
             }
         }
     }
     return false;
 }