private void SimpleButton_Click(object sender, RoutedEventArgs e)
        {
            MyVisitor        visitor  = new MyVisitor();
            DocumentIterator iterator = new DocumentIterator(richEditControl1.Document, true);

            while (iterator.MoveNext())
            {
                iterator.Current.Accept(visitor);
            }
            textEdit1.Text = visitor.Text;
        }
コード例 #2
0
        private int GetWordCount(RichEditControl richEdit)
        {
            DocumentIterator   iterator = new DocumentIterator(richEdit.Document, true);
            StaticsticsVisitor visitor  = new StaticsticsVisitor();

            while (iterator.MoveNext())
            {
                iterator.Current.Accept(visitor);
            }

            return(visitor.WordCount);
        }
コード例 #3
0
 private void btnIteratorRun_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     #region #runvisitor
     MyVisitor        visitor  = new MyVisitor();
     DocumentIterator iterator = new DocumentIterator(richEditControl1.Document, true);
     while (iterator.MoveNext())
     {
         iterator.Current.Accept(visitor);
     }
     memoEdit1.Text = visitor.Text;
     #endregion #runvisitor
 }
コード例 #4
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            var visitor = new SpreadRichDocumentVisitor(Editor.Document.Range.End.ToInt());

            using (DocumentIterator iterator = new DocumentIterator(Editor.Document, true))
            {
                while (iterator.MoveNext())
                {
                    iterator.Current.Accept(visitor);
                }
            }
            RichTextString richText = visitor.RichText;

            cell.SetRichText(richText);
            if (Editor.Document.Paragraphs.Count > 1)
            {
                cell.Alignment.WrapText = true;
            }
        }
コード例 #5
0
        public async Task <ParsingResult> Parse(ParsingRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            logger.LogDebug("Parsing [{0}]", request.File.FullName);
            using (var documentProcessor = new RichEditDocumentServer())
            {
                documentProcessor.LayoutCalculationMode = CalculationModeType.Automatic;
                documentProcessor.LayoutUnit            = DocumentLayoutUnit.Document;
                var loaded = Observable.FromEventPattern <EventHandler, EventArgs>(
                    h => documentProcessor.DocumentLayout.DocumentFormatted += h,
                    h => documentProcessor.DocumentLayout.DocumentFormatted -= h)
                             .FirstOrDefaultAsync()
                             .GetAwaiter();

                documentProcessor.LoadDocument(request.File.FullName);
                await loaded;

                var iterator   = new DocumentIterator(documentProcessor.Document);
                var pageLayout = new CurrentLayoutVisitor();
                var visitor    = new DocumentVisitor(pageLayout);

                var layoutIterator = new LayoutIterator(documentProcessor.DocumentLayout);
                while (layoutIterator.MoveNext(LayoutLevel.Page))
                {
                    layoutIterator.Current.Accept(pageLayout);
                }

                while (iterator.MoveNext())
                {
                    iterator.Current.Accept(visitor);
                }

                return(new ParsingResult(visitor.GenerateResult(request.MaxPages), request, ParsingType.Extract));
            }
        }