Exemplo n.º 1
0
 /// <summary>
 /// 获取新的词列表
 /// </summary>
 public void FetchNewWords()
 {
     // 获取URL
     MainForm.UrlManager.GetUrls();
     _totalPages      = MainForm.UrlManager.Urls.Count;
     _getedPage       = 0;
     StartCrawlerTime = DateTime.Now;
     //准备显示进度条
     if (progressBar == null)
     {
         progressBar = new ProgressBarForm();
         progressBar.SetMaxProgress(_totalPages);
         progressBar.LableTotalPage.Text = TotalPages.ToString();
     }
     else
     {
         progressBar.SetMaxProgress(_totalPages);
         progressBar.LableTotalPage.Text = TotalPages.ToString();
         progressBar.ResetProgress();
     }
     //多线程抓取并分词
     for (int i = 0; i < _threadNum; i++)
     {
         ThreadStart startCrawlePage = new ThreadStart(StartCrawlePage);
         Thread      crawlePage      = new Thread(startCrawlePage);
         crawlePage.Start();
     }
     progressBar.ShowDialog(MainForm);//线程创建结束后才能将进度条显示,否则进程被阻在此处
 }
Exemplo n.º 2
0
        /// <summary>
        /// 获取新的词列表
        /// </summary>
        public void FetchNewWords()
        {
            // 获取URL
            MainForm.UrlManager.GetUrls();
            //准备初始数据
            TotalPages = MainForm.UrlManager.Urls.Count;
            GetedPage  = 0;
            FailedPage = 0;
            GetedUrls  = new List <string>();
            FailedUrls = new List <string>();

            //StartCrawlerTime = DateTime.Now;
            //准备显示进度条
            if (ProgressBar == null)
            {
                ProgressBar = new ProgressBarForm();
                ProgressBar.SetMaxProgress(TotalPages);
                ProgressBar.lableTotalPage.Text = TotalPages.ToString();
            }
            else
            {
                ProgressBar.SetMaxProgress(TotalPages);
                ProgressBar.lableTotalPage.Text = TotalPages.ToString();
                ProgressBar.ResetProgress();
            }
            //多线程抓取并分词
            for (int i = 0; i < ThreadNum; i++)
            {
                ThreadStart startCrawlePage = new ThreadStart(StartCrawlePage);
                Thread      crawlePage      = new Thread(startCrawlePage);
                crawlePage.Start();
            }
            ProgressBar.ShowDialog(MainForm);//线程创建结束后才能将进度条显示,否则进程被阻在此处
        }
Exemplo n.º 3
0
    public void RefreshPages()
    {
        // Remove any old TransUIElems from the previous page
        for (int i = 0; i < transUIElems.Length; i += 1)
        {
            if (transUIElems[i] != null)
            {
                transUIElems[i].Destroy();
                transUIElems[i] = null;
            }
        }

        // Update page number
        if (transSelected >= 0)
        {
            page = Mathf.FloorToInt(transSelected / transUIElems.Length);
        }
        pageLabel.text = "Page " + (page + 1).ToString() + "/" + TotalPages.ToString();

        // Add TransUIElems for this page
        int added         = 0;
        int pageItemStart = page * transUIElems.Length;

        for (int i = pageItemStart; i < Mathf.Min(pageItemStart + transUIElems.Length, transList.Count); i += 1)
        {
            transUIElems[added] = new TransformationItem(this, transList[i], new Vector2(pos.x, pos.y + HEIGHT * 0.5f - LINES_START - LINE_HEIGHT * (added * 4)));
            VoezEditor.Editor.AddObject(transUIElems[added]);
            added += 1;
        }
    }
Exemplo n.º 4
0
        /// <summary>
        /// 1. 根據最新嘅 RowsPerPage 同埋 TotalRows,重新整理 CurrentPage, txtCurrentPage, lblTotalPages
        /// </summary>
        public override void Update()
        {
            #region 根據依家嘅 RowsPerPage 同埋 TotalRows,重新整理 CurrentPage, txtCurrentPage, lblTotalPages
            CurrentPage = 1;
            TotalPages  = CalcTotalPages();

            txtCurrentPage.Text = CurrentPage.ToString();
            lblTotalPages.Text  = string.Format("/{0}", TotalPages.ToString());
            #endregion
        }
