Esempio n. 1
0
        protected override void ProcessRecord()
        {
            if (this.FitContents || this.Width > 0 || this.Height > 0)
            {
                var cmdtarget = this.Client.GetCommandTargetPage();
                var tp        = new VisioScripting.Models.TargetPages(cmdtarget.ActivePage);

                if (this.FitContents)
                {
                    var bordersize = new VisioAutomation.Geometry.Size(this.BorderWidth, this.BorderWidth);
                    this.Client.Page.ResizePageToFitContents(tp, bordersize);
                    this.Client.View.SetActiveWindowZoomToObject(VisioScripting.Models.ZoomToObject.Page);
                }

                if (this.Width > 0 || this.Height > 0)
                {
                    var page_format_cells = new VisioAutomation.Pages.PageFormatCells();

                    if (this.Width > 0)
                    {
                        page_format_cells.Width = this.Width;
                    }

                    if (this.Height > 0)
                    {
                        page_format_cells.Height = this.Height;
                    }

                    this.Client.Page.SetPageFormatCells(tp, page_format_cells);
                }
            }


            if (this.Orientation.HasValue)
            {
                var cmdtarget = this.Client.GetCommandTargetPage();
                var tp        = new VisioScripting.Models.TargetPages(cmdtarget.ActivePage);
                this.Client.Page.SetPageOrientation(tp, this.Orientation.Value);
            }

            if (this.BackgroundPage != null)
            {
                this.Client.Page.SetActivePageBackground(this.BackgroundPage);
            }

            if (this.LayoutStyle != null)
            {
                var cmdtarget = this.Client.GetCommandTargetPage();
                var tp        = new VisioScripting.Models.TargetPage(cmdtarget.ActivePage);
                this.Client.Page.LayoutPage(tp, this.LayoutStyle);
            }
        }
Esempio n. 2
0
        protected override void ProcessRecord()
        {
            var target_page = new VisioScripting.Models.TargetPage();
            var page        = target_page.Resolve(this.Client);

            IVisio.Page newpage;
            if (this.ToDocument == null)
            {
                newpage = this.Client.Page.DuplicateActivePage();
            }
            else
            {
                newpage = this.Client.Page.DuplicatePageToDocument(target_page, this.ToDocument);
            }

            this.WriteObject(newpage);
        }
        protected override void ProcessRecord()
        {
            var target_page = new VisioScripting.Models.TargetPage(null);
            var page        = target_page.Resolve(this.Client);

            // Handle the case where neither names nor ids where passed
            if (this.Name == null && this.Id == null)
            {
                // return selected shapes

                if (this.Recursive)
                {
                    this.WriteVerbose("Returning selected shapes (nested)");
                    var shapes = this.Client.Selection.GetShapesInSelectionRecursive();
                    this.WriteObject(shapes, true);
                }
                if (this.SubSelected)
                {
                    this.WriteVerbose("Returning selected shapes (subselecte)");
                    var shapes = this.Client.Selection.GetSubSelectedShapes();
                    this.WriteObject(shapes, true);
                }
                else
                {
                    this.WriteVerbose("Returning selected shapes ");
                    var shapes = this.Client.Selection.GetShapesInSelection();
                    this.WriteObject(shapes, true);
                }

                return;
            }

            // Handle the case where names where passed
            if (this.Name != null)
            {
                string str_asterisk = "*";
                if (this.Name.Contains(str_asterisk))
                {
                    var shapes = this.Client.Draw.GetAllShapesOnActiveDrawingSurface();
                    this.WriteObject(shapes, true);
                }
                else
                {
                    var strings = this.Name.OfType <string>().ToArray();
                    var shapes  = this.Client.Page.GetShapesOnPageByName(target_page, strings);
                    this.WriteObject(shapes, true);
                }

                return;
            }

            // Handle the case where ids where passed
            if (this.Id != null)
            {
                var shapes = this.Client.Page.GetShapesOnPageByID(target_page, this.Id);
                this.WriteObject(shapes, true);

                return;
            }

            throw new System.ArgumentOutOfRangeException();
        }