Esempio n. 1
0
        public void ReloadWorkflowOutline()
        {
            this.OnBeginUpdate();
            this.treeView.BeginUpdate();
            try
            {
                this.treeView.Nodes.Clear();
                this.activityToNodeMapping.Clear();
                IRootDesigner safeRootDesigner = ActivityDesigner.GetSafeRootDesigner(this.serviceProvider);
                if (((safeRootDesigner != null) && (safeRootDesigner.Component != null)) && (safeRootDesigner.Component is Activity))
                {
                    this.InsertDocOutlineNode(null, safeRootDesigner.Component as Activity, 0, true);
                }
                if (this.NeedsExpandAll)
                {
                    this.treeView.ExpandAll();
                }
            }
            finally
            {
                this.treeView.EndUpdate();
            }
            this.IsDirty = false;
            ISelectionService service = this.GetService(typeof(ISelectionService)) as ISelectionService;

            if ((service != null) && (service.PrimarySelection != null))
            {
                this.treeView.SelectedNode = this.activityToNodeMapping[service.PrimarySelection] as WorkflowOutlineNode;
                if (this.treeView.SelectedNode != null)
                {
                    this.treeView.SelectedNode.EnsureVisible();
                }
            }
            this.OnEndUpdate();
        }
        public static Point[] Route(IServiceProvider serviceProvider, object source, object target, ICollection <Rectangle> userDefinedRoutingObstacles)
        {
            List <Rectangle> list;
            List <Point>     list2;
            List <Point>     list3;

            GetRoutingObstacles(serviceProvider, source, target, out list, out list2, out list3);
            if (userDefinedRoutingObstacles != null)
            {
                list.AddRange(userDefinedRoutingObstacles);
            }
            ActivityDesigner safeRootDesigner = ActivityDesigner.GetSafeRootDesigner(serviceProvider);
            AmbientTheme     ambientTheme     = WorkflowTheme.CurrentTheme.AmbientTheme;
            Point            begin            = (source is ConnectionPoint) ? ((ConnectionPoint)source).Location : ((Point)source);
            Point            end = (target is ConnectionPoint) ? ((ConnectionPoint)target).Location : ((Point)target);

            Point[] segments = ConnectorRouter.Route(begin, end, new Size(2 * ambientTheme.Margin.Width, 2 * ambientTheme.Margin.Height), safeRootDesigner.Bounds, list.ToArray(), list2.ToArray(), list3.ToArray());
            if (!AreAllSegmentsVerticalOrHorizontal(segments))
            {
                segments = ConnectorRouter.Route(begin, end, ambientTheme.Margin, safeRootDesigner.Bounds, new Rectangle[0], list2.ToArray(), new Point[0]);
            }
            if (!AreAllSegmentsVerticalOrHorizontal(segments))
            {
                Point point3 = (DesignerGeometryHelper.SlopeOfLineSegment(begin, end) < 1f) ? new Point(end.X, begin.Y) : new Point(begin.X, end.Y);
                segments = new Point[] { begin, point3, end };
            }
            return(segments);
        }
Esempio n. 3
0
        private void LoadDesignerLayoutFromResource(out IList layoutErrors)
        {
            layoutErrors = null;
            IWorkflowRootDesigner safeRootDesigner = ActivityDesigner.GetSafeRootDesigner(base.LoaderHost);

            if ((safeRootDesigner != null) && safeRootDesigner.SupportsLayoutPersistence)
            {
                Type   type = safeRootDesigner.Component.GetType();
                string manifestResourceName = type.Name + ".layout";
                this.LoadDesignerLayoutFromResource(type, manifestResourceName, out layoutErrors);
            }
        }
 private IWorkflowRootDesigner LoadHostedWorkflow()
 {
     if (this.RootActivity == null)
     {
         return(null);
     }
     this.containedLoader        = new ContainedDesignerLoader(this.RootActivity);
     this.containedDesignSurface = new ContainedDesignSurface(base.Activity.Site, this);
     if (!this.containedDesignSurface.IsLoaded)
     {
         this.containedDesignSurface.BeginLoad(this.containedLoader);
     }
     return(ActivityDesigner.GetSafeRootDesigner(this.containedDesignSurface.GetService(typeof(IDesignerHost)) as IServiceProvider));
 }
        private void OnMenuSelectAll(object sender, EventArgs e)
        {
            ActivityDesigner safeRootDesigner = ActivityDesigner.GetSafeRootDesigner(this.serviceProvider);

            if (safeRootDesigner != null)
            {
                List <Activity> list = new List <Activity>();
                if (safeRootDesigner.Activity is CompositeActivity)
                {
                    list.AddRange(Helpers.GetNestedActivities(safeRootDesigner.Activity as CompositeActivity));
                }
                this.selectionService.SetSelectedComponents(list.ToArray(), SelectionTypes.Replace);
            }
        }
        //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());
        }
