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

Event when image is loaded

1 Answer 463 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
MNP
Top achievements
Rank 1
MNP asked on 11 Aug 2011, 03:08 PM
I'm trying to automatically select the crop tool when an image is loaded. All is ok if I preload the image, but if I allow the user to select the image, I can't seem to find the event that is called after I load up the image to load the tool.

It's probably right in front of me.

Thanks

-Matt

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 15 Aug 2011, 02:49 PM
Hello Matt,

Thank you for this feature suggestion. We will be introducing more convenient events in the upcoming service pack, which will enable you to track when a command is executed, be it the OpenImageCommand or any other. 
With the current version of the controls, you can find out when a new image has been loaded in the control by subscribing to the CurrentImageChanged event of the History property in the following way:

this.ImageEditorUI.ImageEditor.History.CurrentImageChanged += History_CurrentImageChanged;
Then, you have to check if you can undo/redo, because the CurrentImageChanged is also fired when you commit a command, e.g. you crop the picture or change its size.
Here is a sample code-snippet that determines if a new image has been loaded in the control:
void History_CurrentImageChanged(object sender, EventArgs e)
{
    ImageHistory history = (ImageHistory)sender;
    if (!history.CanRedo && !history.CanUndo)
    {
        MessageBox.Show("Image changed!");
    }
}
Best wishes,
Iva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
ImageEditor
Asked by
MNP
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or