Exemplo n.º 5
0
 public override string ToString()
 {
     return("PageNumber: " + PageNumber.ToString() + "\n" +
            "PageSize: " + PageSize.ToString() + "\n" +
            "TotalPages: " + TotalPages.ToString() + "\n" +
            "TotalRecords: " + TotalRecords.ToString() + "\n" +
            "NextPage: " + NextPage.ToString() + "\n" +
            "PreviousPage: " + PreviousPage.ToString() + "\n" +
            "Data: " + Data + "\n" +
            "Succeeded: " + Succeeded.ToString() + "\n" +
            "Errors: " + Errors.ToString() + "\n");
 }
 /// <summary>
 /// Builds the "last page" anchor tag [»»]
 /// </summary>
 /// <param name="output">Appends html to the parent TagHelperOutput object</param>
 void BuildLastPageLink(TagHelperOutput output)
 {
     if (TotalPages > 1 && Page < TotalPages)
     {
         RouteValues["page"] = TotalPages.ToString();
         string url = ConstructPageLinkUrl(RouteValues);
         output.Content.AppendHtml($@"<li class=""page-item""><a class=""page-link"" aria-label=""{LastPageAriaLabel}"" href=""{url}""{AjaxHtmlAttributes}>{LastPageLinkText}</a></li>");
     }
     else
     {
         output.Content.AppendHtml($@"<li class=""page-item disabled"" tabindex=""-1""><a class=""page-link"" aria-label=""{LastPageAriaLabel}"">{LastPageLinkText}</a></li>");
     }
 }
Exemplo n.º 7
0
        protected override void Render(HtmlTextWriter writer)
        {
            Control skin         = (Control)this.Parent;
            Panel   displayPager = (Panel)skin.FindControl("DisplayPager");

            if (displayPager != null)
            {
                displayPager.Visible = true;
            }

            this.Text = String.Format(text, PageIndex, TotalPages.ToString("n0"), TotalRecords.ToString("n0"));

            base.Render(writer);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Updates the status of child controls.
        /// </summary>
        /// <param name="e">Event Arguments.</param>
        protected override void OnPreRender(EventArgs e)
        {
            //Update controls status.
            PageIndexTextBox.Text = (PageIndex + 1).ToString(CultureInfo.CurrentCulture);
            PageCountLabel.Text   = TotalPages.ToString(CultureInfo.CurrentCulture);

            NextButton.Enabled  = LastButton.Enabled = PageIndex >= (TotalPages - 1) ? false : true;
            FirstButton.Enabled = PreviousButton.Enabled = PageIndex <= 0 ? false : true;

            //register javascript function.
            PageIndexTextBox.Attributes.Add(_OnKeyPressEvent,
                                            string.Format(CultureInfo.InvariantCulture, _handleKeyPressEvent, PageIndexTextBox.ClientID, 1, TotalPages));

            base.OnPreRender(e);
        }
Exemplo n.º 9
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            TotalPages     = TotalPages < 1000 ? TotalPages : 1000;
            output.TagName = "div";
            output.Attributes.Add("class", "nav-links");

            TagBuilder dots = new TagBuilder("span");

            dots.Attributes.Add("class", "page-numbers dots");
            dots.InnerHtml.Append("...");

            TagBuilder actualIndex;

            var actualPage = int.Parse(ViewContext.RouteData.Values["page"].ToString());

            actualIndex = new TagBuilder("a");
            actualIndex.Attributes.Add("class", "page-numbers");
            actualIndex.InnerHtml.SetContent("1");
            output.Content.AppendHtml(actualIndex);

            for (int i = 0; i <= 4; i++)
            {
                if (i.Equals(0) && actualPage > 4)
                {
                    output.Content.AppendHtml(dots);
                }

                if (((actualPage - 2) + i) >= 2 && ((actualPage - 2) + i) < TotalPages)
                {
                    actualIndex = new TagBuilder("a");
                    actualIndex.Attributes.Add("class", "page-numbers");
                    actualIndex.InnerHtml.SetContent(((actualPage - 2) + i).ToString());
                    output.Content.AppendHtml(actualIndex);
                }

                if (i.Equals(4) && actualPage < TotalPages - 3)
                {
                    output.Content.AppendHtml(dots);
                }
            }

            actualIndex = new TagBuilder("a");
            actualIndex.Attributes.Add("class", "page-numbers");
            actualIndex.InnerHtml.SetContent(TotalPages.ToString());
            output.Content.AppendHtml(actualIndex);
        }
