Using the built in OpenImageCommand functionality of telerik:RadImageEditorUI, you can detect the OpenImageCommand has been executed via the CommandExecuted event.
However there is no way to determine whether an image was loaded or not.
The Dialog Result is silently consumed by the OpenImageCommand class so if the user clicks the cancel button on the open file dialogue you have no way of knowing.
It would be good to have a means to determine the dialog result, either via a property on the command, by an additional property in the CommandExecuted event args, or even an event that is raised when an image is loaded or the dialog is cancelled.
To achieve this functionality I had to implement code like the following:
public bool IsNewImage { get; set; }
private void ImageEditor_CommandExecuting(object sender, ImageCommandExecutingEventArgs e)
{
if (e.Command is OpenImageCommand)
{
IsNewImage = false;
}
}
private void HistoryOnCurrentImageChanged(object sender, EventArgs e)
{
var history = (ImageHistory)sender;
IsNewImage = (!history.CanRedo && !history.CanUndo);
}
private void ImageEditor_CommandExecuted(object sender, ImageCommandExecutedEventArgs e)
{
if (e.Command is OpenImageCommand)
{
if (IsNewImage)
{
// Deal with new image...
}
}
}
It'd be so much easier to have the following:
private void ImageEditor_CommandExecuted(object sender, ImageCommandExecutedEventArgs e)
{
if (e.Command is OpenImageCommand)
{
if (!e.CommandCancelled)
{
// Deal with new image...
}
}
}
Thanks 👍