コード例 #1
0
        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);
            }
        }
コード例 #2
0
 public override AccessibleObject Navigate(AccessibleNavigation navdir)
 {
     if (((navdir == AccessibleNavigation.Up) || (navdir == AccessibleNavigation.Previous)) || ((navdir == AccessibleNavigation.Down) || (navdir == AccessibleNavigation.Next)))
     {
         DesignerNavigationDirection down = DesignerNavigationDirection.Down;
         if ((navdir == AccessibleNavigation.Up) || (navdir == AccessibleNavigation.Previous))
         {
             down = DesignerNavigationDirection.Up;
         }
         else
         {
             down = DesignerNavigationDirection.Down;
         }
         CompositeActivityDesigner parentDesigner = base.ActivityDesigner.ParentDesigner;
         if (parentDesigner != null)
         {
             object nextSelectableObject = parentDesigner.GetNextSelectableObject(base.ActivityDesigner.Activity, down);
             if (nextSelectableObject is ConnectorHitTestInfo)
             {
                 return(this.GetChild(((ConnectorHitTestInfo)nextSelectableObject).MapToIndex()));
             }
         }
     }
     return(base.Navigate(navdir));
 }
コード例 #3
0
ファイル: DragDropManager.cs プロジェクト: dox0/DotNet471RS3
        private void InitiateDragDrop()
        {
            WorkflowView      parentView       = ParentView;
            ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService));
            IDesignerHost     designerHost     = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (selectionService == null || designerHost == null)
            {
                return;
            }

            // check if we are cutting root component
            ICollection components = selectionService.GetSelectedComponents();

            if (components == null || components.Count < 1 || selectionService.GetComponentSelected(designerHost.RootComponent) || !Helpers.AreAllActivities(components))
            {
                return;
            }

            DragDropEffects effects = DragDropEffects.None;

            try
            {
                // get component serialization service
                this.existingDraggedActivities.AddRange(Helpers.GetTopLevelActivities(components));

                //IMPORTANT: FOR WITHIN DESIGNER COMPONENT MOVE WE REMOVE THE ACTIVITIES BEFORE WE ADD THEM WHICH IS IN
                //ONDRAGDROP FUNCTION. ALTHOUGH THIS VIOLATES THE DODRAGDROP FUNCTION SIMANTICS, WE NEED TO DO THIS
                //SO THAT WE CAN USE THE SAME IDS FOR THE ACTIVITIES
                DragDropEffects allowedEffects = (DesignerHelpers.AreAssociatedDesignersMovable(this.existingDraggedActivities)) ? DragDropEffects.Move | DragDropEffects.Copy : DragDropEffects.Copy;
                IDataObject     dataObject     = CompositeActivityDesigner.SerializeActivitiesToDataObject(ParentView, this.existingDraggedActivities.ToArray());
                effects = parentView.DoDragDrop(dataObject, allowedEffects);

                //
            }
            catch (Exception e)
            {
                DesignerHelpers.ShowError(ParentView, e.Message);
            }
            finally
            {
                //This means drag drop occurred across designer
                if (effects == DragDropEffects.Move && this.existingDraggedActivities.Count > 0)
                {
                    string transactionDescription = String.Empty;
                    if (this.existingDraggedActivities.Count > 1)
                    {
                        transactionDescription = SR.GetString(SR.MoveMultipleActivities, this.existingDraggedActivities.Count);
                    }
                    else
                    {
                        transactionDescription = SR.GetString(SR.MoveSingleActivity, this.existingDraggedActivities[0].GetType());
                    }

                    CompositeActivityDesigner.RemoveActivities(ParentView, this.existingDraggedActivities.AsReadOnly(), transactionDescription);
                }

                this.existingDraggedActivities.Clear();
            }
        }
