private void OnStatusDelete(object sender, EventArgs e)
        {
            MenuCommand command = (MenuCommand)sender;

            command.Enabled = false;
            IDesignerHost service = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (((service == null) || (service.RootComponent == null)) || !this.selectionService.GetComponentSelected(service.RootComponent))
            {
                ICollection selectedComponents = this.selectionService.GetSelectedComponents();
                if (DesignerHelpers.AreComponentsRemovable(selectedComponents))
                {
                    foreach (DictionaryEntry entry in Helpers.PairUpCommonParentActivities(Helpers.GetTopLevelActivities(selectedComponents)))
                    {
                        CompositeActivityDesigner designer = ActivityDesigner.GetDesigner(entry.Key as Activity) as CompositeActivityDesigner;
                        if ((designer != null) && !designer.CanRemoveActivities(new List <Activity>((Activity[])((ArrayList)entry.Value).ToArray(typeof(Activity))).AsReadOnly()))
                        {
                            command.Enabled = false;
                            return;
                        }
                    }
                    command.Enabled = true;
                }
            }
        }
        private void OnStatusEnable(object sender, EventArgs e)
        {
            MenuCommand command = (MenuCommand)sender;
            bool        enabled = true;
            bool        flag2   = true;
            ArrayList   list    = new ArrayList(this.selectionService.GetSelectedComponents());

            for (int i = 0; (i < list.Count) && flag2; i++)
            {
                Activity activity = list[i] as Activity;
                if (activity != null)
                {
                    ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);
                    if ((((designer == null) || designer.IsLocked) || ((i > 0) && (enabled != activity.Enabled))) || ((this.workflowView.RootDesigner != null) && (this.workflowView.RootDesigner.Activity == activity)))
                    {
                        flag2 = false;
                    }
                    else
                    {
                        enabled = activity.Enabled;
                    }
                }
                else
                {
                    flag2 = false;
                }
            }
            command.Visible = command.Enabled = flag2 && (((command.CommandID == WorkflowMenuCommands.Enable) && !enabled) || ((command.CommandID == WorkflowMenuCommands.Disable) && enabled));
        }
        private void OnExpandCollapse(object sender, EventArgs e)
        {
            MenuCommand command = (MenuCommand)sender;

            foreach (object obj2 in this.selectionService.GetSelectedComponents())
            {
                Activity activity = obj2 as Activity;
                if (activity != null)
                {
                    CompositeActivityDesigner designer = ActivityDesigner.GetDesigner(activity) as CompositeActivityDesigner;
                    if (designer != null)
                    {
                        designer.Expanded = command.CommandID.ID == WorkflowMenuCommands.Expand.ID;
                    }
                }
            }
            MenuCommand command2 = this.menuCommandService.FindCommand(WorkflowMenuCommands.Expand);

            if (command2 != null)
            {
                this.OnStatusExpandCollapse(command2, EventArgs.Empty);
            }
            MenuCommand command3 = this.menuCommandService.FindCommand(WorkflowMenuCommands.Collapse);

            if (command3 != null)
            {
                this.OnStatusExpandCollapse(command3, EventArgs.Empty);
            }
        }
Ejemplo n.º 4
0
        public override object GetNextSelectableObject(object obj, DesignerNavigationDirection direction)
        {
            if (base.ActiveDesigner != this)
            {
                return(base.GetNextSelectableObject(obj, direction));
            }
            if ((direction != DesignerNavigationDirection.Left) && (direction != DesignerNavigationDirection.Right))
            {
                return(null);
            }
            object activity = null;
            ReadOnlyCollection <ActivityDesigner> containedDesigners = this.ContainedDesigners;
            ActivityDesigner designer = ActivityDesigner.GetDesigner(obj as Activity);
            int num = (designer != null) ? containedDesigners.IndexOf(designer) : -1;

            if (((direction == DesignerNavigationDirection.Left) && (num >= 0)) && (num < containedDesigners.Count))
            {
                return(containedDesigners[(num > 0) ? (num - 1) : (containedDesigners.Count - 1)].Activity);
            }
            if ((direction == DesignerNavigationDirection.Right) && (num <= (containedDesigners.Count - 1)))
            {
                activity = containedDesigners[(num < (containedDesigners.Count - 1)) ? (num + 1) : 0].Activity;
            }
            return(activity);
        }
 protected override void OnContainedActivitiesChanging(ActivityCollectionChangeEventArgs listChangeArgs)
 {
     base.OnContainedActivitiesChanging(listChangeArgs);
     if (listChangeArgs.Action == ActivityCollectionChangeAction.Remove)
     {
         FreeformActivityDesigner connectorContainer = ConnectionManager.GetConnectorContainer(this);
         List <Connector>         list = new List <Connector>();
         for (ActivityDesigner designer2 = this; designer2 != null; designer2 = designer2.ParentDesigner)
         {
             FreeformActivityDesigner designer3 = designer2 as FreeformActivityDesigner;
             if ((designer3 != null) && (designer3.Connectors.Count > 0))
             {
                 foreach (Activity activity in listChangeArgs.RemovedItems)
                 {
                     ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);
                     if (!connectorContainer.MovingActivities.Contains(designer))
                     {
                         foreach (Connector connector in designer3.Connectors)
                         {
                             if ((designer == connector.Source.AssociatedDesigner) || (designer == connector.Target.AssociatedDesigner))
                             {
                                 list.Add(connector);
                             }
                         }
                     }
                 }
             }
         }
         foreach (Connector connector2 in list)
         {
             connector2.ParentDesigner.RemoveConnector(connector2);
             ((IDisposable)connector2).Dispose();
         }
     }
 }