Exemplo n.º 10
0
        public void WriteSourceFileInfo(Data data, string section)
        {
            data.SetValue(section + "DocumentTitle", DocumentTitle);
            data.SetValue(section + "WinStation", WinStation);
            data.SetValue(section + "Username", Author);
            data.SetValue(section + "ClientComputer", ClientComputer);
            data.SetValue(section + "SpoolFileName", Filename);
            data.SetValue(section + "PrinterName", PrinterName);
            data.SetValue(section + "SessionId", SessionId.ToString(CultureInfo.InvariantCulture));
            data.SetValue(section + "JobCounter", JobCounter.ToString(CultureInfo.InvariantCulture));
            data.SetValue(section + "JobId", JobId.ToString(CultureInfo.InvariantCulture));

            var type = Type == JobType.XpsJob ? "xps" : "ps";

            data.SetValue(section + "SourceFileType", type);

            data.SetValue(section + "Copies", Copies.ToString(CultureInfo.InvariantCulture));
            data.SetValue(section + "TotalPages", TotalPages.ToString(CultureInfo.InvariantCulture));
        }
Exemplo n.º 11
0
        // Statistiktabben börjar
        /// <summary>
        /// Skickar med de parametrar som användaren vill använda för att söka efter till metoden för querin till databasen.
        /// Retunerar informationen som matchar sökpreferensen
        /// </summary>
        private void SendSearchInfo()
        {
            try
            {
                //CollectionViewSource itemCollectionViewSource = (CollectionViewSource)(FindResource("ItemCollectionViewSource"));


                VisitorSearch       = InputVariables();
                VisitorSearchReturn = GetVisitorSearchInfo(VisitorSearch, Offset, HitsPerPage);//returnerar ETT objekt
                int countTotalHits = VisitorSearchReturn.CountTotalHits;
                ReturnTotalPages(countTotalHits);
                lblTotalPages = TotalPages.ToString();

                lblTotalVisitors = countTotalHits.ToString();
                //itemCollectionViewSource.Source = VisitorSearchReturn.VisitorSearches;//printar listan i objektet. Visitor, Employee och BookedMeeting
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //throw;
            }
        }
        //选择每页显示条数
        private void cbxRowCount_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (BindingDataTable == null || ShowingDataTable == null)
            {
                return;
            }
            if (cbxRowCount.Text.Trim() == "全部显示")
            {
                RowsCount   = BindingDataTable.Rows.Count;
                CurrentPage = 1;
                TotalPages  = 1;
            }
            else
            {
                RowsCount   = Convert.ToInt32(cbxRowCount.Text);
                CurrentPage = 1;
                TotalPages  = (int)Math.Ceiling((double)BindingDataTable.Rows.Count / RowsCount);
            }
            ShowingDataTable.Rows.Clear();
            SetShowingDataTable();

            tbxCurrentPage.Text = CurrentPage.ToString();
            lbTotalPages.Text   = TotalPages.ToString();
        }
