This is a migrated thread and some comments may be shown as answers.

Integration with RictTextBox?

7 Answers 69 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Edward
Top achievements
Rank 1
Edward asked on 28 Jan 2013, 08:17 PM
Is there any way to insert a diagram into an existing document in RichTextBox?  Something like InsertPictureCommand.

7 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 31 Jan 2013, 09:22 AM
Hello Edward,

RadRichTextBox does not support diagrams directly. However, it is possible to add an InlineUIContainer to RadDocument's structure that can host any UIElement. I suggest you refer to this help article for further information.

I hope this is helpful! Let us know if you need further assistance.
 
Kind regards,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Edward
Top achievements
Rank 1
answered on 06 Feb 2013, 09:32 PM
I tried to put it in an existing document and got an error "The type 'RadDiagram' was not found. [Line: 896 Position: 55]."  This is using the default XAMLFormatProvider.

<t:Paragraph>
                <t:InlineUIContainer>
                    <t:RadDiagram Width="1000" Height="600">
                        <t:RadDiagramShape Geometry="{t:ArrowShape ShapeType=DoubleArrow4}" Position="100 100" />
                        <t:RadDiagramShape Geometry="{t:CommonShape ShapeType=TriangleShape}" Position="300 100" />
                    </t:RadDiagram>
                </t:InlineUIContainer>
            </t:Paragraph>

0
Petar Mladenov
Telerik team
answered on 11 Feb 2013, 11:03 AM
Hello Edward,

 We are successfully using RadDiagram in InLineUIContainer. Please checkout our test project attached.
You need the following SL 5 dlls referenced to run it:

  • Telerik.Windows.Controls
  • Telerik.Windows.Controls.Diagrams
  • Telerik.Windows.Controls.Diagrams.Extensions
  • Telerik.Windows.Controls.RibbonView
  • Telerik.Windows.Controls.RuchTextBoxUI
  • Telerik.Windows.Data
  • Telerik.Windows.Documents

Let us know if this helps you or not.
Greetings,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Edward
Top achievements
Rank 1
answered on 11 Feb 2013, 06:17 PM
I do have those namespace referenced.  I am using 2012 Q3.

I used this to convert it to radDocument: _xamlProvider.Import(Text);

Here is the entire document:

