Unplanned
Last Updated: 05 Apr 2021 11:07 by ADMIN
Richard
Created on: 29 Mar 2021 17:00
Category: ImageEditor
Type: Feature Request
0
No way to determine Dialog result of OpenImageCommand

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 👍

 

 

1 comment
ADMIN
Martin Ivanov
Posted on: 05 Apr 2021 11:07

Hello Richard,

Thank you for the report. We've approved the request.

An alternative solution that you can consider is to implement a custom OpenImageCommand and override its ExecuteOverride(). There you can implement the image opening logic and access the dialog result. I've attached a small example showing this approach. I hope it helps.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Attached Files: