Completed
Last Updated: 11 Apr 2019 08:52 by Dimitar
Release R2 2019 (LIB 2019.1.415)
Mihajlo
Created on: 28 Feb 2019 16:13
Category: ImageEditor
Type: Bug Report
1
RadImageEditor: Automatic zoom works only when "Auto" is typed in, and even then zoom is not updated on resize

When I select Auto option in zoom drop-down list the image will not be resized to fit available space. The only way to auto-fit the image is to type "Auto" in drop-down list. Also, when editor form is resized while "Auto" option is selected the zoom will not be updated.

Additional methods OnResize and DropDownList_SelectedIndexChanged are required to update the zoom, because in DropDownList_TextChanged event handler this.dropDownList.SelectedIndex is always set to -1 when any option is selected with mouse, and will be different from -1 only when a text matching an option is entered with keyboard.

2 comments
Dimitar
Posted on: 11 Apr 2019 08:52
Hello, 
 
A Fix will be available in LIB Version 2019.1.415 scheduled for April 15th.

Regards,
Dimitar
ADMIN
Hristo
Posted on: 01 Mar 2019 13:28
Hi Mihajlo,

Indeed the reported behavior can be considered an issue and I have updated your Telerik points. A possible workaround is to handle the SelectedIndexChanged event of the zoom element and Resize event of the control and to update the zoom factor: 
public partial class RadForm1 : Telerik.WinControls.UI.RadForm
{
    public RadForm1()
    {
        InitializeComponent();
 
        this.radImageEditor1.LoadAsync(@"..\..\test-image.png");
        this.radImageEditor1.Resize += this.RadImageEditor1_Resize;
        this.radImageEditor1.ImageEditorElement.ZoomElement.DropDownList.SelectedIndexChanged += this.DropDownList_SelectedIndexChanged;
    }
 
    private void RadImageEditor1_Resize(object sender, EventArgs e)
    {
        if (this.radImageEditor1.ImageEditorElement.ZoomElement.DropDownList.SelectedIndex == 0)
        {
            this.UpdateAutoZoom();
        }
    }
 
    private void DropDownList_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
    {
        if (this.radImageEditor1.ImageEditorElement.ZoomElement.DropDownList.SelectedIndex == 0)
        {
            this.UpdateAutoZoom();
        }
    }
 
    private void UpdateAutoZoom()
    {
        float factorX = (float)(this.radImageEditor1.ImageEditorElement.Size.Width - this.radImageEditor1.ImageEditorElement.CommandsElementWidth) / (float)this.radImageEditor1.ImageEditorElement.CurrentBitmap.Width;
        float factorY = (float)(this.radImageEditor1.ImageEditorElement.Size.Height - this.radImageEditor1.ImageEditorElement.ZoomElementHeight) / (float)this.radImageEditor1.ImageEditorElement.CurrentBitmap.Height;
        float factor = Math.Min(factorX, factorY);
 
        this.radImageEditor1.ImageEditorElement.ZoomFactor = new SizeF(factor, factor);
    }
}


Regards,
Hristo
Progress TelerikRadImageEditor for Winforms