Ejemplo n.º 6
0
        protected override bool OnMouseDoubleClick(MouseEventArgs eventArgs)
        {
            ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;

            if (selectionService != null)
            {
                ArrayList selectedComponents = new ArrayList(selectionService.GetSelectedComponents());
                for (int i = 0; i < selectedComponents.Count; i++)
                {
                    Activity selectedComponent = selectedComponents[i] as Activity;
                    if (selectedComponent == null)
                    {
                        continue;
                    }

                    IDesigner designer = ActivityDesigner.GetDesigner(selectedComponent) as IDesigner;
                    if (designer != null)
                    {
                        designer.DoDefaultAction();
                        ((IWorkflowDesignerMessageSink)designer).OnMouseDoubleClick(eventArgs);
                        break;
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 7
0
 public override System.Workflow.ComponentModel.Design.HitTestInfo HitTest(Point point)
 {
     System.Workflow.ComponentModel.Design.HitTestInfo nowhere = System.Workflow.ComponentModel.Design.HitTestInfo.Nowhere;
     if (this.Expanded && (base.ActiveDesigner == this))
     {
         if ((this.ContainedDesigners.Count == 0) && this.HelpTextRectangle.Contains(point))
         {
             return(new ConnectorHitTestInfo(this, HitTestLocations.Designer, 0));
         }
         if (this.previewStrip.Bounds.Contains(point))
         {
             System.Workflow.ComponentModel.Design.ItemInfo info2 = this.previewStrip.HitTest(point);
             ActivityDesigner designer = (info2 != null) ? ActivityDesigner.GetDesigner(info2.UserData[DesignerUserDataKeys.Activity] as Activity) : null;
             if (designer != null)
             {
                 return(new System.Workflow.ComponentModel.Design.HitTestInfo(designer, HitTestLocations.Designer));
             }
             return(new System.Workflow.ComponentModel.Design.HitTestInfo(this, HitTestLocations.ActionArea | HitTestLocations.Designer));
         }
         if ((this.ShowPreview && this.previewWindow.Bounds.Contains(point)) && ((this.previewWindow.PreviewMode || (this.PreviewedDesigner == null)) || !this.PreviewedDesigner.Bounds.Contains(point)))
         {
             return(new System.Workflow.ComponentModel.Design.HitTestInfo(this, HitTestLocations.ActionArea | HitTestLocations.Designer));
         }
         nowhere = base.HitTest(point);
         if ((this.ShowPreview && this.previewWindow.PreviewMode) && (nowhere.AssociatedDesigner != this))
         {
             nowhere = System.Workflow.ComponentModel.Design.HitTestInfo.Nowhere;
         }
         return(nowhere);
     }
     return(base.HitTest(point));
 }
Ejemplo n.º 8
0
        public override object GetNextSelectableObject(object obj, DesignerNavigationDirection direction)
        {
            if (ActiveDesigner != this)
            {
                return(base.GetNextSelectableObject(obj, direction));
            }

            if (direction != DesignerNavigationDirection.Left && direction != DesignerNavigationDirection.Right)
            {
                return(null);
            }

            object nextObject = null;

            ReadOnlyCollection <ActivityDesigner> containedDesigners = ContainedDesigners;
            ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(obj as Activity);
            int index = (activityDesigner != null) ? containedDesigners.IndexOf(activityDesigner) : -1;

            if (direction == DesignerNavigationDirection.Left && index >= 0 && index < containedDesigners.Count)
            {
                nextObject = ((ActivityDesigner)containedDesigners[(index > 0) ? index - 1 : containedDesigners.Count - 1]).Activity;
            }
            else if (direction == DesignerNavigationDirection.Right && index <= containedDesigners.Count - 1)
            {
                nextObject = ((ActivityDesigner)containedDesigners[(index < containedDesigners.Count - 1) ? index + 1 : 0]).Activity;
            }

            return(nextObject);
        }
Ejemplo n.º 9
0
 protected virtual void OnRefreshNode(WorkflowOutlineNode node)
 {
     if (node != null)
     {
         Activity activity = node.Activity;
         if (activity != null)
         {
             int num = (this.treeView.ImageList != null) ? this.treeView.ImageList.Images.IndexOfKey(activity.GetType().FullName) : -1;
             if (num == -1)
             {
                 ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);
                 if (designer != null)
                 {
                     Bitmap stockImage = designer.StockImage as Bitmap;
                     if (stockImage != null)
                     {
                         if (this.treeView.ImageList == null)
                         {
                             this.treeView.ImageList            = new ImageList();
                             this.treeView.ImageList.ColorDepth = ColorDepth.Depth32Bit;
                         }
                         this.treeView.ImageList.Images.Add(activity.GetType().FullName, stockImage);
                         num = this.treeView.ImageList.Images.Count - 1;
                     }
                 }
             }
             node.ImageIndex = node.SelectedImageIndex = num;
             node.RefreshNode();
         }
     }
 }
 internal static bool AreComponentsRemovable(ICollection components)
 {
     if (components == null)
     {
         throw new ArgumentNullException("components");
     }
     foreach (object obj2 in components)
     {
         Activity             activity = obj2 as Activity;
         ConnectorHitTestInfo info     = obj2 as ConnectorHitTestInfo;
         if ((activity == null) && (info == null))
         {
             return(false);
         }
         if (activity != null)
         {
             ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);
             if ((designer != null) && designer.IsLocked)
             {
                 return(false);
             }
         }
         if ((info != null) && !(info.AssociatedDesigner is FreeformActivityDesigner))
         {
             return(false);
         }
     }
     return(true);
 }
        public override void MoveActivities(System.Workflow.ComponentModel.Design.HitTestInfo moveLocation, ReadOnlyCollection <Activity> activitiesToMove)
        {
            if (moveLocation == null)
            {
                throw new ArgumentNullException("moveLocation");
            }
            if (activitiesToMove == null)
            {
                throw new ArgumentNullException("activitiesToMove");
            }
            FreeformActivityDesigner connectorContainer = ConnectionManager.GetConnectorContainer(this);

            try
            {
                connectorContainer.MovingActivities.Clear();
                if ((connectorContainer != null) && (connectorContainer.Connectors.Count > 0))
                {
                    foreach (Activity activity in activitiesToMove)
                    {
                        ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);
                        if (ConnectionManager.GetConnectorContainer(designer) == connectorContainer)
                        {
                            connectorContainer.MovingActivities.Add(designer);
                        }
                    }
                }
                base.MoveActivities(moveLocation, activitiesToMove);
            }
            finally
            {
                connectorContainer.MovingActivities.Clear();
            }
        }
        internal static Activity GetNextSelectableActivity(Activity currentActivity)
        {
            object                    obj2;
            ActivityDesigner          designer  = ActivityDesigner.GetDesigner(currentActivity);
            CompositeActivityDesigner designer2 = (designer != null) ? designer.ParentDesigner : null;

            if (designer2 == null)
            {
                return(null);
            }
            DesignerNavigationDirection direction = ((designer2 is ParallelActivityDesigner) || (designer2 is ActivityPreviewDesigner)) ? DesignerNavigationDirection.Right : DesignerNavigationDirection.Down;
            Activity activity = null;

            for (obj2 = designer2.GetNextSelectableObject(currentActivity, direction); ((activity == null) && (obj2 != null)) && (obj2 != currentActivity); obj2 = designer2.GetNextSelectableObject(obj2, direction))
            {
                activity = obj2 as Activity;
            }
            if (activity == null)
            {
                direction = ((designer2 is ParallelActivityDesigner) || (designer2 is ActivityPreviewDesigner)) ? DesignerNavigationDirection.Left : DesignerNavigationDirection.Up;
                for (obj2 = designer2.GetNextSelectableObject(currentActivity, direction); ((activity == null) && (obj2 != null)) && (obj2 != currentActivity); obj2 = designer2.GetNextSelectableObject(obj2, direction))
                {
                    activity = obj2 as Activity;
                }
            }
            if (activity == null)
            {
                activity = designer2.Activity;
            }
            return(activity);
        }
Ejemplo n.º 13
0
 public override void OnActivate()
 {
     if (this.AssociatedDesigner == null)
     {
         Type type = base.UserData[UserDataKey_ActivityType] as Type;
         CompositeActivity activity = this.parentDesigner.Activity as CompositeActivity;
         if (((type != null) && (activity != null)) && this.parentDesigner.IsEditable)
         {
             Activity activity2 = Activator.CreateInstance(type) as Activity;
             try
             {
                 CompositeActivityDesigner.InsertActivities(this.parentDesigner, new System.Workflow.ComponentModel.Design.HitTestInfo(this.parentDesigner, HitTestLocations.Designer), new List <Activity>(new Activity[] { activity2 }).AsReadOnly(), SR.GetString("AddingImplicitActivity"));
             }
             catch (Exception exception)
             {
                 if (exception != CheckoutException.Canceled)
                 {
                     IUIService service = this.parentDesigner.Activity.Site.GetService(typeof(IUIService)) as IUIService;
                     if (service != null)
                     {
                         service.ShowError(exception.Message);
                     }
                 }
             }
             ActivityDesigner designer = ActivityDesigner.GetDesigner(activity2);
             base.UserData[UserDataKey_Designer] = designer;
         }
     }
 }
Ejemplo n.º 14
0
        public override object GetNextSelectableObject(object obj, DesignerNavigationDirection direction)
        {
            if (ActiveDesigner != this)
            {
                return(base.GetNextSelectableObject(obj, direction));
            }

            if (direction != DesignerNavigationDirection.Down && direction != DesignerNavigationDirection.Up)
            {
                return(null);
            }

            object nextObject = null;
            ReadOnlyCollection <ActivityDesigner> containedDesigners = ContainedDesigners;

            if (direction == DesignerNavigationDirection.Down)
            {
                if (obj is ConnectorHitTestInfo)
                {
                    int currentIndex = ((ConnectorHitTestInfo)obj).MapToIndex();
                    if (currentIndex >= 0 && currentIndex < containedDesigners.Count)
                    {
                        nextObject = ((ActivityDesigner)containedDesigners[currentIndex]).Activity;
                    }
                }
                else if (obj is Activity)
                {
                    ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(obj as Activity);
                    int currentIndex = (activityDesigner != null) ? containedDesigners.IndexOf(activityDesigner) : -1;
                    if (currentIndex >= 0 && (currentIndex + 1) < GetConnectors().Length)
                    {
                        nextObject = new ConnectorHitTestInfo(this, HitTestLocations.Designer, currentIndex + 1);
                    }
                }
            }
            else if (direction == DesignerNavigationDirection.Up)
            {
                if (obj is ConnectorHitTestInfo)
                {
                    int currentIndex = ((ConnectorHitTestInfo)obj).MapToIndex();
                    if (currentIndex > 0 && currentIndex < GetConnectors().Length)
                    {
                        nextObject = ((ActivityDesigner)containedDesigners[currentIndex - 1]).Activity;
                    }
                }
                else if (obj is Activity)
                {
                    ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(obj as Activity);
                    int currentIndex = (activityDesigner != null) ? containedDesigners.IndexOf(activityDesigner) : -1;
                    if (currentIndex >= 0 && currentIndex < GetConnectors().Length)
                    {
                        nextObject = new ConnectorHitTestInfo(this, HitTestLocations.Designer, currentIndex);
                    }
                }
            }

            return(nextObject);
        }
Ejemplo n.º 15
0
        public override object GetNextSelectableObject(object obj, DesignerNavigationDirection direction)
        {
            if (base.ActiveDesigner != this)
            {
                return(base.GetNextSelectableObject(obj, direction));
            }
            if ((direction != DesignerNavigationDirection.Down) && (direction != DesignerNavigationDirection.Up))
            {
                return(null);
            }
            object activity = null;
            ReadOnlyCollection <ActivityDesigner> containedDesigners = this.ContainedDesigners;

            if (direction == DesignerNavigationDirection.Down)
            {
                if (obj is ConnectorHitTestInfo)
                {
                    int num = ((ConnectorHitTestInfo)obj).MapToIndex();
                    if ((num >= 0) && (num < containedDesigners.Count))
                    {
                        activity = containedDesigners[num].Activity;
                    }
                    return(activity);
                }
                if (obj is Activity)
                {
                    ActivityDesigner designer = ActivityDesigner.GetDesigner(obj as Activity);
                    int num2 = (designer != null) ? containedDesigners.IndexOf(designer) : -1;
                    if ((num2 >= 0) && ((num2 + 1) < this.GetConnectors().Length))
                    {
                        activity = new ConnectorHitTestInfo(this, HitTestLocations.Designer, num2 + 1);
                    }
                }
                return(activity);
            }
            if (direction == DesignerNavigationDirection.Up)
            {
                if (obj is ConnectorHitTestInfo)
                {
                    int num3 = ((ConnectorHitTestInfo)obj).MapToIndex();
                    if ((num3 > 0) && (num3 < this.GetConnectors().Length))
                    {
                        activity = containedDesigners[num3 - 1].Activity;
                    }
                    return(activity);
                }
                if (obj is Activity)
                {
                    ActivityDesigner designer2 = ActivityDesigner.GetDesigner(obj as Activity);
                    int connector = (designer2 != null) ? containedDesigners.IndexOf(designer2) : -1;
                    if ((connector >= 0) && (connector < this.GetConnectors().Length))
                    {
                        activity = new ConnectorHitTestInfo(this, HitTestLocations.Designer, connector);
                    }
                }
            }
            return(activity);
        }
        private void OnEnable(object sender, EventArgs e)
        {
            MenuCommand         command1         = (MenuCommand)sender;
            DesignerTransaction transaction      = null;
            IComponent          primarySelection = this.selectionService.PrimarySelection as IComponent;

            if ((primarySelection != null) && (primarySelection.Site != null))
            {
                IDesignerHost service = primarySelection.Site.GetService(typeof(IDesignerHost)) as IDesignerHost;
                if (service != null)
                {
                    transaction = service.CreateTransaction(SR.GetString("ChangingEnabled"));
                }
            }
            try
            {
                foreach (object obj2 in this.selectionService.GetSelectedComponents())
                {
                    Activity activity = obj2 as Activity;
                    if (activity != null)
                    {
                        ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);
                        if ((designer != null) && !designer.IsLocked)
                        {
                            PropertyDescriptor descriptor = TypeDescriptor.GetProperties(activity)["Enabled"];
                            if (descriptor != null)
                            {
                                descriptor.SetValue(activity, !activity.Enabled);
                            }
                        }
                    }
                }
                if (transaction != null)
                {
                    transaction.Commit();
                }
            }
            finally
            {
                if (transaction != null)
                {
                    ((IDisposable)transaction).Dispose();
                }
            }
            MenuCommand command = this.menuCommandService.FindCommand(WorkflowMenuCommands.Disable);

            if (command != null)
            {
                this.OnStatusEnable(command, EventArgs.Empty);
            }
            MenuCommand command2 = this.menuCommandService.FindCommand(WorkflowMenuCommands.Enable);

            if (command2 != null)
            {
                this.OnStatusEnable(command2, EventArgs.Empty);
            }
        }
