public void InsertImage(string bookmarkStr, System.Drawing.Image image)
        {
            try
            {
                BookmarkRangeStart bookmark = this.radRichTextBox.Document.GetBookmarkByName(bookmarkStr);

                if (bookmark != null)
                {
                    this.radRichTextBox.Document.GoToBookmark(bookmark);
                    //this.radRichTextBox.Document.Selection.SelectAnnotationRange(bookmark);

                    using (Stream stream = new System.IO.MemoryStream())
                    {
                        image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                        stream.Position = 0;

                        this.radRichTextBox.InsertImage(stream, "png");
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                LoggerHelper.Log(ex.Message + "\n" + ex.StackTrace);
            }
        }
        public void InsertInfo(string bookmarkStr, string insertContent)
        {
            //return;

            BookmarkRangeStart bookmark = this.radRichTextBox.Document.GetBookmarkByName(bookmarkStr);

            this.radRichTextBox.Document.GoToBookmark(bookmark);
            this.radRichTextBox.Document.Selection.SelectAnnotationRange(bookmark);

            this.radRichTextBox.Insert(insertContent);
        }
Esempio n. 3
0
 protected void btnExportXLSX_Click(object sender, EventArgs e)
 {
     /*
      * var document = new RadFlowDocument();
      * var editor = new RadFlowDocumentEditor(document);
      * editor.ParagraphFormatting.TextAlignment.LocalValue = Alignment.Justified;
      * editor.InsertLine("Dear Telerik User,");
      * editor.InsertText("We're happy to introduce the new Telerik RadWordsProcessing component for WPF. High performance library that enables you to read, write and manipulate documents in DOCX, RTF and plain text format. The document model is independent from UI and ");
      * Run run = editor.InsertText("does not require");
      * run.Underline.Pattern = UnderlinePattern.Single;
      * editor.InsertLine(" Microsoft Office.");
      * editor.InsertText("bold, ").FontWeight = System.Windows.FontWeights.Bold;
      * editor.InsertText("italic, ").FontStyle = System.Windows.FontStyles.Italic;
      * editor.InsertText("underline,").Underline.Pattern = UnderlinePattern.Single;
      * editor.InsertText(" font sizes and ").FontSize = 20;
      * editor.InsertText("colors ").ForegroundColor = new ThemableColor(System.Windows.Media.Colors.Green);
      * editor.InsertText("or ");
      * editor.InsertText("colors2 ").ForegroundColor = new ThemableColor(System.Windows.Media.Color.FromRgb(255,0,0));
      * editor.InsertLine("as well as text alignment and indentation. Other options include tables, hyperlinks, inline and floating images. Even more sweetness is added by the built-in styles and themes.");
      * editor.InsertText("Here at Telerik we strive to provide the best services possible and fulfill all needs you as a customer may have. We would appreciate any feedback you send our way through the ");
      * editor.InsertHyperlink("public forums", "http://www.telerik.com/forums", false, "Telerik Forums");
      * editor.InsertLine(" or support ticketing system.");
      * editor.InsertLine("We hope you'll enjoy RadWordsProcessing as much as we do. Happy coding!");
      * editor.InsertParagraph();
      * editor.InsertLine("Kind regards,");
      * editor.InsertLine("Telerik Admin");
      * exportDOCX(document);
      */
     try {
         DocumentReplacemetsController cont = new DocumentReplacemetsController();
         List <DocumentReplacemetB>    reps = new List <DocumentReplacemetB>();
         reps = cont.GetDocumentReplacemets("GLOBAL");
         DocumentReplacemetB curRep = reps.Find(o => o.Title == "Τίτλος Test");
         if (curRep != null)
         {
             RadFlowDocument       curDoc = LoadSampleDocument();
             RadFlowDocumentEditor editor = new RadFlowDocumentEditor(curDoc);
             //System.Text.RegularExpressions.Regex textRegex = new System.Text.RegularExpressions.Regex("ΣΑΟΥΣΟΠΟΥΛΟΥ ΑΝΝΑ");
             //editor.ReplaceText("ΣΑΟΥΣΟΠΟΥΛΟΥ ΑΝΝΑ", txtNew.Text, true, true);
             BookmarkRangeStart bookmarkRangeStart = editor.Document.EnumerateChildrenOfType <BookmarkRangeStart>().Where(rangeStart => rangeStart.Bookmark.Name == "Name2Change").FirstOrDefault();
             editor.MoveToInlineEnd(bookmarkRangeStart);
             editor.InsertText(curRep.Text);
             exportXLSX(curDoc);
         }
     }
     catch (Exception) { }
 }
Esempio n. 4
0
        private void AddSubTitle(IGlymaNode map, string bookMarkId)
        {
            var paragraph = new Paragraph();

            paragraph.StyleName = string.Format("Heading{0}", 1);
            if (ShowImage)
            {
                CreateNodeIcon(map, ref paragraph);
            }
            var text = new Span(string.IsNullOrEmpty(map.Name) ? "(No Name)" : map.Name);
            //{
            //    FontSize = 18,
            //    ForeColor = Colors.DarkSlateBlue
            //};

            var bookMarkStart = new BookmarkRangeStart(bookMarkId);
            var bookMarkEnd   = new BookmarkRangeEnd();

            bookMarkEnd.PairWithStart(bookMarkStart);
            paragraph.Inlines.Add(bookMarkStart);
            paragraph.Inlines.Add(text);
            paragraph.Inlines.Add(bookMarkEnd);
            Section.Blocks.Add(paragraph);
        }
        private void AddSubTitle(IGlymaNode map, string bookMarkId)
        {
            var paragraph = new Paragraph();
            paragraph.StyleName = string.Format("Heading{0}", 1);
            if (ShowImage)
            {
                CreateNodeIcon(map, ref paragraph);
            }
            var text = new Span(string.IsNullOrEmpty(map.Name) ? "(No Name)" : map.Name);
            //{
            //    FontSize = 18,
            //    ForeColor = Colors.DarkSlateBlue
            //};

            var bookMarkStart = new BookmarkRangeStart(bookMarkId);
            var bookMarkEnd = new BookmarkRangeEnd();
            bookMarkEnd.PairWithStart(bookMarkStart);
            paragraph.Inlines.Add(bookMarkStart);
            paragraph.Inlines.Add(text);
            paragraph.Inlines.Add(bookMarkEnd);
            Section.Blocks.Add(paragraph);          
        }