Beispiel #1
0
        public IVisio.Layer FindLayersOnPageByName(TargetPage targetpage, string name)
        {
            targetpage = targetpage.Resolve(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);
        }
        public List <IVisio.Shape> GetShapes(TargetPage targetpage)
        {
            targetpage = targetpage.Resolve(this._client);
            var shapes = targetpage.Page.Shapes.ToList();

            return(shapes);
        }
        public Models.ShapeSheetReader GetReaderForPage(TargetPage targetpage)
        {
            targetpage = targetpage.Resolve(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.Resolve(this._client);
            var directed_edges = VA.DocumentAnalysis.ConnectionAnalyzer.GetDirectedEdges(targetpage.Page, flag);

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

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

            return(shape);
        }
Beispiel #6
0
        // http://blogs.msdn.com/b/visio/archive/2010/01/27/container-list-and-callout-api-in-visio-2010.aspx
        // https://msdn.microsoft.com/en-us/library/office/ff768907(v=office.14).aspx

        public IVisio.Shape DropContainerMaster(TargetPage targetpage, IVisio.Master master)
        {
            targetpage = targetpage.Resolve(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);
        }
        public List <IVisio.Shape> GetShapesyID(TargetPage targetpage, int[] shapeids)
        {
            targetpage = targetpage.Resolve(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);
        }
        public IVisio.Page Duplicate(TargetPage targetpage)
        {
            targetpage = targetpage.Resolve(this._client);

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(Duplicate)))
            {
                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 #9
0
        public IVisio.Shape DropContainer(TargetPage targetpage, string master)
        {
            targetpage = targetpage.Resolve(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);
        }
        public List <IVisio.Shape> GetShapesByName(TargetPage targetpage, string[] shapenames, bool ignore_bad_names)
        {
            targetpage = targetpage.Resolve(this._client);

            var shapes             = targetpage.Page.Shapes;
            var cached_shapes_list = new List <IVisio.Shape>(shapes.Count);

            cached_shapes_list.AddRange(shapes.ToEnumerable());

            if (shapenames.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, shapenames, s => s.Name, true, VisioScripting.Helpers.WildcardHelper.FilterAction.Include).ToList();

            return(shapes_list);
        }
        public IVisio.Page DuplicateToDocument(TargetPage targetpage, IVisio.Document dest_doc)
        {
            targetpage = targetpage.Resolve(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[1];

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

            return(dest_page);
        }
        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.Resolve(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);
        }
Beispiel #13
0
        public short[] DropMasters(
            TargetPage targetpage,
            IList <IVisio.Master> masters,
            IList <VisioAutomation.Geometry.Point> points)
        {
            targetpage = targetpage.Resolve(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 #14
0
 public List <IVisio.Layer> GetLayersOnPage(TargetPage targetpage)
 {
     targetpage = targetpage.Resolve(this._client);
     return(targetpage.Page.Layers.ToList());
 }
        public List <IVisio.Shape> GetShapesByName(TargetPage targetpage, string[] shapenames)
        {
            targetpage = targetpage.Resolve(this._client);

            return(this.GetShapesByName(targetpage, shapenames, false));
        }