Ejemplo n.º 17
0
            protected override void OnActivate(ActivityDesigner designer)
            {
                ActivityDesigner designer2 = ActivityDesigner.GetDesigner(this.item.UserData[DesignerUserDataKeys.Activity] as Activity);

                if (designer2 != null)
                {
                    base.OnActivate(designer2);
                }
            }
            public Size GetSize(Activity activity)
            {
                Size             empty    = Size.Empty;
                ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);

                if (designer != null)
                {
                    empty = designer.Size;
                }
                return(empty);
            }
            public Point GetLocation(Activity activity)
            {
                Point            empty    = Point.Empty;
                ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);

                if (designer != null)
                {
                    empty = designer.Location;
                }
                return(empty);
            }
Ejemplo n.º 20
0
        private void OnSelectionChanged(object sender, EventArgs e)
        {
            ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;

            if (selectionService == null || ActiveDesigner != this)
            {
                return;
            }

            foreach (ItemInfo itemInfo in this.previewStrip.Items)
            {
                if (itemInfo.UserData[DesignerUserDataKeys.Activity] == selectionService.PrimarySelection)
                {
                    this.previewStrip.ActiveItem = itemInfo;
                    break;
                }
            }

            //We need to make sure that for preview designer; if we select the designer using property grid or
            //any other means then selection is visible
            if (selectionService.SelectionCount == 1)
            {
                ActivityDesigner selectedDesigner = ActivityDesigner.GetDesigner(selectionService.PrimarySelection as Activity);
                if (selectedDesigner != null && !selectedDesigner.IsVisible && this != selectedDesigner.ParentDesigner)
                {
                    //PLEASE NOTE:
                    //We want to search if the current designer is ancestor of selected designer
                    //We do the search till we hit the immediate child of the "this" designer in ancestor chain
                    //so that if we are in preview mode then we make sure that we make the imamediate child of "this" visible
                    ActivityDesigner designer = selectedDesigner;
                    while (designer != null)
                    {
                        CompositeActivityDesigner parentDesigner = designer.ParentDesigner;
                        if (this == parentDesigner)
                        {
                            break;
                        }
                        designer = parentDesigner;
                    }

                    if (designer != null)
                    {
                        if (this.previewWindow != null && this.previewWindow.PreviewMode)
                        {
                            designer.EnsureVisible();
                        }
                        else
                        {
                            selectedDesigner.EnsureVisible();
                        }
                    }
                }
            }
        }
        private void OnStatusPaste(object sender, EventArgs e)
        {
            MenuCommand command = (MenuCommand)sender;

            command.Enabled = false;
            object primarySelection = this.selectionService.PrimarySelection;
            CompositeActivityDesigner parentDesigner = ActivityDesigner.GetDesigner(primarySelection as Activity) as CompositeActivityDesigner;

            if (parentDesigner == null)
            {
                parentDesigner = ActivityDesigner.GetParentDesigner(primarySelection);
            }
            if ((parentDesigner != null) && parentDesigner.IsEditable)
            {
                IDesignerHost   host       = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;
                IToolboxService service    = (IToolboxService)this.serviceProvider.GetService(typeof(IToolboxService));
                IDataObject     dataObject = Clipboard.GetDataObject();
                if (((dataObject != null) && (host != null)) && ((dataObject.GetDataPresent("CF_WINOEDESIGNERCOMPONENTS") || (service == null)) || service.IsSupported(dataObject, host)))
                {
                    System.Workflow.ComponentModel.Design.HitTestInfo insertLocation = null;
                    if (primarySelection is System.Workflow.ComponentModel.Design.HitTestInfo)
                    {
                        insertLocation = (System.Workflow.ComponentModel.Design.HitTestInfo)primarySelection;
                    }
                    else if (primarySelection is CompositeActivity)
                    {
                        insertLocation = new System.Workflow.ComponentModel.Design.HitTestInfo(parentDesigner, HitTestLocations.Designer);
                    }
                    else if (primarySelection is Activity)
                    {
                        Activity                  item     = primarySelection as Activity;
                        CompositeActivity         parent   = item.Parent;
                        CompositeActivityDesigner designer = ActivityDesigner.GetDesigner(parent) as CompositeActivityDesigner;
                        if (designer != null)
                        {
                            insertLocation = new ConnectorHitTestInfo(designer, HitTestLocations.Designer, parent.Activities.IndexOf(item) + 1);
                        }
                    }
                    ICollection activities = null;
                    try
                    {
                        activities = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(this.serviceProvider, dataObject);
                    }
                    catch (CheckoutException exception)
                    {
                        if (exception != CheckoutException.Canceled)
                        {
                            throw exception;
                        }
                    }
                    command.Enabled = ((activities != null) && (insertLocation != null)) && parentDesigner.CanInsertActivities(insertLocation, new List <Activity>(Helpers.GetTopLevelActivities(activities)).AsReadOnly());
                }
            }
        }
        protected override object CreateInstance(WorkflowMarkupSerializationManager serializationManager, Type type)
        {
            if (serializationManager == null)
            {
                throw new ArgumentNullException("serializationManager");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            Connector                connector = null;
            IReferenceService        service   = serializationManager.GetService(typeof(IReferenceService)) as IReferenceService;
            FreeformActivityDesigner designer  = serializationManager.Context[typeof(FreeformActivityDesigner)] as FreeformActivityDesigner;

            if ((designer != null) && (service != null))
            {
                ConnectionPoint source = null;
                ConnectionPoint target = null;
                try
                {
                    Dictionary <string, string> connectorConstructionArguments = this.GetConnectorConstructionArguments(serializationManager, type);
                    if ((connectorConstructionArguments.ContainsKey("SourceActivity") && connectorConstructionArguments.ContainsKey("SourceConnectionIndex")) && connectorConstructionArguments.ContainsKey("SourceConnectionEdge"))
                    {
                        ActivityDesigner associatedDesigner = ActivityDesigner.GetDesigner(service.GetReference(connectorConstructionArguments["SourceActivity"]) as Activity);
                        DesignerEdges    designerEdge       = (DesignerEdges)Enum.Parse(typeof(DesignerEdges), connectorConstructionArguments["SourceConnectionEdge"]);
                        int connectionIndex = Convert.ToInt32(connectorConstructionArguments["SourceConnectionIndex"], CultureInfo.InvariantCulture);
                        if (((associatedDesigner != null) && (designerEdge != DesignerEdges.None)) && (connectionIndex >= 0))
                        {
                            source = new ConnectionPoint(associatedDesigner, designerEdge, connectionIndex);
                        }
                    }
                    if ((connectorConstructionArguments.ContainsKey("TargetActivity") && connectorConstructionArguments.ContainsKey("TargetConnectionIndex")) && connectorConstructionArguments.ContainsKey("TargetConnectionEdge"))
                    {
                        ActivityDesigner designer3 = ActivityDesigner.GetDesigner(service.GetReference(connectorConstructionArguments["TargetActivity"]) as Activity);
                        DesignerEdges    edges2    = (DesignerEdges)Enum.Parse(typeof(DesignerEdges), connectorConstructionArguments["TargetConnectionEdge"]);
                        int num2 = Convert.ToInt32(connectorConstructionArguments["TargetConnectionIndex"], CultureInfo.InvariantCulture);
                        if (((designer3 != null) && (edges2 != DesignerEdges.None)) && (num2 >= 0))
                        {
                            target = new ConnectionPoint(designer3, edges2, num2);
                        }
                    }
                }
                catch
                {
                }
                if ((source != null) && (target != null))
                {
                    connector = designer.AddConnector(source, target);
                }
            }
            return(connector);
        }
Ejemplo n.º 23
0
        private void OnPropertyGridAdornments(ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList)
        {
            IComponent        component        = null;
            IReferenceService referenceService = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;

            if (referenceService != null)
            {
                component = referenceService.GetComponent(context.Instance);
            }

            string fullAliasName = string.Empty;
            //this attribue is set to overcome issue with the TypedVariableDeclarationTypeConverter
            //not returning Name property at all. we alias that property to the VariableDeclaration itself
            DefaultPropertyAttribute aliasPropertyNameAttribute = propDesc.Attributes[typeof(DefaultPropertyAttribute)] as DefaultPropertyAttribute;

            if (aliasPropertyNameAttribute != null && aliasPropertyNameAttribute.Name != null && aliasPropertyNameAttribute.Name.Length > 0)
            {
                fullAliasName = propDesc.Name + "." + aliasPropertyNameAttribute.Name;
            }

            if (component != null)
            {
                ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(component as Activity);
                if (activityDesigner != null)
                {
                    if (!activityDesigner.IsLocked && ActivityBindPropertyDescriptor.IsBindableProperty(propDesc) && !propDesc.IsReadOnly)
                    {
                        valueUIItemList.Add(new PropertyValueUIItem(DR.GetImage(DR.Bind), OnBindProperty, DR.GetString(DR.BindProperty)));
                    }

                    string fullComponentName = referenceService.GetName(component);        //schedule1.send1
                    string fullPropertyName  = referenceService.GetName(context.Instance); //schedule1.send1.message
                    fullPropertyName = (fullPropertyName.Length > fullComponentName.Length) ? fullPropertyName.Substring(fullComponentName.Length + 1, fullPropertyName.Length - fullComponentName.Length - 1) + "." + propDesc.Name : string.Empty;

                    foreach (DesignerAction action in activityDesigner.DesignerActions)
                    {
                        string actionPropertyName = action.PropertyName as string;
                        if (actionPropertyName == null || actionPropertyName.Length == 0)
                        {
                            continue;
                        }

                        if (actionPropertyName == propDesc.Name || (actionPropertyName == fullPropertyName) || (actionPropertyName == fullAliasName))
                        {
                            PropertyValueUIItemHandler propValueUIItemhandler = new PropertyValueUIItemHandler(action);
                            valueUIItemList.Add(new PropertyValueUIItem(action.Image, propValueUIItemhandler.OnFixPropertyError, action.Text));
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 24
0
        internal bool IsValidDropContext(HitTestInfo dropLocation)
        {
            if (this.draggedActivities.Count == 0)
            {
                return(false);
            }

            if (dropLocation == null || dropLocation.AssociatedDesigner == null)
            {
                return(false);
            }

            CompositeActivityDesigner compositeDesigner = dropLocation.AssociatedDesigner as CompositeActivityDesigner;

            if (compositeDesigner == null)
            {
                return(false);
            }

            if (!compositeDesigner.IsEditable || !compositeDesigner.CanInsertActivities(dropLocation, new List <Activity>(this.draggedActivities).AsReadOnly()))
            {
                return(false);
            }

            if (!this.wasCtrlKeyPressed && this.existingDraggedActivities.Count > 0)
            {
                //We are trying to move the actvities with designer
                if (!DesignerHelpers.AreAssociatedDesignersMovable(this.draggedActivities))
                {
                    return(false);
                }

                if (IsRecursiveDropOperation(dropLocation.AssociatedDesigner))
                {
                    return(false);
                }

                IDictionary commonParentActivities = Helpers.PairUpCommonParentActivities(this.draggedActivities);
                foreach (DictionaryEntry entry in commonParentActivities)
                {
                    CompositeActivityDesigner compositeActivityDesigner = ActivityDesigner.GetDesigner(entry.Key as Activity) as CompositeActivityDesigner;
                    Activity[] activitiesToMove = (Activity[])((ArrayList)entry.Value).ToArray(typeof(Activity));
                    if (compositeActivityDesigner != null && !compositeActivityDesigner.CanMoveActivities(dropLocation, new List <Activity>(activitiesToMove).AsReadOnly()))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 25
0
        private void OnRefreshTasks(object sender, EventArgs e)
        {
            WorkflowView workflowView = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;

            if (this.refreshTasksHandler != null)
            {
                if (workflowView != null)
                {
                    workflowView.Idle -= this.refreshTasksHandler;
                }
                this.refreshTasksHandler = null;
            }

            ISelectionService  selectionService  = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService;
            IExtendedUIService extendedUIService = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService;

            if (selectionService != null && extendedUIService != null)
            {
                extendedUIService.RemoveDesignerActions();

                //Only if the current designer is active designer we add the designer actions to the task list
                IDesignerEventService designerEventService = (IDesignerEventService)this.serviceProvider.GetService(typeof(IDesignerEventService));
                if (designerEventService != null && designerEventService.ActiveDesigner == this.serviceProvider.GetService(typeof(IDesignerHost)))
                {
                    foreach (object obj in selectionService.GetSelectedComponents())
                    {
                        ActivityDesigner activityDesigner = null;
                        if (obj is HitTestInfo)
                        {
                            activityDesigner = ((HitTestInfo)obj).AssociatedDesigner;
                        }
                        else if (obj is Activity)
                        {
                            activityDesigner = ActivityDesigner.GetDesigner(obj as Activity);
                        }

                        if (activityDesigner != null)
                        {
                            extendedUIService.AddDesignerActions(new List <DesignerAction>(activityDesigner.DesignerActions).ToArray());
                        }
                    }
                }
            }

            if (workflowView != null)
            {
                workflowView.Invalidate();
            }
        }
        bool IExtenderProvider.CanExtend(object extendee)
        {
            bool     flag     = false;
            Activity activity = extendee as Activity;

            if (((activity != null) && (activity.Site != null)) && (activity == Helpers.GetRootActivity(activity)))
            {
                ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);
                if ((designer != null) && (designer.ParentDesigner == null))
                {
                    flag = true;
                }
            }
            return(flag);
        }
            bool IExtenderProvider.CanExtend(object extendee)
            {
                bool     flag     = false;
                Activity activity = extendee as Activity;

                if (activity != null)
                {
                    ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);
                    if ((designer != null) && (((designer.ParentDesigner != null) ? (designer.ParentDesigner as FreeformActivityDesigner) : (designer as FreeformActivityDesigner)) != null))
                    {
                        flag = true;
                    }
                }
                return(flag);
            }
            public void SetSize(Activity activity, Size size)
            {
                ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);

                if (designer != null)
                {
                    FreeformActivityDesigner designer2 = (designer.ParentDesigner != null) ? (designer.ParentDesigner as FreeformActivityDesigner) : (designer as FreeformActivityDesigner);
                    if (designer2 != null)
                    {
                        designer.Size = size;
                        if (designer2.AutoSize)
                        {
                            designer2.PerformLayout();
                        }
                    }
                }
            }
        public override object GetNextSelectableObject(object current, DesignerNavigationDirection navigate)
        {
            object           activity = null;
            ArrayList        list     = new ArrayList(this.ContainedDesigners);
            ActivityDesigner designer = (current is Activity) ? ActivityDesigner.GetDesigner(current as Activity) : ActivityDesigner.GetParentDesigner(current);
            int num = (designer != null) ? list.IndexOf(designer) : -1;

            if (((navigate == DesignerNavigationDirection.Left) || (navigate == DesignerNavigationDirection.Up)) && ((num >= 0) && (num < list.Count)))
            {
                return(((ActivityDesigner)list[(num > 0) ? (num - 1) : (list.Count - 1)]).Activity);
            }
            if (((navigate == DesignerNavigationDirection.Right) || (navigate == DesignerNavigationDirection.Down)) && (num <= (list.Count - 1)))
            {
                activity = ((ActivityDesigner)list[(num < (list.Count - 1)) ? (num + 1) : 0]).Activity;
            }
            return(activity);
        }
 public override void InsertActivities(System.Workflow.ComponentModel.Design.HitTestInfo insertLocation, ReadOnlyCollection <Activity> activitiesToInsert)
 {
     base.InsertActivities(insertLocation, activitiesToInsert);
     if (this.AutoSize)
     {
         Size  autoSizeMargin = this.AutoSizeMargin;
         Point location       = this.Location;
         foreach (Activity activity in activitiesToInsert)
         {
             ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);
             if (designer.Location.IsEmpty)
             {
                 designer.Location = new Point(location.X + autoSizeMargin.Width, location.Y + autoSizeMargin.Height);
             }
         }
     }
 }