<t:RadDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:t="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents" xmlns:s="clr-namespace:Telerik.Windows.Documents.Model.Styles;assembly=Telerik.Windows.Documents" version="1.2" DefaultPageLayoutSettings="816,1056" LayoutMode="Flow" PageViewMargin="10,10" StyleName="defaultDocumentStyle">
  <t:RadDocument.ProtectionSettings>
    <t:DocumentProtectionSettings EnableDocumentProtection="False" Enforce="False" HashingAlgorithm="None" HashingSpinCount="0" ProtectionMode="ReadOnly" />
  </t:RadDocument.ProtectionSettings>
  <t:RadDocument.Styles>
    <s:StyleDefinition BasedOnName="Normal" DisplayName="Caption" IsCustom="False" IsDefault="False" IsPrimary="True" Name="Caption" Type="Paragraph">
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties FontFamily="Calibri" FontSize="12" FontWeight="Bold" ForeColor="#FF4F81BD" />
      </s:StyleDefinition.SpanStyle>
    </s:StyleDefinition>
    <s:StyleDefinition DisplayName="Document Default Style" IsCustom="False" IsDefault="False" IsPrimary="True" Name="defaultDocumentStyle" Type="Default">
      <s:StyleDefinition.ParagraphStyle>
        <s:ParagraphProperties LineSpacing="1.15" SpacingAfter="12" />
      </s:StyleDefinition.ParagraphStyle>
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties FontFamily="Arial" FontSize="16" FontStyle="Normal" FontWeight="Normal" />
      </s:StyleDefinition.SpanStyle>
    </s:StyleDefinition>
    <s:StyleDefinition BasedOnName="Normal" DisplayName="Heading1" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading1Char" Name="Heading1" Type="Paragraph">
      <s:StyleDefinition.ParagraphStyle>
        <s:ParagraphProperties SpacingAfter="0" SpacingBefore="32" />
      </s:StyleDefinition.ParagraphStyle>
    </s:StyleDefinition>
    <s:StyleDefinition DisplayName="Heading1Char" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading1" Name="Heading1Char" Type="Character">
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties FontSize="18.6666660308838" FontWeight="Bold" ForeColor="#FF4F81BD" />
      </s:StyleDefinition.SpanStyle>
    </s:StyleDefinition>
    <s:StyleDefinition BasedOnName="Normal" DisplayName="Heading2" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading2Char" Name="Heading2" Type="Paragraph">
      <s:StyleDefinition.ParagraphStyle>
        <s:ParagraphProperties SpacingAfter="0" SpacingBefore="13.3333330154419" />
      </s:StyleDefinition.ParagraphStyle>
    </s:StyleDefinition>
    <s:StyleDefinition DisplayName="Heading2Char" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading2" Name="Heading2Char" Type="Character">
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties FontSize="17.3333339691162" FontWeight="Bold" ForeColor="#FF4F81BD" />
      </s:StyleDefinition.SpanStyle>
    </s:StyleDefinition>
    <s:StyleDefinition BasedOnName="Normal" DisplayName="Heading3" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading3Char" Name="Heading3" Type="Paragraph">
      <s:StyleDefinition.ParagraphStyle>
        <s:ParagraphProperties SpacingAfter="0" SpacingBefore="13.3333330154419" />
      </s:StyleDefinition.ParagraphStyle>
    </s:StyleDefinition>
    <s:StyleDefinition DisplayName="Heading3Char" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading3" Name="Heading3Char" Type="Character">
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties FontWeight="Bold" ForeColor="#FF4F81BD" />
      </s:StyleDefinition.SpanStyle>
    </s:StyleDefinition>
    <s:StyleDefinition BasedOnName="Normal" DisplayName="Heading4" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading4Char" Name="Heading4" Type="Paragraph">
      <s:StyleDefinition.ParagraphStyle>
        <s:ParagraphProperties SpacingAfter="0" SpacingBefore="13.3333330154419" />
      </s:StyleDefinition.ParagraphStyle>
    </s:StyleDefinition>
    <s:StyleDefinition DisplayName="Heading4Char" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading4" Name="Heading4Char" Type="Character">
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties FontStyle="Italic" FontWeight="Bold" ForeColor="#FF4F81BD" />
      </s:StyleDefinition.SpanStyle>
    </s:StyleDefinition>
    <s:StyleDefinition BasedOnName="Normal" DisplayName="Heading5" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading5Char" Name="Heading5" Type="Paragraph">
      <s:StyleDefinition.ParagraphStyle>
        <s:ParagraphProperties SpacingAfter="0" SpacingBefore="13.3333330154419" />
      </s:StyleDefinition.ParagraphStyle>
    </s:StyleDefinition>
    <s:StyleDefinition DisplayName="Heading5Char" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading5" Name="Heading5Char" Type="Character">
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties ForeColor="#FF4F81BD" />
      </s:StyleDefinition.SpanStyle>
    </s:StyleDefinition>
    <s:StyleDefinition BasedOnName="Normal" DisplayName="Heading6" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading6Char" Name="Heading6" Type="Paragraph">
      <s:StyleDefinition.ParagraphStyle>
        <s:ParagraphProperties SpacingAfter="0" SpacingBefore="13.3333330154419" />
      </s:StyleDefinition.ParagraphStyle>
    </s:StyleDefinition>
    <s:StyleDefinition DisplayName="Heading6Char" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading6" Name="Heading6Char" Type="Character">
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties FontStyle="Italic" ForeColor="#FF4F81BD" />
      </s:StyleDefinition.SpanStyle>
    </s:StyleDefinition>
    <s:StyleDefinition BasedOnName="Normal" DisplayName="Heading7" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading7Char" Name="Heading7" Type="Paragraph">
      <s:StyleDefinition.ParagraphStyle>
        <s:ParagraphProperties SpacingAfter="0" SpacingBefore="13.3333330154419" />
      </s:StyleDefinition.ParagraphStyle>
    </s:StyleDefinition>
    <s:StyleDefinition DisplayName="Heading7Char" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading7" Name="Heading7Char" Type="Character">
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties FontStyle="Italic" ForeColor="#FF000000" />
      </s:StyleDefinition.SpanStyle>
    </s:StyleDefinition>
    <s:StyleDefinition BasedOnName="Normal" DisplayName="Heading8" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading8Char" Name="Heading8" Type="Paragraph">
      <s:StyleDefinition.ParagraphStyle>
        <s:ParagraphProperties SpacingAfter="0" SpacingBefore="13.3333330154419" />
      </s:StyleDefinition.ParagraphStyle>
    </s:StyleDefinition>
    <s:StyleDefinition DisplayName="Heading8Char" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading8" Name="Heading8Char" Type="Character">
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties FontSize="13.3333330154419" ForeColor="#FF000000" />
      </s:StyleDefinition.SpanStyle>
    </s:StyleDefinition>
    <s:StyleDefinition BasedOnName="Normal" DisplayName="Heading9" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading9Char" Name="Heading9" Type="Paragraph">
      <s:StyleDefinition.ParagraphStyle>
        <s:ParagraphProperties SpacingAfter="0" SpacingBefore="13.3333330154419" />
      </s:StyleDefinition.ParagraphStyle>
    </s:StyleDefinition>
    <s:StyleDefinition DisplayName="Heading9Char" IsCustom="False" IsDefault="False" IsPrimary="True" LinkedStyleName="Heading9" Name="Heading9Char" Type="Character">
      <s:StyleDefinition.SpanStyle>
        <s:SpanProperties FontSize="13.3333330154419" FontStyle="Italic" ForeColor="#FF000000" />
      </s:StyleDefinition.SpanStyle>
    </s:StyleDefinition>
  </t:RadDocument.Styles>
  <t:Section>
    <t:Paragraph>
                <t:InlineUIContainer>
                    <t:RadDiagram Width="1000" Height="600">
                        <t:RadDiagramShape Geometry="{t:ArrowShape ShapeType=DoubleArrow4}" Position="100 100" />
                        <t:RadDiagramShape Geometry="{t:CommonShape ShapeType=TriangleShape}" Position="300 100" />
                    </t:RadDiagram>
                </t:InlineUIContainer>
            </t:Paragraph>
  </t:Section>
