Ejemplo n.º 1
0
        private void draw_directed_graph(VisioScripting.Client client, string dg_text)
        {
            var dg_xml   = SXL.XDocument.Parse(dg_text);
            var dg_model = VisioScripting.Builders.DirectedGraphBuilder.LoadFromXML(client, dg_xml);

            // TODO: Investigate if this this special case for Visio 2013 can be removed
            // this is a temporary fix to handle the fact that server_u.vss in Visio 2013 doesn't result in server_u.vssx
            // gettign automatically loaded

            var version = client.Application.Version;

            if (version.Major >= 15)
            {
                foreach (var drawing in dg_model)
                {
                    foreach (var shape in drawing.Shapes)
                    {
                        if (shape.StencilName == "server_u.vss")
                        {
                            shape.StencilName = "server_u.vssx";
                        }
                    }
                }
            }

            client.Draw.DirectedGraph(dg_model);
        }
        private void draw_directed_graph(VisioScripting.Client client, string dg_text)
        {
            var dg_xml = SXL.XDocument.Parse(dg_text);
            var dgdoc  = VisioScripting.Builders.DirectedGraphDocumentLoader.LoadFromXml(client, dg_xml);

            // TODO: Investigate if this this special case for Visio 2013 can be removed
            // this is a temporary fix to handle the fact that server_u.vss in Visio 2013 doesn't result in server_u.vssx
            // getting automatically loaded

            var version = client.Application.ApplicationVersion;

            if (version.Major >= 15)
            {
                foreach (var drawing in dgdoc.Layouts)
                {
                    foreach (var shape in drawing.Nodes)
                    {
                        if (shape.StencilName == "server_u.vss")
                        {
                            shape.StencilName = "server_u.vssx";
                        }
                    }
                }
            }

            var dgstyling = new VA.Models.Layouts.DirectedGraph.DirectedGraphStyling();

            client.Model.DrawDirectedGraphDocument(dgdoc, dgstyling);
        }
Ejemplo n.º 3
0
        internal int SelectShapesAndCount(VisioScripting.Client client)
        {
            client.Application.AssertHasActiveApplication();

            var app           = client.Application.GetActiveApplication();
            var active_window = app.ActiveWindow;
            var sel           = active_window.Selection;

            if (this.Shapes == null)
            {
                int n = sel.Count;
                client.Output.WriteVerbose("GetTargetSelectionCount: Using active selection of {0} shapes", n);
                return(n);
            }

            client.Output.WriteVerbose("GetTargetSelectionCount: Reseting selecton to specified {0} shapes", this.Shapes.Count);

            // Force empty slection
            active_window.DeselectAll();
            active_window.DeselectAll(); // doing this twice is deliberate

            // Force selection to specific shapes
            active_window.Select(this.Shapes, IVisio.VisSelectArgs.visSelect);

            int selected_count = sel.Count;

            return(selected_count);
        }
Ejemplo n.º 4
0
        private void draw_org_chart(VisioScripting.Client client, string text)
        {
            var xmldoc   = SXL.XDocument.Parse(text);
            var orgchart = VisioScripting.Builders.OrgChartBuilder.LoadFromXml(client, xmldoc);

            client.Draw.OrgChart(orgchart);
        }
Ejemplo n.º 5
0
        public TargetShapes ResolveShapes(VisioScripting.Client client)
        {
            var shapes  = this.__ResolveShapes(client);
            var targets = new TargetShapes(shapes);

            return(targets);
        }
        public TargetDocuments Resolve(VisioScripting.Client client)
        {
            if (this.IsResolved)
            {
                return(this);
            }

            // Handle the unresolved case

            var cmdtarget = new CommandTarget(client, CommandTargetRequirementFlags.RequireApplication |
                                              CommandTargetRequirementFlags.RequireActiveDocument |
                                              CommandTargetRequirementFlags.RequirePage);

            if (cmdtarget.ActiveDocument == null)
            {
                var docs = new List <IVisio.Document>(0);
                return(new TargetDocuments(docs));
            }
            else
            {
                var docs = new List <IVisio.Document> {
                    cmdtarget.ActiveDocument
                };
                return(new TargetDocuments(docs));
            }
        }
        private void draw_org_chart(VisioScripting.Client client, string text)
        {
            var xmldoc   = SXL.XDocument.Parse(text);
            var orgchart = VisioScripting.Builders.OrgChartDocumentLoader.LoadFromXml(client, xmldoc);

            client.Model.DrawOrgChart(VisioScripting.TargetPage.Auto, orgchart);
        }
Ejemplo n.º 8
0
        internal TargetShapes ResolveShapes2D(VisioScripting.Client client)
        {
            var shapes    = this.__ResolveShapes(client);
            var shapes_2d = shapes.Where(s => s.OneD == 0).ToList();
            var targets   = new TargetShapes(shapes_2d);

            return(targets);
        }
