コード例 #1
0
        void richEditControl1_SelectionChanged(object sender, EventArgs e)
        {
            RichEditControl richEdit = sender as RichEditControl;

            if (richEdit.DocumentLayout.IsDocumentFormattingCompleted)
            {
                int currentPageIndex = richEdit.Views.PrintLayoutView.CurrentPageIndex;
                barStaticItem3.Caption = string.Format("Current page: {0}", currentPageIndex + 1);

                CustomLayoutVisitor visitor = new CustomLayoutVisitor(richEdit.Document);

                for (int i = 0; i < richEdit.DocumentLayout.GetPageCount(); i++)
                {
                    visitor.Reset();
                    LayoutPage page = richEdit.DocumentLayout.GetPage(i);
                    visitor.Visit(page);

                    if (visitor.IsFound)
                    {
                        break;
                    }
                }

                if (visitor.IsFound)
                {
                    barStaticItem4.Caption = string.Format("Current line: {0}", visitor.RowIndex);
                    barStaticItem5.Caption = string.Format("Current column: {0}", visitor.ColIndex);
                }
            }
        }
コード例 #2
0
        void DocumentLayout_DocumentFormatted(object sender, EventArgs e)
        {
            this.BeginInvoke((MethodInvoker)(() =>
            {
                if (this.Visible)
                {
                    CustomLayoutVisitor visitor = new CustomLayoutVisitor(richEditControl1.Document);
                    List <PageLayoutInfo> list = richEditControl1.ActiveView.GetVisiblePageLayoutInfos();

                    for (int i = 0; i < list.Count; i++)
                    {
                        visitor.Reset();
                        visitor.Visit(richEditControl1.DocumentLayout.GetPage(list[i].PageIndex));
                    }

                    UpdateStaticItems(richEditControl1);
                }
            }));
        }