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

How to access Richtextbox Symbols Unicode...

1 Answer 216 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Madhusudhan
Top achievements
Rank 1
Madhusudhan asked on 22 Jun 2012, 08:12 AM

Hi brilliants,
Silverlight RadInsertSymbolDialog
(RichtextBOX editor ,in that when we clicked "Insert Symbol" this window is opening)

We are using this dialog to select symbols. We can get the Symbol and Font Family from the call back. But we also need the Unicode HTML equivalent number from the dialog. The Dialog shows the number (For example, for "W", it shows U+87: Uppercase letter) while we select/mouse over the symbol.

But we need to know how to access this number for some modification.(in this example, we need to get the value "U+87")

I need this informations,if anyone aware of it please reply to it ...its better with clear code details.

Thanks,
Madhu

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 26 Jun 2012, 09:34 AM
Hello Madhu,

The text that is shown in the InsertSymbolDialog at the position marked in the screenshot is calculated in the following way:
private string GetDescription(char c)
{
    Dictionary<UnicodeCategory, string> unicodeCategoryNames = new Dictionary<UnicodeCategory, string>();
 
    foreach (UnicodeCategory category in this.GetValues(typeof(UnicodeCategory)))
    {
        unicodeCategoryNames.Add(category, LocalizationManager.GetString("Documents_InsertSymbolDialog_UnicodeCategory_" + category.ToString()));
    }
    return string.Format("U+{0}: {1}", (int)c, unicodeCategoryNames[char.GetUnicodeCategory(c)]);
}
 
internal IEnumerable GetValues(Type enumType)
{
    if (enumType == null)
    {
        throw new ArgumentNullException("enumType");
    }
 
    if (!enumType.IsEnum)
    {
        throw new ArgumentException("Argument must be Enum", "enumType");
    }
 
    var fields = from field in enumType.GetFields()
                 where field.IsLiteral
                 select field;
 
    foreach (FieldInfo field in fields)
    {
        yield return field.GetValue(enumType);
    }
}

As you can see, the "Uppercase Letter" text comes from the localization resources. You can find more about localization of RadRichTextBox - mechanisms, localization keys, etc in this article.

If the customization you can do through localization is not sufficient, you can create your own implementation of this window. This is done by implementing the IInsertSymbolWindow interface and marking your user control with the [CustomInsertSymbolWindow] attribute.

Greetings,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox
Asked by
Madhusudhan
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or