Beispiel #1
0
        public Pages.PrintPageOrientation GetOrientation()
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var application = this.Client.Application.Get();
            var active_page = application.ActivePage;

            return(PageCommands.GetOrientation(active_page));
        }
Beispiel #2
0
        public void SetOrientation(Pages.PrintPageOrientation orientation)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var app         = this.Client.Application.Get();
            var application = app;

            var active_page = application.ActivePage;

            if (orientation != Pages.PrintPageOrientation.Landscape && orientation != Pages.PrintPageOrientation.Portrait)
            {
                throw new System.ArgumentOutOfRangeException(nameof(orientation), "must be either Portrait or Landscape");
            }

            var old_orientation = PageCommands.GetOrientation(active_page);

            if (old_orientation == orientation)
            {
                // don't need to do anything
                return;
            }

            var old_size = this.GetSize();

            double new_height = old_size.Width;
            double new_width  = old_size.Height;

            var update = new ShapeSheet.Update(3);

            update.SetFormula(ShapeSheet.SRCConstants.PageWidth, new_width);
            update.SetFormula(ShapeSheet.SRCConstants.PageHeight, new_height);
            update.SetFormula(ShapeSheet.SRCConstants.PrintPageOrientation, (int)orientation);

            using (var undoscope = this.Client.Application.NewUndoScope("Set Page Orientation"))
            {
                update.Execute(active_page.PageSheet);
            }
        }
Beispiel #3
0
        private void _GoTo(IVisio.Pages pages, PageDirection flags)
        {
            this.Client.Application.AssertApplicationAvailable();

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

            var app             = pages.Application;
            var active_document = app.ActiveDocument;

            if (pages.Document != active_document)
            {
                throw new VisioOperationException("Page.Document is not application's ActiveDocument");
            }

            if (pages.Count < 2)
            {
                throw new VisioOperationException("Only 1 page available. Navigation not possible.");
            }

            var activepage = app.ActivePage;

            int       cur_index = activepage.Index;
            const int min_index = 1;
            int       max_index = pages.Count;
            int       new_index = PageCommands.move_in_range(cur_index, min_index, max_index, flags);

            if (cur_index != new_index)
            {
                var doc_pages = active_document.Pages;
                var page      = doc_pages[new_index];

                var active_window = app.ActiveWindow;
                active_window.Page = page;
            }
        }