Exemple #1
0
        private void _GoTo(IVisio.Pages pages, Models.PageDirection flags, CommandTarget cmdtarget)
        {
            if (pages == null)
            {
                throw new System.ArgumentNullException(nameof(pages));
            }

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

            int       cur_index = cmdtarget.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 = cmdtarget.ActiveDocument.Pages;
                var page      = doc_pages[new_index];

                var active_window = cmdtarget.Application.ActiveWindow;
                active_window.Page = page;
            }
        }
Exemple #2
0
        private void _GoTo(IVisio.Pages pages, VisioScripting.Models.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 VisioAutomation.Exceptions.VisioOperationException("Page.Document is not application's ActiveDocument");
            }

            if (pages.Count < 2)
            {
                throw new VisioAutomation.Exceptions.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;
            }
        }