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

Custom tool configuration

2 Answers 71 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Marcin
Top achievements
Rank 1
Veteran
Marcin asked on 26 Apr 2013, 01:39 PM
Hello,
I've started creating custom tool based on resize tool, however I'd like to have:
a) press button -> tool is runnig and changes are applied to image
b) no tool settings window is displayed.

Currently tool settings window with reset button is diplaying (I do not need that)
And Tool is not commiting itself. I would like to automatically commit changes similar to flip or rotate.

2 Answers, 1 is accepted

Sort by
0
Marcin
Top achievements
Rank 1
Veteran
answered on 29 Apr 2013, 01:22 PM
I finally managed to create tool that will suite my needs however I'm missing few generic features:
a) easier way to create custom command - currently I had to create custom command then create routed command that would be bindable to newly created command and from rounted command executeCommand on image editor. It would be good to have a way to avoid such workaround and bind imageeditor command directly to image editor.
b) Custom tools are nice, and powerfull but:
  - there is no way to hide tool after commit - I have to run cancel after apply to finish tool edition. It would be good to have option to set that apply changes finishes edition.
  - There is no way to notify (at least I didn't find any) to let know user that tool action was taken or custom command was run. CommandExecuted event is not running after custom exection. I think this is by design but it would be good to have information tha image was changed/ammended.
c) From custom tool I do not have access to scroll position, so I do not know where to show the tool. I would like to show it on visible part of image, but I don't know how to get this info.

Then using this editor will be easier.
0
Accepted
Petya
Telerik team
answered on 01 May 2013, 02:49 PM
Hello Marcin,

I am not sure what is the exact approach you used to create a custom tool, but this is a fairly easy task and there is an example that might be helpful in our SDK. Creating a custom command in particular is as simple as deriving from IImageCommand.

Regarding your other concerns:
  • RadImageEditor has a CommitTool () method which can be invoked with executeSameToolAfterCommit parameter set to false. This will apply the current tool and hide the tool settings (if such). So, basically, if there is an Apply button in your application, you can call this line in it:
    this.imageEditor.ImageEditor.CommitTool(false);
    and it will behave exactly as you want it to.
  • When executing a tool the ExecuteToolCommand is executed with a CommandParameter the respective tool. If you download the example I previously referenced and add the following in its CommandExecuted event handler, you can verify it is raised when the tool is invoked through the command.
    void ImageEditor_CommandExecuted(object sender, Telerik.Windows.Media.Imaging.ImageEditorCommands.ImageCommandExecutedEventArgs e)
    {
        if (e.Command is ExecuteToolCommand && e.CommandParameter is WatermarkTool )
        {
            //watermark command is executed
        }
    }

As for how to determine that the image has been changed, the easiest way to do that is by subscribing to the CurrentImageChanged event like this:
this.imageEditor.ImageEditor.History.CurrentImageChanged += History_CurrentImageChanged;

I hope the provided information helps! Let us know if you have other questions or comments.

Kind regards,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ImageEditor
Asked by
Marcin
Top achievements
Rank 1
Veteran
Answers by
Marcin
Top achievements
Rank 1
Veteran
Petya
Telerik team
Share this question
or