Esempio n. 7
0
        private void LoadDesignerLayoutFromResource(out IList layoutErrors)
        {
            layoutErrors = null;

            IWorkflowRootDesigner rootDesigner = ActivityDesigner.GetSafeRootDesigner(LoaderHost);

            if (rootDesigner == null || !rootDesigner.SupportsLayoutPersistence)
            {
                return;
            }

            Type   rootActivityType = rootDesigner.Component.GetType();
            string resourceName     = rootActivityType.Name + WorkflowDesignerLoader.DesignerLayoutFileExtension;

            LoadDesignerLayoutFromResource(rootActivityType, resourceName, out layoutErrors);
        }
Esempio n. 8
0
 private IWorkflowRootDesigner LoadHostedWorkflow()
 {
     if (RootActivity != null)
     {
         this.containedLoader        = new ContainedDesignerLoader(RootActivity as Activity);
         this.containedDesignSurface = new ContainedDesignSurface(Activity.Site, this);
         if (this.containedDesignSurface.IsLoaded == false)
         {
             this.containedDesignSurface.BeginLoad(this.containedLoader);
         }
         return(ActivityDesigner.GetSafeRootDesigner(this.containedDesignSurface.GetService(typeof(IDesignerHost)) as IServiceProvider) as IWorkflowRootDesigner);
     }
     else
     {
         return(null);
     }
 }
        private ActivityDesigner[] GetActivityDesigners(Rectangle logicalViewPort)
        {
            List <ActivityDesigner> list      = new List <ActivityDesigner>();
            bool             isEmpty          = logicalViewPort.IsEmpty;
            ActivityDesigner safeRootDesigner = ActivityDesigner.GetSafeRootDesigner(base.ParentView);

            if (safeRootDesigner != null)
            {
                Stack <object> stack = new Stack <object>();
                stack.Push(safeRootDesigner);
                CompositeActivityDesigner designer2 = safeRootDesigner as CompositeActivityDesigner;
                if ((designer2 != null) && (designer2.ContainedDesigners.Count > 0))
                {
                    stack.Push(designer2.ContainedDesigners);
                }
                while (stack.Count > 0)
                {
                    object      obj2 = stack.Pop();
                    ICollection is2  = obj2 as ICollection;
                    if (is2 != null)
                    {
                        foreach (ActivityDesigner designer3 in is2)
                        {
                            if ((isEmpty || logicalViewPort.IntersectsWith(designer3.Bounds)) && designer3.IsVisible)
                            {
                                stack.Push(designer3);
                                designer2 = designer3 as CompositeActivityDesigner;
                                if ((designer2 != null) && (designer2.ContainedDesigners.Count > 0))
                                {
                                    stack.Push(designer2.ContainedDesigners);
                                }
                            }
                        }
                    }
                    else
                    {
                        list.Add((ActivityDesigner)obj2);
                    }
                }
            }
            return(list.ToArray());
        }
Esempio n. 10
0
        private void SaveDesignerLayout()
        {
            string           layoutFileName = DesignerLayoutFileName;
            ActivityDesigner rootDesigner   = ActivityDesigner.GetSafeRootDesigner(LoaderHost);

            if (String.IsNullOrEmpty(layoutFileName) || rootDesigner == null || !rootDesigner.SupportsLayoutPersistence)
            {
                return;
            }

            using (TextWriter layoutWriter = GetFileWriter(layoutFileName))
            {
                if (layoutWriter != null)
                {
                    IList layoutErrors = null;
                    using (XmlWriter xmlWriter = Helpers.CreateXmlWriter(layoutWriter))
                        SaveDesignerLayout(xmlWriter, rootDesigner, out layoutErrors);
                }
            }
        }