</t:RadDocument>
0
Petya
Telerik team
answered on 12 Feb 2013, 02:39 PM
Hello Edward,

The main purpose of InlineUIContainers is for representation purposes - i.e. to be able to insert a control in the document without serializing and deserializing it. XamlFormatProvider can handle the task of serialization and deserialization of smaller (simpler) controls like buttons, but  is not suited to be used with more complex controls like RadDiagram. This is due to the fact that such controls include a lot of public properties that are necessary for their successful serialization/deserialization.

We are considering providing XamlImportSettings in order to allow control over the import of InlineUIContainers, but this has not been scheduled yet. I am sorry for the inconvenience caused.

Let us know if there is anything else we can assist you with.
 
Greetings,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.


Posted on Jun 5, 2012 (permalink)

Hello Tyson,

The main purpose of InlineUIContainers is for representation only - i.e. to be able to insert custom controls in the document without serializing and deserializing them. XamlFormatProvider can handle the task of serialization and deserialization of smaller controls, but  is not suited to be used with more complex controls like RadRichTextBox or custom controls. This is due to the fact that such controls include a lot of public properties that are necessary for their successful deserialization and will be included in the output (the reason for the "hang" in your application).

We are considering providing XamlExportSettings in order to allow control over the export of InlineUIContainers. In that regard, could you provide some more details on your use-case and the reason why you are embedding RadRichTextBox in RadExpander in the document.

0
Edward
Top achievements
Rank 1
answered on 13 Feb 2013, 03:36 PM
So you mean, in theory I can embed a diagram into a document, but I cannot serialize it thus there is no way of saving it?
0
Petya
Telerik team
answered on 14 Feb 2013, 04:42 PM
Hi Edward,

Basically yes, until the settings I mentioned previously are exposed, there is no way to save a diagram hosted in InlineUIContainer within a RadDocument to XAML. This is not the main purpose of the containers in the first place, as RadRichTextBox targets to support rich-text editing scenarios and serializing and deserializing complex controls falls a bit out of that scope.

However, it is possible to handle the export of inline UI containers when exporting to HTML or PDF. If you wish to be able to import back the document, I would suggest to export to HTML and handle the InlineUIContainerExporting event, as PDF import is not possible in RadRichTextBox. Your other option is to export the containers to PDF as images. Both of those are explained in the article I previously referenced here.

I hope this helps!
 
All the best,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Diagram
Asked by
Edward
Top achievements
Rank 1
Answers by
Petya
Telerik team
Edward
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or