コード例 #1
0
        /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         * ~
         * ~ Private methods
         * ~
         * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

        /// <summary>
        /// Validate all of the pages in the designated document.
        /// </summary>
        /// <param name="document">Visio document.</param>
        private ModelCommandResult ValidateAll(IVDocument document)
        {
            #region Validations

            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            #endregion

            ModelCommandResult result = new ModelCommandResult();

            int pageCount = document.Pages.Count;

            for (int i = 1; i <= pageCount; i++)
            {
                Page          page = document.Pages[i];
                PageEventArgs ev   = new PageEventArgs(i, pageCount, page.Name);

                OnPageStart(ev);

                ModelCommandPageResult pageResult = Work(page, true);
                result.Add(pageResult);

                OnPageEnd(ev);
            }

            return(result);
        }
コード例 #2
0
        /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         * ~
         * ~ Public methods
         * ~
         * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

        /// <summary>
        /// Executes an export command.
        /// </summary>
        /// <param name="command">Command to execute.</param>
        public ModelCommandResult Execute(ModelCommand command)
        {
            #region Validations

            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            #endregion

            ModelCommandResult result = ValidateSettings(command, this.Settings);

            if (result != null)
            {
                return(result);
            }

            switch (command.Operation)
            {
            case ModelOperation.ExportAll:
                result = ExportAll(command.Document);
                break;

            case ModelOperation.ExportCurrent:
                result = ExportPage(command.Page);
                break;

            case ModelOperation.ValidateAll:
                result = ValidateAll(command.Document);
                break;

            case ModelOperation.ValidateCurrent:
                result = ValidatePage(command.Page);
                break;
            }

            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Validate and export the designated page.
        /// </summary>
        /// <param name="page">Visio page.</param>
        private ModelCommandResult ExportPage(IVPage page)
        {
            #region Validations

            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

            #endregion

            ModelCommandResult result = new ModelCommandResult();

            PageEventArgs ev = new PageEventArgs(1, 1, page.Name);
            OnPageStart(ev);

            ModelCommandPageResult pageResult = Work(page, false);
            result.Add(pageResult);

            OnPageEnd(ev);

            return(result);
        }
コード例 #4
0
        private static ModelCommandResult BuildResult(string pageName, string itemId)
        {
            #region Validations

            if (pageName == null)
            {
                throw new ArgumentNullException(nameof(pageName));
            }

            if (itemId == null)
            {
                throw new ArgumentNullException(nameof(itemId));
            }

            #endregion

            ModelCommandPageResult pageResult = new ModelCommandPageResult(pageName);
            pageResult.Add(itemId);

            ModelCommandResult result = new ModelCommandResult();
            result.Add(pageResult);

            return(result);
        }