コード例 #1
0
        public void DocumentStyle_ListView_Contains_all_styles_from_model_ImportStylesClass_datasource()
        {
            using var application = DocumentStyleManagerModule().Application;
            ModelSetup(application);
            using (var objectSpace = application.CreateObjectSpace()){
                var dataObject = objectSpace.CreateObject <DataObject>();
                Document.NewDocumentStyle(1, DocumentStyleType.Paragraph);
                dataObject.Content = Document.ToByteArray(DocumentFormat.OpenXml);
                dataObject         = objectSpace.CreateObject <DataObject>();
                RichEditDocumentServer.CreateNewDocument();
                RichEditDocumentServer.Document.NewDocumentStyle(2, DocumentStyleType.Paragraph);
                RichEditDocumentServer.Document.NewDocumentStyle(1, DocumentStyleType.Character);
                dataObject.Content = RichEditDocumentServer.Document.ToByteArray(DocumentFormat.OpenXml);
                RichEditDocumentServer.CreateNewDocument();
                dataObject = objectSpace.CreateObject <DataObject>();
                RichEditDocumentServer.Document.NewDocumentStyle(2, DocumentStyleType.Character);
                dataObject.Content = RichEditDocumentServer.Document.ToByteArray(DocumentFormat.OpenXml);
                objectSpace.CommitChanges();
            }


            var view          = (ListView)application.NewView(application.FindListViewId(typeof(DocumentStyle)));
            var listViewFrame = application.WhenViewOnFrame(typeof(DocumentStyle)).Test();

            application.CreateViewWindow().SetView(view);

            var documentStyles = listViewFrame.Items.First().View.AsListView().CollectionSource.Objects <DocumentStyle>().ToArray();

            documentStyles.Length.ShouldBe(8);
            documentStyles.Count(style => style.DocumentStyleType == DocumentStyleType.Paragraph).ShouldBe(3);
            documentStyles.Count(style => style.DocumentStyleType == DocumentStyleType.Character).ShouldBe(5);
        }
コード例 #2
0
 public override void Setup()
 {
     base.Setup();
     RichEditDocumentServer = new RichEditDocumentServer();
     RichEditDocumentServer.CreateNewDocument();
     Document = RichEditDocumentServer.Document;
 }
コード例 #3
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofdlg = new OpenFileDialog();

            ofdlg.Multiselect = false;
            ofdlg.Filter      = "Word 97-2003 Files (*.doc)|*.doc";
            if (ofdlg.ShowDialog() == true)
            {
                image1.Source   = null;
                textBlock1.Text = string.Empty;
                #region #richserverload
                richServer = new RichEditDocumentServer();
                richServer.CreateNewDocument();
                try {
                    richServer.LoadDocument(ofdlg.File.OpenRead(), DocumentFormat.Doc);
                    imgs = richServer.Document.GetImages(richServer.Document.Range);
                    if (imgs.Count > 0)
                    {
                        ShowCurrentImage();
                    }
                    textBlock1.Text = richServer.Document.Text;
                }
                catch (Exception ex) {
                    textBlock1.Text = "Exception occurs:\n" + ex.Message;
                }
                #endregion #richserverload

                button2.IsEnabled = true;
                this.SimpleAnimation.Completed += new EventHandler(SimpleAnimaton_Completed);
                this.SimpleAnimation.Begin();
            }
        }
        void evaluator_OnBeforeCompile(object sender, EventArgs e)
        {
            Document document = wordProcessor.Document;

            document.BeginUpdate();
            codeEditor.BeforeCompile();
            wordProcessor.CreateNewDocument();
            document.Unit = DevExpress.Office.DocumentUnit.Document;
        }
コード例 #5
0
 private void btnPageCountSelectedRange_Click(object sender, EventArgs e)
 {
     #region #GetPageCountForSelection
     RichEditDocumentServer srv = new RichEditDocumentServer();
     srv.CreateNewDocument();
     srv.Document.AppendDocumentContent(richEditControl1.Document.Selection);
     int pageCount = srv.DocumentLayout.GetPageCount();
     MessageBox.Show(String.Format("Selected range will occupy {0} page(s)", pageCount));
     #endregion #GetPageCountForSelection
 }
