Skip to content

Commit 482ebea

Browse files
Merge pull request #1610 from syncfusion-content/925962-updateImageEditordocument
925962 - Update Text Settings content in Image Editor UG document.
2 parents 40fc0c9 + a129f5f commit 482ebea

File tree

2 files changed

+51
-23
lines changed

2 files changed

+51
-23
lines changed
Loading

wpf/Image-Editor/Text.md

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ You can annotate an image by adding the desired text to it. This can be done in
1818

1919
To add text, click the Text icon (T) in the toolbar. Now, the text will be added at the center of the image along with the selection handle, which helps in resizing. By default, the added text will be in pan mode, so you can position the text anywhere by dragging it. By clicking the text, it will change into typing mode, and you can edit the text directly. Click outside to exit from typing mode.
2020

21+
![Text-settings-toolbar-in-WPF-ImageEditor](Images/text-setting-toolbar-in-wpf-image-editor.gif)
22+
2123
## Customization
2224

2325
The following properties of the added text can be customized:
2426

27+
* Background
2528
* Font family
2629
* Font size
2730
* Font color
@@ -32,6 +35,10 @@ Upon selecting the Text icon in the toolbar, a sub toolbar will be generated bel
3235

3336
>N Text needs to be selected to apply the customization from the sub toolbar.
3437
38+
### Background
39+
40+
You can customize the text background color by clicking on the fill icon, choosing a color from the color picker, and applying it to the background.
41+
3542
### Font family
3643

3744
Font family icon lists out the predefined system font families. You can select the required font family.
@@ -52,7 +59,6 @@ You can make the text bold, italic, or underline by clicking the corresponding i
5259

5360
Text can be aligned to the left, center, or right by clicking the corresponding icon. By default, text will be aligned at the left.
5461

55-
5662
## Adding text programmatically
5763

5864
You can add text to an image using the AddText method programmatically. This method requires the following parameters:
@@ -61,19 +67,30 @@ You can add text to an image using the AddText method programmatically. This met
6167
* TextSettings - Customizes the text.
6268

6369
{% tabs %}
70+
{% highlight XAML %}
6471

65-
{% highlight C# %}
66-
67-
editor.AddText("Hello", new TextSettings());
72+
<editor:SfImageEditor x:Name="editor"
73+
Loaded="OnImageEditorLoaded">
74+
</editor:SfImageEditor>
6875

6976
{% endhighlight %}
77+
{% highlight C# hl_lines="5" %}
78+
79+
this.editor.Loaded += this.OnImageEditorLoaded;
80+
81+
private void OnImageEditorLoaded(object sender, RoutedEventArgs e)
82+
{
83+
this.editor.AddText("Hello", new TextSettings());
84+
}
7085

86+
{% endhighlight %}
7187
{% endtabs %}
7288

7389
## Text settings
7490

7591
Using the following properties in TextSettings, text can be customized.
7692

93+
* [`Background`](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.ImageEditor.TextSettings.html#Syncfusion_UI_Xaml_ImageEditor_TextSettings_Background) - Specifies the background color of the text annotation. The default value is `Brush.Transparent.`
7794
* [`FontFamily`](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.ImageEditor.TextSettings.html#Syncfusion_UI_Xaml_ImageEditor_TextSettings_FontFamily) - Changes the font family of the text.
7895
* [`FontSize`](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.ImageEditor.TextSettings.html#Syncfusion_UI_Xaml_ImageEditor_TextSettings_FontSize) - Changes the font size of the text.
7996
* [`Color`](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.ImageEditor.TextSettings.html#Syncfusion_UI_Xaml_ImageEditor_TextSettings_Color) - Modifies the font color of the text.
@@ -86,29 +103,40 @@ Using the following properties in TextSettings, text can be customized.
86103
>N Values of bounds will be in percentage. For example (25, 25, 25, 25) will take the position of 25 percent from the left and top.
87104
88105
{% tabs %}
106+
{% highlight XAML %}
89107

90-
{% highlight C# %}
91-
92-
TextSettings textSettings = new TextSettings();
93-
textSettings.FontFamily = new FontFamily("Century Schoolbook");
94-
textSettings.FontSize = 30;
95-
textSettings.Color = new SolidColorBrush(Colors.Red);
96-
textSettings.TextEffects = TextEffects.Bold | TextEffects.Italic;
97-
textSettings.Bounds = new Rect(50, 10, 50, 15);
98-
editor.AddText("Good morning", textSettings);
99-
100-
textSettings = new TextSettings();
101-
textSettings.FontFamily = new FontFamily("Bell MT");
102-
textSettings.FontSize = 22;
103-
textSettings.Color = new SolidColorBrush(Colors.DarkGreen);
104-
textSettings.TextEffects = TextEffects.Italic;
105-
textSettings.Bounds = new Rect(50, 23, 30, 15);
106-
textSettings.TextAlignment = TextAlignment.Center;
107-
editor.AddText("The happiness of your \nlife depend upon the \nquality of your thoughts.", textSettings);
108-
108+
<editor:SfImageEditor x:Name="editor"
109+
Loaded="OnImageEditorLoaded">
110+
</editor:SfImageEditor>
109111

110112
{% endhighlight %}
113+
{% highlight C# %}
114+
115+
this.editor.Loaded += this.OnImageEditorLoaded;
116+
117+
private void OnImageEditorLoaded(object sender, RoutedEventArgs e)
118+
{
119+
TextSettings textSettings = new TextSettings();
120+
textSettings.Background = new SolidColorBrush(Colors.Yellow);
121+
textSettings.FontFamily = new FontFamily("Century Schoolbook");
122+
textSettings.FontSize = 30;
123+
textSettings.Color = new SolidColorBrush(Colors.Red);
124+
textSettings.TextEffects = TextEffects.Bold | TextEffects.Italic;
125+
textSettings.Bounds = new Rect(50, 10, 50, 15);
126+
this.editor.AddText("Good morning", textSettings);
127+
128+
textSettings = new TextSettings();
129+
textSettings.Background = new SolidColorBrush(Colors.Ivory);
130+
textSettings.FontFamily = new FontFamily("Bell MT");
131+
textSettings.FontSize = 22;
132+
textSettings.Color = new SolidColorBrush(Colors.DarkGreen);
133+
textSettings.TextEffects = TextEffects.Italic;
134+
textSettings.Bounds = new Rect(50, 23, 30, 15);
135+
textSettings.TextAlignment = TextAlignment.Center;
136+
this.editor.AddText("The happiness of your \nlife depend upon the \nquality of your thoughts.", textSettings);
137+
}
111138

139+
{% endhighlight %}
112140
{% endtabs %}
113141

114142
![Text](Images/Text.jpg)

0 commit comments

Comments
 (0)