Ejemplo n.º 9
0
        public VisioScripting.Client GetScriptingClient()
        {
            var app = this.GetVisioApplication();
            // this ensures that any debug, verbose, user , etc. messages are
            // sent to a useful place in the unit tests
            var context = new DiagnosticDebugClientContext();
            var client  = new VisioScripting.Client(app, context);

            return(client);
        }
Ejemplo n.º 10
0
        public TargetShapes Resolve(VisioScripting.Client client)
        {
            if (this.IsResolved)
            {
                return(this);
            }

            var shapes       = client.Selection.GetShapesInSelection();
            var targetshapes = new TargetShapes(shapes);

            return(targetshapes);
        }
Ejemplo n.º 11
0
        public IVisio.Document Resolve(VisioScripting.Client client)
        {
            if (this.Document == null)
            {
                var cmdtarget = client.GetCommandTarget(
                    Commands.CommandTargetFlags.Application |
                    Commands.CommandTargetFlags.ActiveDocument |
                    Commands.CommandTargetFlags.ActivePage);
                this.Document = cmdtarget.ActiveDocument;
            }

            return(this.Document);
        }
Ejemplo n.º 12
0
        public TargetDocument Resolve(VisioScripting.Client client)
        {
            if (this.IsResolved)
            {
                return(this);
            }

            var command_target = new CommandTarget(client, CommandTargetRequirementFlags.RequireApplication |
                                                   CommandTargetRequirementFlags.RequireActiveDocument |
                                                   CommandTargetRequirementFlags.RequirePage);

            return(new TargetDocument(command_target.ActiveDocument));
        }
Ejemplo n.º 13
0
        public TargetWindow ResolveToWindow(VisioScripting.Client client)
        {
            if (this.Resolved)
            {
                return(this);
            }

            var cmdtarget     = client.GetCommandTarget(CommandTargetFlags.RequireDocument);
            var active_window = cmdtarget.Application.ActiveWindow;

            client.Output.WriteVerbose("Resolving to active window (caption=\"{0}\")", active_window.Caption);

            return(new TargetWindow(active_window));
        }
Ejemplo n.º 14
0
        private IList <IVisio.Shape> __ResolveShapes(VisioScripting.Client client)
        {
            client.Application.AssertHasActiveApplication();

            if (this.Shapes == null)
            {
                var out_shapes = client.Selection.GetShapesInSelection();
                client.Output.WriteVerbose("GetTargetShapes: Returning {0} shapes from the active selection", out_shapes.Count);
                return(out_shapes);
            }

            client.Output.WriteVerbose("GetTargetShapes: Returning {0} shapes that were passed in", this.Shapes.Count);
            return(this.Shapes);
        }
Ejemplo n.º 15
0
        public TargetPage Resolve(VisioScripting.Client client)
        {
            if (!this.IsResolved)
            {
                var cmdtarget = client.GetCommandTargetPage();

                // It doesn't matter if there is an active page or not
                // at this point it is considered resolved
                return(new TargetPage(cmdtarget.ActivePage, true));
            }
            else
            {
                return(this);
            }
        }
Ejemplo n.º 16
0
        public IVisio.Page Resolve(VisioScripting.Client client)
        {
            if (this.Page == null)
            {
                var cmdtarget = client.GetCommandTargetPage();
                this.Page = cmdtarget.ActivePage;
            }

            if (this.Page == null)
            {
                throw new VisioOperationException("Unvalid State No Pages");
            }

            return(this.Page);
        }
Ejemplo n.º 17
0
        public TargetShapes ResolveToShapes(VisioScripting.Client client)
        {
            if (this.Resolved)
            {
                return(this);
            }

            var cmdtarget = client.GetCommandTarget(CommandTargetFlags.RequireDocument); var active_window = cmdtarget.Application.ActiveWindow;
            var selection    = active_window.Selection;
            var shapes       = selection.ToList();
            var targetshapes = new TargetShapes(shapes);

            client.Output.WriteVerbose("Resolving to selection (numshapes={0}) from active window (caption=\"{1}\")", shapes.Count, active_window.Caption);

            return(targetshapes);
        }
Ejemplo n.º 18
0
        public TargetDocument ResolveToDocument(VisioScripting.Client client)
        {
            if (this.Resolved)
            {
                return(this);
            }

            var flags = CommandTargetFlags.RequireApplication |
                        CommandTargetFlags.RequireDocument |
                        CommandTargetFlags.RequirePage;

            var command_target = new CommandTarget(client, flags);

            client.Output.WriteVerbose("Resolving to active document (name={0})", command_target.ActiveDocument.Name);

            return(new TargetDocument(command_target.ActiveDocument));
        }
