Beispiel #1
0
        public List <IVisio.Shape> GetShapesOnPage(TargetPage targetpage)
        {
            targetpage = targetpage.ResolveToPage(this._client);
            var shapes = targetpage.Page.Shapes.ToList();

            return(shapes);
        }
        public IVisio.Layer FindLayersOnPageByName(TargetPage targetpage, string name)
        {
            targetpage = targetpage.ResolveToPage(this._client);


            if (name == null)
            {
                throw new System.ArgumentNullException(nameof(name));
            }

            if (name.Length < 1)
            {
                throw new System.ArgumentException("Layer name cannot be empty", nameof(name));
            }

            IVisio.Layer layer = null;
            try
            {
                this._client.Output.WriteVerbose("Trying to find layer named \"{0}\"", name);
                var layers = targetpage.Page.Layers;
                layer = layers.ItemU[name];
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                string msg = string.Format("No layer with name \"{0}\"", name);
                throw new VisioAutomation.Exceptions.VisioOperationException(msg);
            }
            return(layer);
        }
Beispiel #3
0
        public Models.ShapeSheetReader GetReaderForPage(TargetPage targetpage)
        {
            targetpage = targetpage.ResolveToPage(this._client);
            var reader = new Models.ShapeSheetReader(this._client, targetpage.Page);

            return(reader);
        }
Beispiel #4
0
        public List <VA.DocumentAnalysis.ConnectorEdge> GetDirectedEdgesOnPage(TargetPage targetpage, VA.DocumentAnalysis.ConnectionAnalyzerOptions flag)
        {
            targetpage = targetpage.ResolveToPage(this._client);
            var directed_edges = VA.DocumentAnalysis.ConnectionAnalyzer.GetDirectedEdges(targetpage.Page, flag);

            return(directed_edges);
        }
        public IVisio.Shape DropMaster(TargetPage targetpage, IVisio.Master master, VisioAutomation.Geometry.Point p)
        {
            targetpage = targetpage.ResolveToPage(this._client);

            var shape = targetpage.Page.Drop(master, p.X, p.Y);

            return(shape);
        }
Beispiel #6
0
        public void SelectShapesByMaster(TargetPage targetpage, IVisio.Master master)
        {
            targetpage = targetpage.ResolveToPage(this._client);

            // Get a selection of connectors, by master:
            var selection = targetpage.Page.CreateSelection(
                IVisio.VisSelectionTypes.visSelTypeByMaster,
                IVisio.VisSelectMode.visSelModeSkipSub,
                master);
        }
        public void ExportPageToImage(TargetPage targetpage, string filename)
        {
            if (filename == null)
            {
                throw new System.ArgumentNullException(nameof(filename));
            }

            targetpage = targetpage.ResolveToPage(this._client);

            targetpage.Page.Export(filename);
        }
Beispiel #8
0
        public IVisio.Shape DropContainerMaster(TargetPage targetpage, IVisio.Master master)
        {
            targetpage = targetpage.ResolveToPage(this._client);
            var page      = targetpage.Page;
            var app       = page.Application;
            var window    = app.ActiveWindow;
            var selection = window.Selection;

            var shape = page.DropContainer(master, selection);

            return(shape);
        }
Beispiel #9
0
        public List <IVisio.Shape> GetShapesOnPageByID(TargetPage targetpage, int[] shapeids)
        {
            targetpage = targetpage.ResolveToPage(this._client);
            var shapes      = targetpage.Page.Shapes;
            var shapes_list = new List <IVisio.Shape>(shapeids.Length);

            foreach (int id in shapeids)
            {
                var shape = shapes.ItemFromID[id];
                shapes_list.Add(shape);
            }
            return(shapes_list);
        }
Beispiel #10
0
        public List <IVisio.Shape> GetShapesOnPageByName(TargetPage targetpage, string[] names)
        {
            targetpage = targetpage.ResolveToPage(this._client);

            var cached_shapes_list = targetpage.Page.Shapes.ToList();

            if (names.Contains("*"))
            {
                // if any of the shape names contains a simple wildcard then return all the shapes
                return(cached_shapes_list);
            }

            // otherwise we start checking for each name
            var shapes_list = VisioScripting.Helpers.WildcardHelper.FilterObjectsByNames(cached_shapes_list, names, s => s.Name, true, VisioScripting.Helpers.WildcardHelper.FilterAction.Include).ToList();

            return(shapes_list);
        }