コード例 #6
0
 public Form1()
 {
     InitializeComponent();
     server = new RichEditDocumentServer();
     server.CreateNewDocument();
     server.Document.Images.Append
         (DocumentImageSource.FromUri("http://www.devexpress.com/i/pagetitles/xtrarichedit.png", null));
     embedImagesCheck.EditValue = true;
     server.ContentChanged     += new EventHandler(richEditControl1_ContentChanged);
 }
コード例 #7
0
        public void New_DocumentStyle_Default_Properties_Should_reflect_To_DefaultPropertiesProvider(DocumentStyleType type)
        {
            RichEditDocumentServer.CreateNewDocument();
            RichEditDocumentServer.Document.DefaultCharacterProperties.FontSize = 30;

            var styles        = type == DocumentStyleType.Paragraph? Document.ParagraphStyles:Document.CharacterStyles.Cast <CharacterPropertiesBase>();
            var documentStyle = styles.Select(style => style.ToDocumentStyle(RichEditDocumentServer.Document)).First();

            documentStyle.FontName.ShouldNotBeNull();
            documentStyle.FontSize.ShouldBe(30);
            if (type == DocumentStyleType.Paragraph)
            {
                documentStyle.SuppressHyphenation.ShouldNotBeNull();
            }
        }
コード例 #8
0
        public void CreateNewStyle_Updates_DefaultProperties()
        {
            RichEditDocumentServer.CreateNewDocument();
            RichEditDocumentServer.Document.DefaultCharacterProperties.FontSize            = 30;
            RichEditDocumentServer.Document.DefaultParagraphProperties.SuppressHyphenation = true;

            var nativeStyle = Document.CreateNewStyle(new DocumentStyle()
            {
                StyleName = "test"
            }, RichEditDocumentServer.Document);

            nativeStyle.FontSize.ShouldBeNull();
            Document.DefaultCharacterProperties.FontSize.ShouldBe(30);
            Document.DefaultParagraphProperties.SuppressHyphenation.ShouldNotBeNull();
            Document.DefaultParagraphProperties.SuppressHyphenation.Value.ShouldBeTrue();
        }
コード例 #9
0
        string PrintToPDF(RichEditDocumentServer server, string filePath)
        {
            try {
                server.LoadDocument(filePath);
            }
            catch (Exception ex) {
                server.CreateNewDocument();
                return(String.Format("{0:T} Error:{1} -> {2}", DateTime.Now, ex.Message, filePath) + Environment.NewLine);
            }
            string     outFileName = Path.ChangeExtension(filePath, "pdf");
            FileStream fsOut       = File.Open(outFileName, FileMode.Create);

            server.ExportToPdf(fsOut);
            fsOut.Close();
            return(String.Format("{0:T} Done-> {1}", DateTime.Now, outFileName) + Environment.NewLine);
        }
