コード例 #1
0
 protected internal virtual void OnConnectorChanged(ConnectorEventArgs e)
 {
     if (this.ConnectorChanged != null)
     {
         this.ConnectorChanged(this, e);
     }
 }
コード例 #2
0
 protected virtual void OnConnectorRemoved(ConnectorEventArgs e)
 {
     if (this.ConnectorRemoved != null)
     {
         this.ConnectorRemoved(this, e);
     }
 }
 protected virtual void OnConnectorRemoved(ConnectorEventArgs e)
 {
     if (this.ConnectorRemoved != null)
     {
         this.ConnectorRemoved(this, e);
     }
 }
 protected internal virtual void OnConnectorChanged(ConnectorEventArgs e)
 {
     if (this.ConnectorChanged != null)
     {
         this.ConnectorChanged(this, e);
     }
 }
コード例 #5
0
        protected override void OnConnectorRemoved(ConnectorEventArgs e)
        {
            base.OnConnectorRemoved(e);

            StateDesignerConnector connector = e.Connector as StateDesignerConnector;
            if (connector == null || string.IsNullOrEmpty(connector.SetStateName) || !this.RootStateDesigner.RemovingSetState)
                return;

            DesignerLayoutConnectionPoint sourceDesignerLayoutConnectionPoint = connector.Source as DesignerLayoutConnectionPoint;
            if (sourceDesignerLayoutConnectionPoint != null)
            {
                CompositeActivityDesigner compositeDesigner = StateDesigner.GetDesigner(sourceDesignerLayoutConnectionPoint.EventHandler) as CompositeActivityDesigner;
                if (compositeDesigner != null && sourceDesignerLayoutConnectionPoint.EventHandler != null)
                {
                    Activity setStateActivity = StateDesigner.FindActivityByQualifiedName(sourceDesignerLayoutConnectionPoint.EventHandler, connector.SetStateName);
                    if (setStateActivity != null)
                    {
                        List<Activity> activitiesToRemove = new List<Activity>();
                        activitiesToRemove.Add(setStateActivity);
                        CompositeActivityDesigner setStateParentDesigner = StateDesigner.GetDesigner(setStateActivity.Parent) as CompositeActivityDesigner;
                        if (setStateParentDesigner != null)
                            setStateParentDesigner.RemoveActivities(activitiesToRemove.AsReadOnly());
                    }
                }
            }
        }
コード例 #6
0
        protected override void OnConnectorChanged(ConnectorEventArgs e)
        {
            base.OnConnectorChanged(e);

            Connector connector = e.Connector;

            StateDesignerConnector stateDesignerConnector = connector as StateDesignerConnector;
            if (stateDesignerConnector == null)
                return;

            if (!stateDesignerConnector.Target.AssociatedDesigner.Activity.QualifiedName.Equals(stateDesignerConnector.TargetStateName))
            {
                StateActivity rootState = (StateActivity)this.RootStateDesigner.Activity;
                // target state has changed
                SetStateActivity setState = FindActivityByQualifiedName(rootState, stateDesignerConnector.SetStateName) as SetStateActivity;
                if (setState != null)
                {
                    StateActivity targetState = (StateActivity)stateDesignerConnector.Target.AssociatedDesigner.Activity;
                    PropertyDescriptor property = GetPropertyDescriptor(setState, SetStateActivity.TargetStateNamePropertyName);
                    property.SetValue(setState, targetState.QualifiedName);
                    stateDesignerConnector.TargetStateName = targetState.QualifiedName;
                }
            }

            StateDesigner.DesignerLayoutConnectionPoint sourceConnectionPoint = (StateDesigner.DesignerLayoutConnectionPoint)stateDesignerConnector.Source;
            if (!sourceConnectionPoint.EventHandler.QualifiedName.Equals(stateDesignerConnector.EventHandlerName))
            {
                StateActivity rootState = (StateActivity)this.RootStateDesigner.Activity;
                // source state has changed
                SetStateActivity setState = FindActivityByQualifiedName(rootState, stateDesignerConnector.SetStateName) as SetStateActivity;
                if (setState != null)
                {
                    IDesignerHost designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost;
                    DesignerTransaction transaction = null;
                    if (designerHost != null)
                        transaction = designerHost.CreateTransaction(SR.GetMoveSetState());

                    try
                    {
                        CompositeActivityDesigner previousSetStateParentDesigner = (CompositeActivityDesigner)StateDesigner.GetDesigner(setState.Parent);
                        List<Activity> activitiesToRemove = new List<Activity>();
                        activitiesToRemove.Add(setState);
                        previousSetStateParentDesigner.RemoveActivities(activitiesToRemove.AsReadOnly());

                        DesignerLayoutConnectionPoint source = (DesignerLayoutConnectionPoint)stateDesignerConnector.Source;
                        CompositeActivityDesigner newSetStateParentDesigner = (CompositeActivityDesigner)StateDesigner.GetDesigner(source.EventHandler);
                        List<Activity> activitiesToInsert = new List<Activity>();
                        activitiesToInsert.Add(setState);
                        newSetStateParentDesigner.InsertActivities(new HitTestInfo(newSetStateParentDesigner, HitTestLocations.Designer), activitiesToInsert.AsReadOnly());

                        stateDesignerConnector.EventHandlerName = source.EventHandler.QualifiedName;
                        stateDesignerConnector.SourceStateName = source.EventHandler.Parent.QualifiedName;

                        if (transaction != null)
                            transaction.Commit();
                    }
                    catch
                    {
                        if (transaction != null)
                            transaction.Cancel();

                        throw;
                    }
                }
            }
        }
