예제 #1
0
        public void GoTo(VisioScripting.Models.PageDirection flags)
        {
            this._client.Application.AssertApplicationAvailable();

            var application     = this._client.Application.Get();
            var active_document = application.ActiveDocument;
            var docpages        = active_document.Pages;

            if (docpages.Count < 2)
            {
                return;
            }

            var pages = docpages;

            this._GoTo(pages, flags);
        }
예제 #2
0
        internal static int move_in_range(int cur, int min, int max, VisioScripting.Models.PageDirection direction)
        {
            if (max < min)
            {
                throw new System.ArgumentOutOfRangeException(nameof(max));
            }

            if (cur < min)
            {
                throw new System.ArgumentOutOfRangeException(nameof(cur));
            }

            if (cur > max)
            {
                throw new System.ArgumentOutOfRangeException(nameof(cur));
            }

            if (direction == VisioScripting.Models.PageDirection.Next)
            {
                return(System.Math.Min(cur + 1, max));
            }
            else if (direction == VisioScripting.Models.PageDirection.Previous)
            {
                return(System.Math.Max(cur - 1, min));
            }
            else if (direction == VisioScripting.Models.PageDirection.First)
            {
                return(min);
            }
            else if (direction == VisioScripting.Models.PageDirection.Last)
            {
                return(max);
            }
            else
            {
                throw new System.ArgumentOutOfRangeException(nameof(direction));
            }
        }
예제 #3
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;
            }
        }