Custom tool configuration

3 posts, 1 answers
  1. Marcin
    Marcin avatar
    165 posts
    Member since:
    Jan 2011

    Posted 26 Apr 2013 Link to this post

    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. Marcin
    Marcin avatar
    165 posts
    Member since:
    Jan 2011

    Posted 29 Apr 2013 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Petya
    Admin
    Petya avatar
    975 posts

    Posted 01 May 2013 Link to this post

    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.

Back to Top