コード例 #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (MemoryStream stream = new MemoryStream()) {
             RichEditDocumentServer server = new RichEditDocumentServer();
             server.CreateNewDocument();
             server.Document.AppendText("Hello world!");
             server.Document.Paragraphs.Append();
             server.Document.AppendText("Some text...");
             server.SaveDocument(stream, DocumentFormat.OpenXml);
             stream.Position = 0;
             DocumentManager.CloseDocument(documentId);
             RichEdit.Open(documentId, DocumentFormat.OpenXml, () => stream);
         }
         RichEdit.Focus();
     }
 }
        static void CustomDocumentProperties(RichEditDocumentServer server)
        {
            #region #CustomDocumentProperties
            server.CreateNewDocument();
            Document document = server.Document;
            document.BeginUpdate();
            document.Fields.Create(document.AppendText("\nMyNumericProperty: ").End, "DOCVARIABLE CustomProperty MyNumericProperty");
            document.Fields.Create(document.AppendText("\nMyStringProperty: ").End, "DOCVARIABLE CustomProperty MyStringProperty");
            document.Fields.Create(document.AppendText("\nMyBooleanProperty: ").End, "DOCVARIABLE CustomProperty MyBooleanProperty");
            document.EndUpdate();

            document.CustomProperties.Add("MyNumericProperty", 123.45);
            document.CustomProperties.Add("MyStringProperty", "The Final Answer");
            document.CustomProperties.Add("MyBooleanProperty", true);

            server.CalculateDocumentVariable += DocumentPropertyDisplayHelper.OnCalculateDocumentVariable;
            document.Fields.Update();
            #endregion #CustomDocumentProperties
        }
        static void StandardDocumentProperties(RichEditDocumentServer server)
        {
            #region #StandardDocumentProperties
            server.CreateNewDocument();
            Document document = server.Document;
            document.BeginUpdate();

            document.DocumentProperties.Creator     = "John Doe";
            document.DocumentProperties.Title       = "Inserting Custom Properties";
            document.DocumentProperties.Category    = "TestDoc";
            document.DocumentProperties.Description = "This code demonstrates API to modify and display standard document properties.";

            document.Fields.Create(document.AppendText("\nAUTHOR: ").End, "AUTHOR");
            document.Fields.Create(document.AppendText("\nTITLE: ").End, "TITLE");
            document.Fields.Create(document.AppendText("\nCOMMENTS: ").End, "COMMENTS");
            document.Fields.Create(document.AppendText("\nCREATEDATE: ").End, "CREATEDATE");
            document.Fields.Create(document.AppendText("\nCategory: ").End, "DOCPROPERTY Category");
            document.Fields.Update();
            document.EndUpdate();
            #endregion #StandardDocumentProperties
        }
コード例 #13
0
        private void PrintToPDF(string filePath)
        {
            string displayText;

            try {
                server.LoadDocument(filePath);
            }
            catch (Exception ex) {
                server.CreateNewDocument();
                displayText    = String.Format("{0:T} Error:{1} -> {2}", DateTime.Now, ex.Message, filePath) + Environment.NewLine;
                textBox2.Text += displayText;
                return;
            }
            string     outFileName = Path.ChangeExtension(filePath, "pdf");
            FileStream fsOut       = File.Open(outFileName, FileMode.Create);

            server.ExportToPdf(fsOut);
            fsOut.Close();
            displayText    = String.Format("{0:T} Done-> {1}", DateTime.Now, outFileName) + Environment.NewLine;
            textBox2.Text += displayText;
        }
        private void CopyToClipboard()
        {
            GridCell[] cells = gridView1.GetSelectedCells();
            var        rows  = from c in cells
                               group c by c.RowHandle
                               into gr
                               orderby gr.Key
                               select gr;
            var columns = from c in cells
                          group c by c.Column
                          into gr
                          orderby gr.Key.VisibleIndex
                          select gr;
            RichEditDocumentServer srv = new RichEditDocumentServer();

            srv.CreateNewDocument();
            Table table = srv.Document.Tables.Create(srv.Document.CaretPosition, rows.Count() + 1, columns.Count());

            SetBorders(table);
            CopyColumns(columns, srv, table);
            CopyCells(rows, srv, table);

            DevExpress.XtraRichEdit.Export.HtmlDocumentExporterOptions options = srv.Options.Export.Html;
            options.ExportRootTag           = ExportRootTag.Html;
            options.Encoding                = Encoding.UTF8;
            options.CssPropertiesExportType = CssPropertiesExportType.Inline;
            options.UriExportType           = UriExportType.Absolute;
            options.EmbedImages             = false;

            string htmlContent = srv.HtmlText;
            string cfHtml      = CF_HTMLHelper.GetHtmlClipboardFormat(htmlContent);

            IDataObject dataObject = new DataObject();

            dataObject.SetData(DataFormats.Text, srv.Text);
            dataObject.SetData(DataFormats.Html, cfHtml);
            Clipboard.SetDataObject(dataObject, true);
        }
 static void CreateNewDocument(RichEditDocumentServer wordProcessor)
 {
     #region #CreateDocument
     wordProcessor.CreateNewDocument();
     #endregion #CreateDocument
 }
 static void CreateNewDocument(RichEditDocumentServer server)
 {
     #region #CreateDocument
     server.CreateNewDocument();
     #endregion #CreateDocument
 }