コード例 #7
0
        protected override void OnConnectorAdded(ConnectorEventArgs e)
        {
            base.OnConnectorAdded(e);

            StateDesignerConnector connector = e.Connector as StateDesignerConnector;
            if (connector == null)
                return;

            // We need to make sure that the source connection point
            // is always the event handler
            DesignerLayoutConnectionPoint sourceDesignerLayoutConnectionPoint = connector.Source as DesignerLayoutConnectionPoint;
            DesignerLayoutConnectionPoint targetDesignerLayoutConnectionPoint = connector.Target as DesignerLayoutConnectionPoint;
            if (sourceDesignerLayoutConnectionPoint == null)
            {
                Debug.Assert(targetDesignerLayoutConnectionPoint != null);
                ConnectionPoint source = connector.Source;
                connector.Source = connector.Target;
                connector.Target = source;
            }
            else
            {
                Debug.Assert(targetDesignerLayoutConnectionPoint == null);
            }

            ConnectionPoint target = connector.Target;
            sourceDesignerLayoutConnectionPoint = (DesignerLayoutConnectionPoint)connector.Source;
            if (this.RootStateDesigner.AddingSetState)
            {
                SetStateActivity setState = new SetStateActivity();
                setState.TargetStateName = target.AssociatedDesigner.Activity.QualifiedName;
                CompositeActivityDesigner compositeDesigner = (CompositeActivityDesigner)StateDesigner.GetDesigner(sourceDesignerLayoutConnectionPoint.EventHandler);
                List<Activity> activitiesToInsert = new List<Activity>();
                activitiesToInsert.Add(setState);
                compositeDesigner.InsertActivities(new HitTestInfo(compositeDesigner, HitTestLocations.Designer), activitiesToInsert.AsReadOnly());
                connector.SetStateName = setState.QualifiedName;
            }
            connector.TargetStateName = target.AssociatedDesigner.Activity.QualifiedName;
            connector.SourceStateName = sourceDesignerLayoutConnectionPoint.EventHandler.Parent.QualifiedName;
            connector.EventHandlerName = sourceDesignerLayoutConnectionPoint.EventHandler.QualifiedName;
        }
コード例 #8
0
 /// <summary>
 /// Called when a new connector has been added in the freeform designer
 /// </summary>
 /// <param name="e">Event args containing connector</param>
 protected virtual void OnConnectorAdded(ConnectorEventArgs e)
 {
     if (ConnectorAdded != null)
         ConnectorAdded(this, e);
 }
コード例 #9
0
 protected override void OnConnectorRemoved(ConnectorEventArgs e)
 {
     base.OnConnectorRemoved(e);
     StateDesignerConnector connector = e.Connector as StateDesignerConnector;
     if (((connector != null) && !string.IsNullOrEmpty(connector.SetStateName)) && this.RootStateDesigner.RemovingSetState)
     {
         DesignerLayoutConnectionPoint source = connector.Source as DesignerLayoutConnectionPoint;
         if (((source != null) && (GetDesigner(source.EventHandler) is CompositeActivityDesigner)) && (source.EventHandler != null))
         {
             Activity activity = FindActivityByQualifiedName(source.EventHandler, connector.SetStateName);
             if (activity != null)
             {
                 List<Activity> list = new List<Activity> {
                     activity
                 };
                 CompositeActivityDesigner designer = GetDesigner(activity.Parent) as CompositeActivityDesigner;
                 if (designer != null)
                 {
                     designer.RemoveActivities(list.AsReadOnly());
                 }
             }
         }
     }
 }