コード例 #4
0
        private void EnsureValidDesignerPreview(ActivityDesigner designer)
        {
            CompositeActivityDesigner designer2 = designer as CompositeActivityDesigner;

            if ((designer2 != null) && designer2.Expanded)
            {
                ActivityPreviewDesignerTheme designerTheme = this.parentDesigner.DesignerTheme as ActivityPreviewDesignerTheme;
                if (designerTheme != null)
                {
                    System.Drawing.Size previewWindowSize = designerTheme.PreviewWindowSize;
                    System.Drawing.Size size = designer2.Size;
                    float num = ((float)previewWindowSize.Width) / ((float)size.Width);
                    if (Math.Min(num, ((float)previewWindowSize.Height) / ((float)size.Height)) < 0.1f)
                    {
                        if (!designer2.CanExpandCollapse && (designer2.ContainedDesigners.Count > 0))
                        {
                            designer2 = designer2.ContainedDesigners[0] as CompositeActivityDesigner;
                        }
                        if (designer2 != null)
                        {
                            designer2.Expanded = false;
                        }
                    }
                }
            }
        }
コード例 #5
0
        protected override bool OnMouseUp(MouseEventArgs eventArgs)
        {
            if ((Control.ModifierKeys & Keys.Shift) > 0)
            {
                base.OnMouseUp(eventArgs);

                //Select all the shapes
                WorkflowView parentView = ParentView;
                if (!DragRectangle.IsEmpty && parentView.RootDesigner != null)
                {
                    ActivityDesigner[] intersectingDesigners = CompositeActivityDesigner.GetIntersectingDesigners(parentView.RootDesigner, DragRectangle);
                    ArrayList          selectableComponents  = new ArrayList();
                    foreach (ActivityDesigner activityDesigner in intersectingDesigners)
                    {
                        selectableComponents.Add(activityDesigner.Activity);
                    }

                    ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
                    if (selectableComponents.Count > 0 && selectionService != null)
                    {
                        selectionService.SetSelectedComponents((object[])selectableComponents.ToArray(typeof(object)), SelectionTypes.Replace);
                    }
                }

                return(true);
            }
            return(false);
        }
コード例 #6
0
        protected override void OnDragDrop(ActivityDragEventArgs e)
        {
            base.OnDragDrop(e);

            bool ctrlKeyPressed = ((e.KeyState & 8) == 8);

            if (ctrlKeyPressed && (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy)
            {
                e.Effect = DragDropEffects.Copy;
            }
            else if ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move)
            {
                e.Effect = DragDropEffects.Move;
            }

            //If the component is sited then that means that we are moving it
            try
            {
                CompositeActivityDesigner.InsertActivities(this, new ConnectorHitTestInfo(this, HitTestLocations.Designer, CurrentDropTarget), e.Activities, SR.GetString(SR.DragDropActivities));
            }
            finally
            {
                CurrentDropTarget = -1;
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        protected override bool OnMouseUp(MouseEventArgs eventArgs)
        {
            if ((Control.ModifierKeys & Keys.Shift) <= Keys.None)
            {
                return(false);
            }
            base.OnMouseUp(eventArgs);
            WorkflowView parentView = base.ParentView;

            if (!base.DragRectangle.IsEmpty && (parentView.RootDesigner != null))
            {
                ActivityDesigner[] intersectingDesigners = CompositeActivityDesigner.GetIntersectingDesigners(parentView.RootDesigner, base.DragRectangle);
                ArrayList          list = new ArrayList();
                foreach (ActivityDesigner designer in intersectingDesigners)
                {
                    list.Add(designer.Activity);
                }
                ISelectionService service = base.GetService(typeof(ISelectionService)) as ISelectionService;
                if ((list.Count > 0) && (service != null))
                {
                    service.SetSelectedComponents((object[])list.ToArray(typeof(object)), SelectionTypes.Replace);
                }
            }
            return(true);
        }
コード例 #9
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;
         }
     }
 }
        private void SetAutoExpandableDesigner(CompositeActivityDesigner value)
        {
            if (this.autoExpandableDesigner == value)
            {
                return;
            }

            //We always remove this so that the timer counter gets reset
            if (value == null || value.Expanded || !value.CanExpandCollapse)
            {
                this.autoExpandableDesigner = null;
                if (this.autoExpandEventHandler != null)
                {
                    WorkflowTimer.Default.Unsubscribe(this.autoExpandEventHandler);
                    this.autoExpandEventHandler = null;
                }
            }
            else
            {
                //User has to hover for 2 seconds
                this.autoExpandableDesigner = value;
                if (this.autoExpandEventHandler == null)
                {
                    this.autoExpandEventHandler = new EventHandler(OnAutoExpand);
                    WorkflowTimer.Default.Subscribe(500, this.autoExpandEventHandler);
                }
            }
        }
