/// <summary>
        /// 加载分页器
        /// </summary>
        private void LoadPaginator()
        {
            _paginator = PaginatorFactory.GetDocumentPaginator(_config);

            OnPageLoading();

            Task.Factory.StartNew(() =>
            {
                if (PageOrientation == PageOrientation.Portrait)
                {
                    _paginator.PageSize = new Size((int)PageSize.Width, (int)PageSize.Height);
                }
                else if (PageOrientation == PageOrientation.Landscape)
                {
                    _paginator.PageSize = new Size((int)PageSize.Height, (int)PageSize.Width);
                }

                PageCount = _paginator.PageCount;

                EndIndex = PageCount - 1;

                CurrentPageIndex = 0;

                _dispatcher.BeginInvoke(new Action(() => OnPageChanged(_paginator.GetPage(CurrentPageIndex))));
            });
        }
        /// <summary>
        /// 打印范围
        /// </summary>
        /// <param name="startIndex"></param>
        /// <param name="endIndex"></param>
        private void PrintRange(int startIndex, int endIndex)
        {
            if (startIndex >= 0 && endIndex < PageCount && startIndex <= endIndex)
            {
                var queueName = CurrentPrintQueue.FullName;

                //BitmapImage暂时没有办法异步打印
                if (this._paginator is DataTableDocumentPaginator)
                {
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            ProgressValue = 0;

                            if (endIndex != 0)
                            {
                                ShowProgress = true;
                            }

                            ControlStatus   = false;
                            IsIndeterminate = false;

                            var p = PaginatorFactory.GetDocumentPaginator(_config);

                            p.PageSize = new Size(_paginator.PageSize.Width, _paginator.PageSize.Height);

                            var server = new LocalPrintServer();

                            var queue = server.GetPrintQueue(queueName);

                            queue.UserPrintTicket.PageMediaSize = PageSize;

                            queue.UserPrintTicket.PageOrientation = PageOrientation;

                            var doc = PrintQueue.CreateXpsDocumentWriter(queue);

                            if (endIndex != 0)
                            {
                                doc.WritingProgressChanged += doc_WritingProgressChanged;
                            }

                            doc.Write(new PageRangeDocumentPaginator(startIndex, endIndex, p));

                            if (endIndex != 0)
                            {
                                doc.WritingProgressChanged -= doc_WritingProgressChanged;
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        finally
                        {
                            ControlStatus = true;
                            ShowProgress  = false;

                            _dispatcher.BeginInvoke(new Action(() => Close()));
                        }
                    });
                }
                else
                {
                    ProgressValue = 0;

                    if (endIndex != 0)
                    {
                        ShowProgress = true;
                    }

                    ControlStatus   = false;
                    IsIndeterminate = false;

                    var p = PaginatorFactory.GetDocumentPaginator(_config);

                    p.PageSize = new Size(_paginator.PageSize.Width, _paginator.PageSize.Height);

                    var server = new LocalPrintServer();

                    var queue = server.GetPrintQueue(queueName);

                    queue.UserPrintTicket.PageMediaSize = PageSize;

                    queue.UserPrintTicket.PageOrientation = PageOrientation;

                    var doc = PrintQueue.CreateXpsDocumentWriter(queue);

                    if (endIndex != 0)
                    {
                        doc.WritingProgressChanged += doc_WritingProgressChanged;
                    }

                    doc.Write(new PageRangeDocumentPaginator(startIndex, endIndex, p));

                    if (endIndex != 0)
                    {
                        doc.WritingProgressChanged -= doc_WritingProgressChanged;
                    }

                    ControlStatus = true;
                    ShowProgress  = false;

                    _dispatcher.BeginInvoke(new Action(() => Close()));
                }
            }
        }