Example #1
0
        public void LayoutPage(Models.TargetPage targetpage, VisioAutomation.Models.LayoutStyles.LayoutStyleBase layout)
        {
            var pages = targetpage.Resolve(this._client);

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetPageSize)))
            {
                layout.Apply(targetpage.Page);
            }
        }
Example #2
0
        public List <IVisio.Shape> GetShapesOnPageByID(Models.TargetPage target_page, int[] shapeids)
        {
            var page        = target_page.Resolve(this._client);
            var shapes      = 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);
        }
Example #3
0
        public void SetPageSize(Models.TargetPage target_page, double?width, double?height)
        {
            if (!width.HasValue && !height.HasValue)
            {
                // nothing to do
                return;
            }

            var page     = this._client.Page.GetActivePage();
            var tp       = new VisioScripting.Models.TargetPages(page);
            var old_size = this.GetPageSize(tp);
            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 Models.TargetPages(target_page.Page), new_size);
        }
Example #4
0
        public List <IVisio.Shape> GetShapesOnPageByName(Models.TargetPage target_page, string[] shapenames, bool ignore_bad_names)
        {
            var page = target_page.Resolve(this._client);

            var cmdtarget          = this._client.GetCommandTargetDocument();
            var shapes             = cmdtarget.ActivePage.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);
        }
Example #5
0
        public IVisio.Page DuplicatePageToDocument(Models.TargetPage target_page, IVisio.Document dest_doc)
        {
            var src_page = target_page.Resolve(this._client);

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

            if (src_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(src_page, dest_page);

            return(dest_page);
        }
Example #6
0
        public List <IVisio.Shape> GetShapesOnPageByName(Models.TargetPage target_page, string[] shapenames)
        {
            var page = target_page.Resolve(this._client);

            return(this.GetShapesOnPageByName(target_page, shapenames, false));
        }