コード例 #11
0
        public override AccessibleObject Navigate(AccessibleNavigation navdir)
        {
            if (navdir == AccessibleNavigation.Up || navdir == AccessibleNavigation.Previous ||
                navdir == AccessibleNavigation.Down || navdir == AccessibleNavigation.Next)
            {
                DesignerNavigationDirection navigate = default(DesignerNavigationDirection);
                if (navdir == AccessibleNavigation.Up || navdir == AccessibleNavigation.Previous)
                {
                    navigate = DesignerNavigationDirection.Up;
                }
                else
                {
                    navigate = DesignerNavigationDirection.Down;
                }

                CompositeActivityDesigner compositeDesigner = this.ActivityDesigner.ParentDesigner;
                if (compositeDesigner != null)
                {
                    object nextSelectableObj = compositeDesigner.GetNextSelectableObject(this.ActivityDesigner.Activity, navigate);
                    if (nextSelectableObj is ConnectorHitTestInfo)
                    {
                        return(GetChild(((ConnectorHitTestInfo)nextSelectableObj).MapToIndex()));
                    }
                }
            }

            return(base.Navigate(navdir));
        }
コード例 #12
0
        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;
                }
            }
        }
コード例 #13
0
 internal ContainedDesignSurface(IServiceProvider parentServiceProvider, CompositeActivityDesigner parentDesigner) : base(parentServiceProvider)
 {
     this.parentDesigner = parentDesigner;
     if (base.ServiceContainer != null)
     {
         base.ServiceContainer.RemoveService(typeof(ISelectionService));
     }
 }
コード例 #14
0
 public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
 {
     if (parentActivityDesigner == null)
     {
         throw new ArgumentNullException("parentActivity");
     }
     return((parentActivityDesigner.Activity is IfElseActivity) && base.CanBeParentedTo(parentActivityDesigner));
 }
コード例 #15
0
 private void OnMenuCopy(object sender, EventArgs e)
 {
     if (Helpers.AreAllActivities(this.selectionService.GetSelectedComponents()))
     {
         Activity[] topLevelActivities = Helpers.GetTopLevelActivities(this.selectionService.GetSelectedComponents());
         Clipboard.SetDataObject(CompositeActivityDesigner.SerializeActivitiesToDataObject(this.serviceProvider, topLevelActivities));
     }
 }
コード例 #16
0
 public ConnectorHitTestInfo(CompositeActivityDesigner compositeActivityDesigner, HitTestLocations flags, int connector) : base(compositeActivityDesigner, flags)
 {
     if (this.connector < 0)
     {
         throw new ArgumentException(SR.GetString("Error_InvalidConnectorValue"), "connector");
     }
     this.connector = connector;
 }
        public override AccessibleObject GetChild(int index)
        {
            CompositeActivityDesigner activityDesigner = base.ActivityDesigner as CompositeActivityDesigner;

            if ((index >= 0) && (index < activityDesigner.ContainedDesigners.Count))
            {
                return(activityDesigner.ContainedDesigners[index].AccessibilityObject);
            }
            return(base.GetChild(index));
        }
