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

DrawTextTool Default Font Size

7 Answers 145 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Nisarg
Top achievements
Rank 1
Nisarg asked on 25 Sep 2015, 07:02 AM

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

Sort by
0
Tanya
Telerik team
answered on 29 Sep 2015, 02:52 PM
Hi Nisarg,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Nisarg
Top achievements
Rank 1
answered on 30 Sep 2015, 11:40 AM

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

 

0
Tanya
Telerik team
answered on 02 Oct 2015, 04:07 PM
Hi Nisarg,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Nisarg
Top achievements
Rank 1
answered on 08 Oct 2015, 05:25 AM

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

 

 

0
Todor
Telerik team
answered on 12 Oct 2015, 08:54 AM
Hello Nisarg,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
mark gamache
Top achievements
Rank 1
answered on 19 May 2018, 02:34 PM
I was able to get the sample code working, but I don't see a way of changing the drawn text font or weight. The"FontWeight" property sets the weight of the editor UI not the text drawn on the image. 
0
Martin Ivanov
Telerik team
answered on 21 May 2018, 12:01 PM
Hello Mark,

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
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ImageEditor
Asked by
Nisarg
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Nisarg
Top achievements
Rank 1
Todor
Telerik team
mark gamache
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or