コード例 #10
0
 protected override void OnConnectorChanged(ConnectorEventArgs e)
 {
     base.OnConnectorChanged(e);
     StateDesignerConnector connector = e.Connector as StateDesignerConnector;
     if (connector != null)
     {
         if (!connector.Target.AssociatedDesigner.Activity.QualifiedName.Equals(connector.TargetStateName))
         {
             StateActivity activity = (StateActivity) this.RootStateDesigner.Activity;
             SetStateActivity component = FindActivityByQualifiedName(activity, connector.SetStateName) as SetStateActivity;
             if (component != null)
             {
                 StateActivity activity3 = (StateActivity) connector.Target.AssociatedDesigner.Activity;
                 GetPropertyDescriptor(component, "TargetStateName").SetValue(component, activity3.QualifiedName);
                 connector.TargetStateName = activity3.QualifiedName;
             }
         }
         DesignerLayoutConnectionPoint source = (DesignerLayoutConnectionPoint) connector.Source;
         if (!source.EventHandler.QualifiedName.Equals(connector.EventHandlerName))
         {
             StateActivity activity4 = (StateActivity) this.RootStateDesigner.Activity;
             SetStateActivity activity5 = FindActivityByQualifiedName(activity4, connector.SetStateName) as SetStateActivity;
             if (activity5 != null)
             {
                 IDesignerHost service = base.GetService(typeof(IDesignerHost)) as IDesignerHost;
                 DesignerTransaction transaction = null;
                 if (service != null)
                 {
                     transaction = service.CreateTransaction(SR.GetMoveSetState());
                 }
                 try
                 {
                     ((CompositeActivityDesigner) GetDesigner(activity5.Parent)).RemoveActivities(new List<Activity> { activity5 }.AsReadOnly());
                     DesignerLayoutConnectionPoint point2 = (DesignerLayoutConnectionPoint) connector.Source;
                     CompositeActivityDesigner designer = (CompositeActivityDesigner) GetDesigner(point2.EventHandler);
                     designer.InsertActivities(new System.Workflow.ComponentModel.Design.HitTestInfo(designer, HitTestLocations.Designer), new List<Activity> { activity5 }.AsReadOnly());
                     connector.EventHandlerName = point2.EventHandler.QualifiedName;
                     connector.SourceStateName = point2.EventHandler.Parent.QualifiedName;
                     if (transaction != null)
                     {
                         transaction.Commit();
                     }
                 }
                 catch
                 {
                     if (transaction != null)
                     {
                         transaction.Cancel();
                     }
                     throw;
                 }
             }
         }
     }
 }
コード例 #11
0
 protected override void OnConnectorAdded(ConnectorEventArgs e)
 {
     base.OnConnectorAdded(e);
     StateDesignerConnector connector = e.Connector as StateDesignerConnector;
     if (connector != null)
     {
         DesignerLayoutConnectionPoint source = connector.Source as DesignerLayoutConnectionPoint;
         ConnectionPoint target = connector.Target;
         if (source == null)
         {
             ConnectionPoint point2 = connector.Source;
             connector.Source = connector.Target;
             connector.Target = point2;
         }
         ConnectionPoint point3 = connector.Target;
         source = (DesignerLayoutConnectionPoint) connector.Source;
         if (this.RootStateDesigner.AddingSetState)
         {
             SetStateActivity activity = new SetStateActivity {
                 TargetStateName = point3.AssociatedDesigner.Activity.QualifiedName
             };
             CompositeActivityDesigner designer = (CompositeActivityDesigner) GetDesigner(source.EventHandler);
             designer.InsertActivities(new System.Workflow.ComponentModel.Design.HitTestInfo(designer, HitTestLocations.Designer), new List<Activity> { activity }.AsReadOnly());
             connector.SetStateName = activity.QualifiedName;
         }
         connector.TargetStateName = point3.AssociatedDesigner.Activity.QualifiedName;
         connector.SourceStateName = source.EventHandler.Parent.QualifiedName;
         connector.EventHandlerName = source.EventHandler.QualifiedName;
     }
 }