コード例 #18
0
        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());
                }
            }
        }
コード例 #19
0
 public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
 {
     for (Activity activity = parentActivityDesigner.Activity; activity != null; activity = activity.Parent)
     {
         if (((activity is CancellationHandlerActivity) || (activity is CompensationHandlerActivity)) || (activity is FaultHandlerActivity))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #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();
                        }
                    }
                }
            }
        }
コード例 #21
0
 public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
 {
     if (parentActivityDesigner == null)
     {
         throw new ArgumentNullException("parentActivity");
     }
     if ((!Type.GetType("System.Workflow.Activities.ListenActivity,System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35").IsAssignableFrom(parentActivityDesigner.Activity.GetType()) && !(parentActivityDesigner.Activity is EventHandlersActivity)) && !Type.GetType("System.Workflow.Activities.StateActivity,System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35").IsAssignableFrom(parentActivityDesigner.Activity.GetType()))
     {
         return(false);
     }
     return(base.CanBeParentedTo(parentActivityDesigner));
 }
コード例 #22
0
 public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
 {
     if (parentActivityDesigner == null)
     {
         throw new ArgumentNullException("parentActivity");
     }
     if ((parentActivityDesigner.Activity != null) && !(parentActivityDesigner.Activity is EventHandlingScopeActivity))
     {
         return(false);
     }
     return(base.CanBeParentedTo(parentActivityDesigner));
 }
コード例 #23
0
        public override AccessibleObject GetChild(int index)
        {
            CompositeActivityDesigner compositeDesigner = base.ActivityDesigner as CompositeActivityDesigner;

            if (index >= 0 && index < compositeDesigner.ContainedDesigners.Count)
            {
                return(compositeDesigner.ContainedDesigners[index].AccessibilityObject);
            }
            else
            {
                return(base.GetChild(index));
            }
        }
コード例 #24
0
        private List <ActivityDesigner> GetMatchingActivityDesigners(ActivityDesigner activityDesigner)
        {
            CompositeActivityDesigner rootDesigner = DesignerPainter.GetRootDesigner(activityDesigner);

            matchingActivityDesigner = new List <ActivityDesigner>();

            Walker activityTreeWalker = new Walker();

            activityTreeWalker.FoundActivity += new WalkerEventHandler(OnWalkerFoundActivity);
            activityTreeWalker.Walk(rootDesigner.Activity);

            return(matchingActivityDesigner);
        }
コード例 #25
0
ファイル: DragDropManager.cs プロジェクト: dox0/DotNet471RS3
        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);
        }
コード例 #26
0
        public override void EnsureVisibleContainedDesigner(ActivityDesigner containedDesigner)
        {
            if (containedDesigner == null)
            {
                throw new ArgumentNullException("containedDesigner");
            }

            //we could be collapsed, make sure the view itself is visible
            this.Expanded = true;

            ActivityDesigner activeDesigner = ActiveDesigner;

            if (containedDesigner != activeDesigner && containedDesigner != this)
            {
                DesignerView viewToActivate             = null;
                ReadOnlyCollection <DesignerView> views = ValidatedViews;

                //Go thru the views and check if the child designer is one of the views
                foreach (DesignerView view in views)
                {
                    if (containedDesigner == view.AssociatedDesigner)
                    {
                        viewToActivate = view;
                        break;
                    }
                }

                //This means that the child designer is in our main flow
                if (viewToActivate == null)
                {
                    viewToActivate = views[0];
                }

                ActiveView = viewToActivate;

                //Invoking a verb might change the shown view so we map again
                CompositeActivityDesigner activeCompositeDesigner = ActiveDesigner as CompositeActivityDesigner;
                if (activeCompositeDesigner != null)
                {
                    if (activeCompositeDesigner != this)
                    {
                        activeCompositeDesigner.EnsureVisibleContainedDesigner(containedDesigner);
                    }
                    else
                    {
                        base.EnsureVisibleContainedDesigner(containedDesigner);
                    }
                }
            }
        }