Exemplo n.º 13
0
        public MvcHtmlString PagerMenu(HtmlHelper hhelper, RouteValueDictionary add = null)
        {
            if (AccessHelper.IsMasterPage)
            {
                var content = "";

                content =
                    string.Concat(new object[]
                                  { content, "<input type=\"hidden\" value=\"", PageIndex, "\" id=\"page\"/>" });
                if (TotalPages > 1)
                {
                    content = content + "<div class=\"pager\">Страницы:&nbsp;";


                    if (add != null)
                    {
                        foreach (var pair in add)
                        {
                            if (DefaultRoutes.ContainsKey(pair.Key))
                            {
                                DefaultRoutes[pair.Key] = pair.Value;
                            }
                            else
                            {
                                DefaultRoutes.Add(pair.Key, pair.Value);
                            }
                        }
                    }

                    if (!DefaultRoutes.ContainsKey("page"))
                    {
                        DefaultRoutes.Add("page", 0);
                    }



                    if (HasPreviousPage)
                    {
                        DefaultRoutes["page"] = PageIndex - 1;
                        content = AddLink("<<", PageIndex - 1, content, hhelper);


                        /*
                         *                      (hhelper.RouteLink("<<", MapRuleName, DefaultRoutes,
                         *                                                         (AjaxPager
                         *                                                              ? ((object)
                         *                                                                 new
                         *                                                                     {
                         *                                                                         onclick =
                         *                                                                     "return {0}({1})".FormatWith(PageJSFunction,
                         *                                                                                                  (PageIndex - 1).
                         *                                                                                                      ToString())
                         *                                                                     })
                         *                                                              : ((object)new { })).ToDictionary())) + "&nbsp;";
                         */
                    }
                    string links       = "";
                    bool   begin       = false;
                    bool   end         = false;
                    string fmtInactive = "<span>{0}</span>&nbsp;&nbsp;&nbsp;";

                    /*
                     *              List<int> allowed = new List<int>();
                     *              if (TotalPages < 15)
                     *                  for (int i = 0; i < 15; i++)
                     *                      allowed.Add(i);
                     *              else
                     *              {
                     */
                    int PageWidth = 5;
                    for (int i = 0; TotalPages > i; i++)
                    {
                        int offset = 0;
                        if (PageIndex < (PageWidth - 1))
                        {
                            offset = PageWidth - PageIndex - 1;
                        }

                        if ((i > (PageIndex - PageWidth)) && (i < (PageIndex + PageWidth + offset)))
                        {
                            if (PageIndex == i)
                            {
                                links = links + string.Format(fmtInactive, i + 1);
                            }
                            else
                            {
                                string linkText = (i + 1).ToString();
                                if ((i - 1) == (PageIndex - PageWidth))
                                {
                                    if (i > 0)
                                    {
                                        begin    = true;
                                        linkText = "...";
                                    }
                                }

                                if ((i + 1) == (PageIndex + PageWidth + offset))
                                {
                                    if ((i + 1) != TotalPages)
                                    {
                                        end      = true;
                                        linkText = "...";
                                    }
                                }

                                DefaultRoutes["page"] = i;
                                links = AddLink(linkText, i, links, hhelper);
                            }
                        }
                    }

                    if (begin)
                    {
                        links = AddLink("1", 0, links, hhelper, false);
                    }
                    if (end)
                    {
                        links = AddLink(TotalPages.ToString(), TotalPages - 1, links, hhelper);
                    }
                    content = content + links;
                    if (HasNextPage)
                    {
                        content = AddLink(">>", PageIndex + 1, content, hhelper);
                    }
                    content = content + "</div>";
                }
                return(new MvcHtmlString(content));
            }
            else
            {
                string prevSpan  = "<span><i class=\"icon_c_mark-lb\"></i> Назад</span>";
                string nextSpan  = "<span>Вперед <i class=\"icon_c_mark-rb\"></i></span>";
                string prevLink  = "<a href=\"{0}\"><i class=\"icon_c_mark-lb\"></i> Назад</a>";
                string nextLink  = "<a href=\"{0}\"> Вперед <i class=\"icon_c_mark-rb\"></i></a>";
                string indexSpan = "<span class=\"selected\">{0}</span>";
                string indexLink = "<a href=\"{0}\">{1}</a>";
                string ctx       = "<div class=\"el_paginate\"><div class=\"num_line bradius_20 gradient_white-gray\">{0}</div><div class=\"signature\">Страница: {1} из {2}</div></div>";

                string sLinks = "";
                if (TotalPages > 1)
                {
                    if (!DefaultRoutes.ContainsKey("page"))
                    {
                        DefaultRoutes.Add("page", 0);
                    }



                    bool begin     = false;
                    bool end       = false;
                    int  PageWidth = 5;
                    for (int i = 0; TotalPages > i; i++)
                    {
                        int offset = 0;
                        if (PageIndex < (PageWidth - 1))
                        {
                            offset = PageWidth - PageIndex - 1;
                        }

                        if ((i > (PageIndex - PageWidth)) && (i < (PageIndex + PageWidth + offset)))
                        {
                            if (PageIndex == i)
                            {
                                sLinks += string.Format(indexSpan, i + 1);
                            }
                            else
                            {
                                string linkText = (i + 1).ToString();
                                if ((i - 1) == (PageIndex - PageWidth))
                                {
                                    if (i > 0)
                                    {
                                        begin    = true;
                                        linkText = "...";
                                    }
                                }

                                if ((i + 1) == (PageIndex + PageWidth + offset))
                                {
                                    if ((i + 1) != TotalPages)
                                    {
                                        end      = true;
                                        linkText = "...";
                                    }
                                }

                                DefaultRoutes["page"] = i;
                                sLinks += indexLink.FormatWith(CreateLink(i), linkText);
                            }
                        }
                    }

                    if (begin)
                    {
                        sLinks = indexLink.FormatWith(CreateLink(0), "1") + sLinks;
                    }
                    if (end)
                    {
                        sLinks += indexLink.FormatWith(CreateLink(TotalPages - 1), TotalPages.ToString());
                    }

                    if (HasPreviousPage)
                    {
                        DefaultRoutes["page"] = PageIndex - 1;
                        sLinks = prevLink.FormatWith(CreateLink(PageIndex - 1)) + sLinks;
                    }
                    else
                    {
                        sLinks = prevSpan + sLinks;
                    }

                    if (HasNextPage)
                    {
                        DefaultRoutes["page"] = PageIndex + 1;
                        sLinks += nextLink.FormatWith(CreateLink(PageIndex + 1));
                    }
                    else
                    {
                        sLinks += nextSpan;
                    }
                    return(new MvcHtmlString(ctx.FormatWith(sLinks, PageIndex + 1, TotalPages)));
                }
                return(new MvcHtmlString(""));
            }
        }
