How to overwrite save command

5 posts, 1 answers
  1. Somnath
    Somnath avatar
    3 posts
    Member since:
    Dec 2011

    Posted 06 Aug 2013 Link to this post

    Hi,

    I am using ImageEditor from the example, I want to get the final edited image in a stream or writable bitmap format, I don't want to save the image in the picture hub.

    How do I archive that.

  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 08 Aug 2013 Link to this post

    Hello Somnath,

    Thank you for your question.

    Here's how you can get the final edited image in the Execute method of your command:

    RadImageEditor currentEditor = (Application.Current as Application).RootVisual.FindChildByType<RadImageEditor>();
    if (currentEditor.CurrentTool != null)
    {
        return;
    }
     
    WriteableBitmap wb = (WriteableBitmap)currentEditor.ModifiedImage;

    First we check if the CurrentEditor is null. This is necessary because when it is not null, it means that the command is executed in order to apply modifications from a single tool and when it is null then it is time for it to be saved. The command will allow you to execute your custom logic, in order to skip the default saving logic, you also need to use the cancelable event ImageSaving and set e.Cancel to true.

    Let me know if you need further assistance here.
     
    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  3. DevCraft banner
  4. Somnath
    Somnath avatar
    3 posts
    Member since:
    Dec 2011

    Posted 08 Aug 2013 Link to this post

    Thank you very much,
    But I am not able to make it run, my be cause I have not writtten the code properly. I saw few example to overwrite the save button using custom class MySaveCommad.cs where it inherit ImageEditorCommandBase. But for Windows Phone i don't see the base class ImageEditorCommandBase.

    Could you please write some more code that I should add in the xaml and in my cs file. I don't want to save the edited image rather I want to get the image data in WritableBitmap for further process.


    Thanks
    Somnath
  5. Answer
    Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 13 Aug 2013 Link to this post

    Hello Somnath,

    Thanks for writing back.

    You can simply handle the ImageSaving event, cancel the default saving routine and obtain the edited image as a writeable bitmap as shown below:

    void imageEditor_ImageSaving(object sender, ImageSavingEventArgs e)
    {
        e.Cancel = true;
     
        WriteableBitmap bitmap = this.imageEditor.ModifiedImage as WriteableBitmap;
    }

    Hope this helps.

    Regards,
    Deyan
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  6. Somnath
    Somnath avatar
    3 posts
    Member since:
    Dec 2011

    Posted 13 Aug 2013 Link to this post

    Thanks. This is exactly what I was looking for . Perfect.
Back to Top
DevCraft banner