Esempio n. 11
0
        private void SaveDesignerLayout()
        {
            string           designerLayoutFileName = this.DesignerLayoutFileName;
            ActivityDesigner safeRootDesigner       = ActivityDesigner.GetSafeRootDesigner(base.LoaderHost);

            if ((!string.IsNullOrEmpty(designerLayoutFileName) && (safeRootDesigner != null)) && safeRootDesigner.SupportsLayoutPersistence)
            {
                using (TextWriter writer = this.GetFileWriter(designerLayoutFileName))
                {
                    if (writer != null)
                    {
                        IList layoutSaveErrors = null;
                        using (XmlWriter writer2 = Helpers.CreateXmlWriter(writer))
                        {
                            this.SaveDesignerLayout(writer2, safeRootDesigner, out layoutSaveErrors);
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        private void LoadDesignerLayout(out IList layoutErrors)
        {
            layoutErrors = null;
            string designerLayoutFileName          = this.DesignerLayoutFileName;
            IWorkflowRootDesigner safeRootDesigner = ActivityDesigner.GetSafeRootDesigner(base.LoaderHost);

            if (((safeRootDesigner != null) && safeRootDesigner.SupportsLayoutPersistence) && File.Exists(designerLayoutFileName))
            {
                using (TextReader reader = this.GetFileReader(designerLayoutFileName))
                {
                    if (reader != null)
                    {
                        using (XmlReader reader2 = XmlReader.Create(reader))
                        {
                            this.LoadDesignerLayout(reader2, out layoutErrors);
                        }
                    }
                }
            }
        }
Esempio n. 13
0
        private void LoadDesignerLayout(out IList layoutErrors)
        {
            layoutErrors = null;

            string layoutFileName = DesignerLayoutFileName;
            IWorkflowRootDesigner rootDesigner = ActivityDesigner.GetSafeRootDesigner(LoaderHost);

            if (rootDesigner == null || !rootDesigner.SupportsLayoutPersistence || !File.Exists(layoutFileName))
            {
                return;
            }

            using (TextReader layoutReader = GetFileReader(layoutFileName))
            {
                if (layoutReader != null)
                {
                    using (XmlReader xmlReader = XmlReader.Create(layoutReader))
                        LoadDesignerLayout(xmlReader, out layoutErrors);
                }
            }
        }
        public static void GetRoutingObstacles(IServiceProvider serviceProvider, object source, object target, out List <Rectangle> rectanglesToExclude, out List <Point> linesToExclude, out List <Point> pointsToExclude)
        {
            AmbientTheme     ambientTheme                 = WorkflowTheme.CurrentTheme.AmbientTheme;
            ActivityDesigner safeRootDesigner             = ActivityDesigner.GetSafeRootDesigner(serviceProvider);
            ConnectionPoint  point                        = source as ConnectionPoint;
            Point            point2                       = (point != null) ? point.Location : ((Point)source);
            ActivityDesigner designer                     = (point != null) ? point.AssociatedDesigner : safeRootDesigner.HitTest(point2).AssociatedDesigner;
            ConnectionPoint  point3                       = target as ConnectionPoint;
            Point            point4                       = (point3 != null) ? point3.Location : ((Point)target);
            ActivityDesigner designer3                    = (point3 != null) ? point3.AssociatedDesigner : safeRootDesigner.HitTest(point4).AssociatedDesigner;
            Dictionary <int, ActivityDesigner> dictionary = new Dictionary <int, ActivityDesigner>();

            if (designer != null)
            {
                for (CompositeActivityDesigner designer4 = designer.ParentDesigner; designer4 != null; designer4 = designer4.ParentDesigner)
                {
                    if (dictionary.ContainsKey(designer4.GetHashCode()))
                    {
                        break;
                    }
                    dictionary.Add(designer4.GetHashCode(), designer4);
                }
            }
            if (designer3 != null)
            {
                for (CompositeActivityDesigner designer5 = designer3.ParentDesigner; designer5 != null; designer5 = designer5.ParentDesigner)
                {
                    if (dictionary.ContainsKey(designer5.GetHashCode()))
                    {
                        break;
                    }
                    dictionary.Add(designer5.GetHashCode(), designer5);
                }
            }
            rectanglesToExclude = new List <Rectangle>();
            pointsToExclude     = new List <Point>();
            foreach (CompositeActivityDesigner designer6 in dictionary.Values)
            {
                ReadOnlyCollection <ActivityDesigner> containedDesigners = designer6.ContainedDesigners;
                for (int i = 0; i < containedDesigners.Count; i++)
                {
                    ActivityDesigner designer7 = containedDesigners[i];
                    if ((designer7.IsVisible && !dictionary.ContainsKey(designer7.GetHashCode())) && ((designer7 != designer) && (designer7 != designer3)))
                    {
                        Rectangle bounds = designer7.Bounds;
                        bounds.Inflate(ambientTheme.Margin);
                        rectanglesToExclude.Add(bounds);
                    }
                }
            }
            linesToExclude = new List <Point>();
            if (((designer != null) && (designer == designer3)) && !designer.IsRootDesigner)
            {
                linesToExclude.AddRange(GetDesignerEscapeCover(designer, new object[] { source, target }));
            }
            else
            {
                if ((designer != null) && !designer.IsRootDesigner)
                {
                    linesToExclude.AddRange(GetDesignerEscapeCover(designer, new object[] { source }));
                }
                if ((designer3 != null) && !designer3.IsRootDesigner)
                {
                    bool flag = true;
                    for (CompositeActivityDesigner designer8 = (designer != null) ? designer.ParentDesigner : null; designer8 != null; designer8 = (designer != null) ? designer8.ParentDesigner : null)
                    {
                        if (designer3 == designer8)
                        {
                            flag = false;
                            break;
                        }
                    }
                    if (flag)
                    {
                        linesToExclude.AddRange(GetDesignerEscapeCover(designer3, new object[] { target }));
                    }
                }
            }
        }