コード例 #27
0
        public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
        {
            if (parentActivityDesigner == null)
            {
                throw new ArgumentNullException("parentActivityDesigner");
            }

            if (!(parentActivityDesigner.Activity is FaultHandlersActivity))
            {
                return(false);
            }

            return(base.CanBeParentedTo(parentActivityDesigner));
        }
コード例 #28
0
        public static CompositeActivityDesigner GetRootDesigner(ActivityDesigner designer)
        {
            if (designer == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("designer");
            }

            CompositeActivityDesigner rootDesigner = designer.ParentDesigner;

            while (!rootDesigner.IsRootDesigner && rootDesigner.ParentDesigner != null)
            {
                rootDesigner = rootDesigner.ParentDesigner;
            }
            return(rootDesigner);
        }
コード例 #29
0
        private void OnAddBranch(object sender, EventArgs e)
        {
            CompositeActivity activity  = this.OnCreateNewBranch();
            CompositeActivity activity2 = base.Activity as CompositeActivity;

            if ((activity2 != null) && (activity != null))
            {
                int count = this.ContainedDesigners.Count;
                CompositeActivityDesigner.InsertActivities(this, new ConnectorHitTestInfo(this, HitTestLocations.Designer, activity2.Activities.Count), new List <Activity>(new Activity[] { activity }).AsReadOnly(), DR.GetString("AddingBranch", new object[] { activity.GetType().Name }));
                if ((this.ContainedDesigners.Count > count) && (this.ContainedDesigners.Count > 0))
                {
                    this.ContainedDesigners[this.ContainedDesigners.Count - 1].EnsureVisible();
                }
            }
        }
コード例 #30
0
        //Please note that before changing this algorithm, you need to know that changing this algorithm
        //will affect the z order of the designers and will affect the way glyphs are drawn.
        //Here what we are using depth first search algorithm to maintain the Z order.
        //Please note that even though one might think the algo might cause some inefficiency, the algo
        //has been timed for huge workflow and typically takes < 20ms to execute
        private ActivityDesigner[] GetActivityDesigners(Rectangle logicalViewPort)
        {
            //We need to go to the deepest point and then start drawing outwards
            List <ActivityDesigner> designerList = new List <ActivityDesigner>();
            bool viewPortEmpty = logicalViewPort.IsEmpty;

            ActivityDesigner rootDesigner = ActivityDesigner.GetSafeRootDesigner(ParentView);

            if (rootDesigner != null)
            {
                Stack <object> designerStack = new Stack <object>();

                designerStack.Push(rootDesigner);
                CompositeActivityDesigner compositeDesigner = rootDesigner as CompositeActivityDesigner;
                if (compositeDesigner != null && compositeDesigner.ContainedDesigners.Count > 0)
                {
                    designerStack.Push(compositeDesigner.ContainedDesigners);
                }

                while (designerStack.Count > 0)
                {
                    object      topOfStack = designerStack.Pop();
                    ICollection designers  = topOfStack as ICollection;
                    if (designers != null)
                    {
                        foreach (ActivityDesigner activityDesigner in designers)
                        {
                            if ((viewPortEmpty || logicalViewPort.IntersectsWith(activityDesigner.Bounds)) && activityDesigner.IsVisible)
                            {
                                designerStack.Push(activityDesigner);
                                compositeDesigner = activityDesigner as CompositeActivityDesigner;
                                if (compositeDesigner != null && compositeDesigner.ContainedDesigners.Count > 0)
                                {
                                    designerStack.Push(compositeDesigner.ContainedDesigners);
                                }
                            }
                        }
                    }
                    else
                    {
                        //Draw glyphs for composite designers
                        designerList.Add((ActivityDesigner)topOfStack);
                    }
                }
            }

            return(designerList.ToArray());
        }