Beispiel #11
0
        public void SetPageSize(TargetPage targetpage, double?width, double?height)
        {
            if (!width.HasValue && !height.HasValue)
            {
                // nothing to do
                return;
            }

            targetpage = targetpage.ResolveToPage(this._client);

            var old_size = VisioAutomation.Pages.PageHelper.GetSize(targetpage.Page);
            var w        = width.GetValueOrDefault(old_size.Width);
            var h        = height.GetValueOrDefault(old_size.Height);
            var new_size = new VisioAutomation.Geometry.Size(w, h);

            this.SetPageSize(new TargetPages(targetpage.Page), new_size);
        }
Beispiel #12
0
        public IVisio.Page DuplicatePage(TargetPage targetpage)
        {
            targetpage = targetpage.ResolveToPage(this._client);

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(DuplicatePage)))
            {
                var src_page = targetpage.Page;
                var doc      = src_page.Document;
                var pages    = doc.Pages;
                var new_page = pages.Add();
                var app      = doc.Application;

                var win = app.ActiveWindow;
                win.Page = src_page;
                VisioAutomation.Pages.PageHelper.Duplicate(src_page, new_page);
                win.Page = new_page;
                return(new_page);
            }
        }
Beispiel #13
0
        public IVisio.Shape DropContainer(TargetPage targetpage, string master)
        {
            targetpage = targetpage.ResolveToPage(this._client);
            var page      = targetpage.Page;
            var app       = page.Application;
            var window    = app.ActiveWindow;
            var selection = window.Selection;
            var docs      = app.Documents;

            var stencil_type       = IVisio.VisBuiltInStencilTypes.visBuiltInStencilContainers;
            var measurement_system = IVisio.VisMeasurementSystem.visMSUS;
            var containers_file    = app.GetBuiltInStencilFile(stencil_type, measurement_system);
            var containers_doc     = docs.OpenStencil(containers_file);
            var masters            = containers_doc.Masters;
            var container_master   = masters.ItemU[master];
            var shape = page.DropContainer(container_master, selection);

            return(shape);
        }
Beispiel #14
0
        public IVisio.Page DuplicatePageToDocument(TargetPage targetpage, IVisio.Document dest_doc)
        {
            targetpage = targetpage.ResolveToPage(this._client);

            if (dest_doc == null)
            {
                throw new System.ArgumentNullException(nameof(dest_doc));
            }

            if (targetpage.Page.Document == dest_doc)
            {
                throw new VisioAutomation.Exceptions.VisioOperationException("dest doc is same as pages src doc");
            }

            var dest_pages = dest_doc.Pages;
            var dest_page  = dest_pages.Add();

            VisioAutomation.Pages.PageHelper.Duplicate(targetpage.Page, dest_page);

            return(dest_page);
        }
Beispiel #15
0
        public void SelectShapesByLayer(TargetPage targetpage, string layername)
        {
            if (layername == null)
            {
                throw new System.ArgumentNullException(nameof(layername), "Layer name cannot be null");
            }

            if (layername.Length < 1)
            {
                throw new System.ArgumentOutOfRangeException(nameof(layername), "Layer name cannot be empty");
            }

            targetpage = targetpage.ResolveToPage(this._client);

            var layer = this._client.Layer.FindLayersOnPageByName(targetpage, layername);

            // Get a selection of connectors, by layer:
            var selection = targetpage.Page.CreateSelection(
                IVisio.VisSelectionTypes.visSelTypeByLayer,
                IVisio.VisSelectMode.visSelModeSkipSub,
                layer);
        }
        public short[] DropMasters(
            TargetPage targetpage,
            IList <IVisio.Master> masters,
            IList <VisioAutomation.Geometry.Point> points)
        {
            targetpage = targetpage.ResolveToPage(this._client);

            if (masters == null)
            {
                throw new System.ArgumentNullException(nameof(points));
            }

            if (points == null)
            {
                throw new System.ArgumentNullException(nameof(points));
            }

            var page     = targetpage.Page;
            var shapeids = page.DropManyU(masters, points);

            return(shapeids);
        }
Beispiel #17
0
 public Models.PageOrientation GetPageOrientation(TargetPage targetpage)
 {
     targetpage = targetpage.ResolveToPage(this._client);
     return(PageCommands._get_page_orientation(targetpage.Page));
 }
 public List <IVisio.Layer> GetLayersOnPage(TargetPage targetpage)
 {
     targetpage = targetpage.ResolveToPage(this._client);
     return(targetpage.Page.Layers.ToList());
 }