Hi,
How can I set default font size to 20 instead of 36 for DrawTextTool of RadImageEditor.
Please see attached image.
Thanks
7 Answers, 1 is accepted
There is no an out-of-the-box way to change the default settings of the DrawTextTool and we have logged a task to expose an API, which will allow setting them easily. You could track our progress on it following the related public item.
To achieve the goal, you could inherit the default tool and implement a custom one, which overrides the ResetSetting() method to return the desired value for the FontSize property:
public
class
CustomDrawTextTool : DrawTextTool
{
private
DrawTextToolSettings SettingsUI
{
get
{
return
(DrawTextToolSettings)
this
.GetSettingsUI();
}
}
public
override
void
ResetSettings()
{
base
.ResetSettings();
this
.SettingsUI.TextFontSize = 20;
}
}
More information about creating a custom tool you could find in our documentation.
Regards,
Tanya
Telerik
Hi Tanya,
I have tried above code by crating CustomDrawTextTool but it gives me error when I rebuild project.
ResetSettings() method is not virtual, abstract, or override type.
Error : CustomDrawTextTool.ResetSettings()': cannot override inherited member 'Telerik.Windows.Media.Imaging.Tools.DrawTextTool.ResetSettings()'
because it is not marked virtual, abstract, or override.
Thanks
The ResetSettings() method and the DrawTextTool class are marked as public and the signature of the method is as follows:
public
override
void
ResetSettings()
Thus, you should be able to override the method in the CustomDrawTextTool class. I wasn't able to reproduce a similar issue in the test application and cannot say what may cause it. Please find attached my test project and let me know if I am missing something.
Regards,
Tanya
Telerik
Hi Tanya,
Thanks for the reply.
As you mentioned above, public override void ResetSettings() but when I checked it, this is not Override method and I am not able to build "ImageEditorCustomToolDemo" project due to this method.
Please see attached file of telerik DrawTextTool class.
Thanks
Since our Q1 2015 release, we introduced the abstract ToolBase class which implements the ITool interface and is inherited by all built-in RadImageEditor tools. The reason you are not able to override the ResetSettings() method is that the binaries you are using are older than the above-mentioned version. Tanya suggested you that approach because the version in the thread info is from our Q2 release - 2015.2.728.
You could implement the ITool interface and implement your own DrawText tool, or you could upgrade to a version where the ToolBase class exists and use the suggest approach by Tanya.
I hope this helps.
If you need further assistance, please get back to us again.
Regards,
Todor
Telerik
Currently, the text drawing tool doesn't allow setting the FontWeight of the drawn text. However, I logged a feature request for implementing this and I updated your Telerik points.
To achieve your requirement you can create a custom draw text command where you can manually add the text to the image and return it in the GetCommand() override of the custom text drawing tool. I updated Tanya's project to show this approach. I hope that helps.
Regards,
Martin Ivanov
Progress Telerik