Ejemplo n.º 19
0
        internal int SetSelectionGetSelectedCount(VisioScripting.Client client)
        {
            client.Application.AssertApplicationAvailable();

            if (this.Shapes == null)
            {
                int n = client.Selection.Count();
                client.WriteVerbose("GetTargetSelectionCount: Using active selection of {0} shapes", n);
                return(n);
            }

            client.WriteVerbose("GetTargetSelectionCount: Reseting selecton to specified {0} shapes", this.Shapes.Count);
            client.Selection.SelectNone();
            client.Selection.Select(this.Shapes);
            int selected_count = client.Selection.Count();

            return(selected_count);
        }
Ejemplo n.º 20
0
        public static void set_page_size(VisioScripting.Client client, double width, double height)
        {
            double?w = null;
            double?h = null;

            if (width > 0)
            {
                w = width;
            }

            if (height > 0)
            {
                h = height;
            }

            if (w.HasValue || h.HasValue)
            {
                client.Page.SetSize(w, h);
            }
        }
Ejemplo n.º 21
0
        public TargetPages Resolve(VisioScripting.Client client)
        {
            // Handle the case where the object is already resolved
            if (this._items != null)
            {
                return(this);
            }

            // Otherwise perform resolution
            // Try to use the active page as the default target for the operation

            var cmdtarget = client.GetCommandTargetPage();

            if (cmdtarget.ActivePage == null)
            {
                throw new VisioAutomation.Exceptions.InternalAssertionException();
            }

            return(new TargetPages(cmdtarget.ActivePage));
        }
Ejemplo n.º 22
0
        public void ResolveToSelection(VisioScripting.Client client)
        {
            // the purpose of this class is to handle those Visio operations that
            // don't explicitly take a list of shapes, but instead rely on the active selection

            var shapes = this._get_items_unsafe();

            if (shapes == null)
            {
                // do nothing - use the active selection
                return;
            }

            if (shapes.Count < 1)
            {
                throw new System.ArgumentOutOfRangeException("Shapes parameter must contain at least one shape");
            }

            client.Selection.SelectShapes(VisioScripting.TargetWindow.Auto, shapes);
        }
Ejemplo n.º 23
0
        public IList <IVisio.Page> Resolve(VisioScripting.Client client)
        {
            if (this.Pages == null)
            {
                var cmdtarget = client.GetCommandTargetPage();
                this.Pages = new List <IVisio.Page> {
                    cmdtarget.ActivePage
                };
            }

            if (this.Pages == null)
            {
                throw new VisioOperationException("Unvalid State No Pages");
            }

            if (this.Pages.Count < 1)
            {
                throw new VisioOperationException("Unvalid State No Pages");
            }

            return(this.Pages);
        }
Ejemplo n.º 24
0
        public TargetDocuments ResolveToDocuments(VisioScripting.Client client)
        {
            if (this.Resolved)
            {
                return(this);
            }

            // Handle the unresolved case

            var flags = CommandTargetFlags.RequireApplication |
                        CommandTargetFlags.RequireDocument |
                        CommandTargetFlags.RequirePage;

            var cmdtarget = new CommandTarget(client, flags);

            var docs = new List <IVisio.Document> {
                cmdtarget.ActiveDocument
            };

            client.Output.WriteVerbose("Resolving to active document (name={0})", cmdtarget.ActiveDocument.Name);
            return(new TargetDocuments(docs));
        }
Ejemplo n.º 25
0
        public TargetPages ResolveToPages(VisioScripting.Client client)
        {
            // Handle the case where the object is already resolved

            if (this.Resolved)
            {
                return(this);
            }

            // Otherwise perform resolution
            // Try to use the active page as the default target for the operation

            var cmdtarget = client.GetCommandTarget(CommandTargetFlags.RequirePage);

            if (cmdtarget.ActivePage == null)
            {
                throw new VisioAutomation.Exceptions.AutomationException("Resolving failed: No active page available");
            }

            client.Output.WriteVerbose("Resolving to active page (name={0})", cmdtarget.ActivePage.Name);

            return(new TargetPages(cmdtarget.ActivePage));
        }
Ejemplo n.º 26
0
 public static void ScriptingDocumentation()
 {
     var app    = SampleEnvironment.Application;
     var client = new VisioScripting.Client(app);
     var doc    = client.Developer.DrawScriptingDocumentation();
 }
Ejemplo n.º 27
0
 public static void VisioAutomationNamespacesAndClasses()
 {
     var app    = SampleEnvironment.Application;
     var client = new VisioScripting.Client(app);
     var doc    = client.Developer.DrawNamespacesAndClasses();
 }