static void FormatParagraph(RichEditDocumentServer wordProcessor)
 {
     #region #FormatParagraph
     Document document = wordProcessor.Document;
     document.BeginUpdate();
     document.AppendText("Modified Paragraph\nNormal\nNormal");
     document.EndUpdate();
     DocumentPosition    pos   = document.Range.Start;
     DocumentRange       range = document.CreateRange(pos, 0);
     ParagraphProperties pp    = document.BeginUpdateParagraphs(range);
     // Center paragraph
     pp.Alignment = ParagraphAlignment.Center;
     // Set triple spacing
     pp.LineSpacingType       = ParagraphLineSpacing.Multiple;
     pp.LineSpacingMultiplier = 3;
     // Set left indent at 0.5".
     // Default unit is 1/300 of an inch (a document unit).
     pp.LeftIndent = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.5f);
     // Set tab stop at 1.5"
     TabInfoCollection tbiColl = pp.BeginUpdateTabs(true);
     TabInfo           tbi     = new DevExpress.XtraRichEdit.API.Native.TabInfo();
     tbi.Alignment = TabAlignmentType.Center;
     tbi.Position  = DevExpress.Office.Utils.Units.InchesToDocumentsF(1.5f);
     tbiColl.Add(tbi);
     pp.EndUpdateTabs(tbiColl);
     document.EndUpdateParagraphs(pp);
     #endregion #FormatParagraph
 }
Пример #2
0
        void richEditControl_InitializeDocument(object sender, EventArgs e)
        {
            Document document = Control.Document;

            document.BeginUpdate();
            try {
                document.DefaultCharacterProperties.FontName = "Courier New";
                document.DefaultCharacterProperties.FontSize = 10;
                document.Sections[0].Page.Width                = Units.InchesToDocumentsF(100);
                document.Sections[0].LineNumbering.CountBy     = 1;
                document.Sections[0].LineNumbering.RestartType = LineNumberingRestart.Continuous;

                SizeF             tabSize = Control.MeasureSingleLineString("    ", document.DefaultCharacterProperties);
                TabInfoCollection tabs    = document.Paragraphs[0].BeginUpdateTabs(true);
                try {
                    for (int i = 1; i <= 30; i++)
                    {
                        DevExpress.XtraRichEdit.API.Native.TabInfo tab = new DevExpress.XtraRichEdit.API.Native.TabInfo();
                        tab.Position = i * tabSize.Width;
                        tabs.Add(tab);
                    }
                }
                finally {
                    document.Paragraphs[0].EndUpdateTabs(tabs);
                }
            }
            finally {
                document.EndUpdate();
            }
        }
Пример #3
0
        static void FormatParagraph(Document document)
        {
            #region #FormatParagraph
            document.BeginUpdate();
            document.AppendText("Modified Paragraph\nNormal\nNormal");
            document.EndUpdate();

            //The target range is the first paragraph
            DocumentPosition pos   = document.Range.Start;
            DocumentRange    range = document.CreateRange(pos, 0);

            // Create and customize an object
            // that sets character formatting for the selected range
            ParagraphProperties pp = document.BeginUpdateParagraphs(range);
            // Center paragraph
            pp.Alignment = ParagraphAlignment.Center;
            // Set triple spacing
            pp.LineSpacingType       = ParagraphLineSpacing.Multiple;
            pp.LineSpacingMultiplier = 3;
            // Set left indent at 0.5".
            // Default unit is 1/300 of an inch (a document unit).
            pp.LeftIndent = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.5f);
            // Set tab stop at 1.5"
            TabInfoCollection tbiColl = pp.BeginUpdateTabs(true);
            TabInfo           tbi     = new DevExpress.XtraRichEdit.API.Native.TabInfo();
            tbi.Alignment = TabAlignmentType.Center;
            tbi.Position  = DevExpress.Office.Utils.Units.InchesToDocumentsF(1.5f);
            tbiColl.Add(tbi);
            pp.EndUpdateTabs(tbiColl);

            //Finalize modifications
            // with this method call
            document.EndUpdateParagraphs(pp);
            #endregion #FormatParagraph
        }
Пример #4
0
 static void TabStops(Document document)
 {
     #region #TabStops
     document.Unit = DevExpress.Office.DocumentUnit.Inch;
     TabInfoCollection tabs = document.Paragraphs[0].BeginUpdateTabs(true);
     DevExpress.XtraRichEdit.API.Native.TabInfo tab1 = new DevExpress.XtraRichEdit.API.Native.TabInfo();
     // Sets tab stop at 2.5 inch.
     tab1.Position  = 2.5f;
     tab1.Alignment = TabAlignmentType.Left;
     tab1.Leader    = TabLeaderType.MiddleDots;
     tabs.Add(tab1);
     DevExpress.XtraRichEdit.API.Native.TabInfo tab2 = new DevExpress.XtraRichEdit.API.Native.TabInfo();
     tab2.Position  = 5.5f;
     tab2.Alignment = TabAlignmentType.Decimal;
     tab2.Leader    = TabLeaderType.EqualSign;
     tabs.Add(tab2);
     document.Paragraphs[0].EndUpdateTabs(tabs);
     #endregion #TabStops
 }
 private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     #region #measuresinglelinestring
     Document          document = richEditControl1.Document;
     SizeF             tabSize  = richEditControl1.MeasureSingleLineString(new String(' ', 4), document.DefaultCharacterProperties);
     TabInfoCollection tabs     = document.Paragraphs[0].BeginUpdateTabs(true);
     try {
         for (int i = 1; i <= 30; i++)
         {
             DevExpress.XtraRichEdit.API.Native.TabInfo tab = new DevExpress.XtraRichEdit.API.Native.TabInfo();
             tab.Position = i * tabSize.Width;
             tabs.Add(tab);
         }
     }
     finally {
         document.Paragraphs[0].EndUpdateTabs(tabs);
     }
     #endregion #measuresinglelinestring
 }