Exemplo n.º 14
0
 // *********************************************************************
 //  DisplayCurrentPage
 //
 /// <summary>
 /// Displays the current page that the user is viewing
 /// </summary>
 ///
 // ********************************************************************/
 private void DisplayCurrentPage()
 {
     currentPage.Text = "Page " + (PageIndex + 1).ToString("n0") + " of " + TotalPages.ToString("n0");
 }
Exemplo n.º 15
0
        protected void CreateListPager()
        {
            UpdateInformation();

            long startIndex = 0;
            long endIndex   = TotalPages;

            if (TotalPages > PageBlock)
            {
                startIndex = CurrentPage - PageBlock / 2;
                endIndex   = CurrentPage + PageBlock / 2;

                if (startIndex < 0)
                {
                    startIndex = 0;
                    endIndex   = startIndex + PageBlock;
                }
                if (endIndex > TotalPages)
                {
                    startIndex = TotalPages - PageBlock;
                    endIndex   = TotalPages;
                }
            }

            ListPagers.Add(new Pager {
                Title = "««", PageNum = "1", CurrentPage = false
            });

            if (CurrentPage == 1)
            {
                listPagers.Add(new Pager {
                    Title = "«", PageNum = CurrentPage.ToString(), CurrentPage = false
                });
            }
            else
            {
                listPagers.Add(new Pager {
                    Title = "«", PageNum = (CurrentPage - 1).ToString(), CurrentPage = false
                });
            }

            for (long i = startIndex; i < endIndex; i++)
            {
                //long test = CurrentPage - 1;
                listPagers.Add(new Pager {
                    Title = (i + 1).ToString(), PageNum = (i + 1).ToString(), CurrentPage = i == (CurrentPage - 1)
                });
            }

            if (CurrentPage == TotalPages)
            {
                listPagers.Add(new Pager {
                    Title = "»", PageNum = CurrentPage.ToString(), CurrentPage = false
                });
            }
            else
            {
                listPagers.Add(new Pager {
                    Title = "»", PageNum = (CurrentPage + 1).ToString(), CurrentPage = false
                });
            }

            listPagers.Add(new Pager {
                Title = "»»", PageNum = TotalPages.ToString(), CurrentPage = false
            });
        }
        /// <summary>
        /// 初始化控件显示
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="gridControl"></param>
        public void InitCtrl(DataTable dataTable, GridControl gridControl, int[] rowCountItems)
        {
            try
            {
                SetRowCountItems(rowCountItems);

                #region 初始化属性
                if (dataTable == null)
                {
                    return;
                }
                BindingGrid         = gridControl;
                BindingDataTable    = dataTable;
                RowsCount           = Convert.ToInt32(cbxRowCount.Text);
                dataSourceRowsCount = BindingDataTable.Rows.Count;
                TotalPages          = (int)Math.Ceiling((double)dataSourceRowsCount / RowsCount);
                CurrentPage         = dataSourceRowsCount == 0 ? 0 : 1;
                ShowingDataTable    = new DataTable();
                if (BindingDataTable.Rows.Count == 0)
                {
                    #region 初始化控件显示
                    tbxCurrentPage.Text = CurrentPage.ToString();
                    lbTotalPages.Text   = TotalPages.ToString();
                    lbTotalRows.Text    = "共 " + dataSourceRowsCount.ToString() + " 条记录";
                    #endregion
                    return;
                }
                if (BindingDataTable.Rows.Count > 0 && BindingDataTable.Rows.Count <= RowsCount)
                {
                    ShowingDataTable = BindingDataTable.Copy();
                }
                else
                {
                    DataColumnCollection dataColumns = BindingDataTable.Columns;
                    foreach (DataColumn dataColumn in dataColumns)
                    {
                        ShowingDataTable.Columns.Add(dataColumn.ColumnName, dataColumn.DataType);
                    }
                    DataRow dataRow = null;
                    for (int i = 0; i < RowsCount; i++)
                    {
                        dataRow = ShowingDataTable.NewRow();
                        dataRow = BindingDataTable.Rows[i];
                        ShowingDataTable.ImportRow(dataRow);
                    }
                }
                #endregion

                #region 初始化控件显示
                tbxCurrentPage.Text = CurrentPage.ToString();
                lbTotalPages.Text   = "共 " + TotalPages.ToString() + " 页";
                lbTotalRows.Text    = "共 " + dataSourceRowsCount.ToString() + " 条记录";
                #endregion
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
            finally
            {
                BindingGrid.DataSource = ShowingDataTable;
                BindingGrid.RefreshDataSource();
            }
        }
Exemplo n.º 17
0
        //------------------------------------------------------------------------------------------
        // Function:     GeneratePaginationLinks
        // Description:  Generate html for pagination links
        //---------------------------------------------

        private string GeneratePaginationLinks(string myUrlBase, string strOrderBy)
        {
            string strNavlinks    = "<strong>Page:</strong> ";
            int    iStartLinkPage = 0;
            int    iEndLinkPage   = 0;

            string strPageLink = null;

            if (myUrlBase.Contains("?"))
            {
                strPageLink = "&page=";
            }
            else
            {
                strPageLink = "/";
            }


            if (PageIndex >= MaxPaginationLinks)
            {
                iStartLinkPage = (PageIndex - MaxPaginationLinks) + 1;
                if (iStartLinkPage < 1)
                {
                    iStartLinkPage = 1;
                }
            }
            else
            {
                iStartLinkPage = 1;
            }

            if ((iStartLinkPage + MaxPaginationLinks) > (TotalPages))
            {
                iEndLinkPage = TotalPages;
            }
            else
            {
                iEndLinkPage = iStartLinkPage + (MaxPaginationLinks - 1);
            }

            //----If the calculated start page for the numbered links is greater than 1, display a "first" link----------------

            if (iStartLinkPage > 1)
            {
                strNavlinks = strNavlinks + "<a href=\"" + myUrlBase + strPageLink + "1" + strOrderBy + "\">First</a> ";
            }

            if (HasPreviousPage)
            {
                strNavlinks = strNavlinks + "<a href=\"" + myUrlBase + strPageLink + (PageIndex - 1).ToString() + strOrderBy + "\">Previous</a> ";
            }

            for (int iPageCount = iStartLinkPage; iPageCount <= iEndLinkPage; iPageCount++)
            {
                if (iPageCount == PageIndex)
                {
                    strNavlinks = strNavlinks + "<b>" + iPageCount.ToString() + "</b> ";
                }
                else
                {
                    strNavlinks = strNavlinks + "<a href=\"" + myUrlBase + strPageLink + iPageCount.ToString() + strOrderBy + "\">" + iPageCount.ToString() + "</a> ";
                }
            }

            if (HasNextPage)
            {
                strNavlinks = strNavlinks + "<a href=\"" + myUrlBase + strPageLink + (PageIndex + 1).ToString() + strOrderBy + "\">Next</a> ";
            }

            //----If the calculated end page for the numbered links is less than the total number of pages, then display a "Last" link----
            if (iEndLinkPage < TotalPages)
            {
                strNavlinks = strNavlinks + " <a href=\"" + myUrlBase + strPageLink + TotalPages.ToString() + strOrderBy + "\">Last</a>";
            }

            return(strNavlinks);
        }
Exemplo n.º 18
0
        private void CheckVisualForSpecialRuns(FrameworkElement root)
        {
            var currentPages = new List <CurrentPage>();
            var pageCounts   = new List <PageCount>();
            var text         = root as TextBlock;

            if (text != null)
            {
                foreach (var run in text.Inlines)
                {
                    var pageCount = run as PageCount;
                    if (pageCount != null)
                    {
                        pageCounts.Add(pageCount);
                    }

                    var currentPage = run as CurrentPage;
                    if (currentPage != null)
                    {
                        currentPages.Add(currentPage);
                    }
                }

                foreach (var pageCount in pageCounts)
                {
                    pageCount.Text = TotalPages.ToString(CultureInfo.InvariantCulture);
                }
                foreach (var currentPage in currentPages)
                {
                    currentPage.Text = CurrentPage.ToString(CultureInfo.InvariantCulture);
                }
                return;
            }

            var items = root as ItemsControl;

            if (items != null)
            {
                foreach (var item in items.Items)
                {
                    var childElement = item as FrameworkElement;
                    if (childElement != null)
                    {
                        CheckVisualForSpecialRuns(childElement);
                    }
                }
            }
            else
            {
                var panel = root as Panel;
                if (panel != null)
                {
                    foreach (var item in panel.Children)
                    {
                        var childElement = item as FrameworkElement;
                        if (childElement != null)
                        {
                            CheckVisualForSpecialRuns(childElement);
                        }
                    }
                }
            }
        }
Exemplo n.º 19
0
/// <summary>
/// overridden to handle custom pager rendering for runtime and design time
/// </summary>
/// <param name="writer"></param>
        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);

            if (TotalPages == 0 && TotalItems > 0)
            {
                TotalPages = CalculateTotalPagesFromTotalItems(); // calculate based on totalitems
            }
            if (DesignMode)
            {
                TotalPages = 10;
            }

            // don't render pager if there's only one page
            if (TotalPages < 2)
            {
                return;
            }

            if (RenderContainerDiv)
            {
                if (!string.IsNullOrEmpty(ContainerDivCssClass))
                {
                    writer.AddAttribute("class", ContainerDivCssClass);
                }
                writer.RenderBeginTag("div");
            }

            // main pager wrapper
            writer.WriteBeginTag("div");
            writer.AddAttribute("id", this.ClientID);
            if (!string.IsNullOrEmpty(CssClass))
            {
                writer.WriteAttribute("class", this.CssClass);
            }

            //writer.Write(HtmlTextWriter.TagRightChar + "\r\n");


            // Pages Text
            writer.WriteBeginTag("span");
            if (!string.IsNullOrEmpty(PagesTextCssClass))
            {
                writer.WriteAttribute("class", PagesTextCssClass);
            }
            writer.Write(HtmlTextWriter.TagRightChar);
            writer.Write(this.PagesText);
            writer.WriteEndTag("span");

            // if the base url is empty use the current URL
            FixupBaseUrl();

            // set _startPage and _endPage
            ConfigurePagesToRender();

            // write out first page link
            if (ShowFirstAndLastPageLinks && _startPage != 1)
            {
                writer.WriteBeginTag("a");
                string pageUrl = StringUtils.SetUrlEncodedKey(BaseUrl, QueryStringPageField, (1).ToString());
                writer.WriteAttribute("href", pageUrl);
                if (!string.IsNullOrEmpty(PageLinkCssClass))
                {
                    writer.WriteAttribute("class", PageLinkCssClass + " " + PageLinkCssClass + "-first");
                }
                writer.Write(HtmlTextWriter.SelfClosingTagEnd);
                writer.Write("1");
                writer.WriteEndTag("a");
            }

            // write out all the page links
            for (int i = _startPage; i < _endPage + 1; i++)
            {
                if (i == ActivePage)
                {
                    writer.WriteBeginTag("span");
                    if (!string.IsNullOrEmpty(SelectedPageCssClass))
                    {
                        writer.WriteAttribute("class", SelectedPageCssClass);
                    }
                    writer.Write(HtmlTextWriter.TagRightChar);
                    writer.Write(i.ToString());
                    writer.WriteEndTag("span");
                }
                else
                {
                    writer.WriteBeginTag("a");
                    string pageUrl = StringUtils.SetUrlEncodedKey(BaseUrl, QueryStringPageField, i.ToString()).TrimEnd('&');
                    writer.WriteAttribute("href", pageUrl);
                    if (!string.IsNullOrEmpty(PageLinkCssClass))
                    {
                        writer.WriteAttribute("class", PageLinkCssClass);
                    }
                    writer.Write(HtmlTextWriter.TagRightChar);
                    writer.Write(i.ToString());
                    writer.WriteEndTag("a");
                }

                writer.Write("\r\n");
            }

            // write out last page link
            if (ShowFirstAndLastPageLinks && _endPage < TotalPages)
            {
                writer.WriteBeginTag("a");
                string pageUrl = StringUtils.SetUrlEncodedKey(BaseUrl, QueryStringPageField, TotalPages.ToString());
                writer.WriteAttribute("href", pageUrl);
                if (!string.IsNullOrEmpty(PageLinkCssClass))
                {
                    writer.WriteAttribute("class", PageLinkCssClass + " " + PageLinkCssClass + "-last");
                }
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.Write(TotalPages.ToString());
                writer.WriteEndTag("a");
                writer.Write("\r\n");
            }


            // Previous link
            if (ShowPreviousNextLinks && !string.IsNullOrEmpty(PreviousText) && ActivePage > 1)
            {
                writer.WriteBeginTag("a");
                string pageUrl = StringUtils.SetUrlEncodedKey(BaseUrl, QueryStringPageField, (ActivePage - 1).ToString());
                writer.WriteAttribute("href", pageUrl);
                if (!string.IsNullOrEmpty(PageLinkCssClass))
                {
                    writer.WriteAttribute("class", PageLinkCssClass + " " + PageLinkCssClass + "-prev");
                }
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.Write(PreviousText);
                writer.WriteEndTag("a");
                writer.Write("\r\n");
            }

            // Next link
            if (ShowPreviousNextLinks && !string.IsNullOrEmpty(NextText) && ActivePage < TotalPages)
            {
                writer.WriteBeginTag("a");
                string pageUrl = StringUtils.SetUrlEncodedKey(BaseUrl, QueryStringPageField, (ActivePage + 1).ToString());
                writer.WriteAttribute("href", pageUrl);
                if (!string.IsNullOrEmpty(PageLinkCssClass))
                {
                    writer.WriteAttribute("class", PageLinkCssClass + " " + PageLinkCssClass + "-next");
                }
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.Write(NextText);
                writer.WriteEndTag("a");
                writer.Write("\r\n");
            }

            writer.WriteEndTag("div");

            if (RenderContainerDiv)
            {
                if (RenderContainerDivBreak)
                {
                    writer.Write("<div style=\"clear:both\"></div>\r\n");
                }

                writer.WriteEndTag("div");
                writer.Write("\r\n");
            }
        }
Exemplo n.º 20
0
 // *********************************************************************
 //  DisplayCurrentPage
 //
 /// <summary>
 /// Displays the current page that the user is viewing
 /// </summary>
 // ********************************************************************/
 private void DisplayCurrentPage()
 {
     currentPage.Text = General.GetString("PAGE", "Page", null) + " " + (PageIndex + 1).ToString("n0") + " " +
                        General.GetString("OF", "of", null) + " " + TotalPages.ToString("n0");
 }