RadOffice2007ScreenTipElement - Image resize

6 posts, 0 answers
  1. Den Duze
    Den Duze avatar
    18 posts
    Member since:
    Nov 2014

    Posted 17 Jan 2017 Link to this post

    Hi,

    I use the RadOffice2007ScreenTipElement to display some tooltip (with image) on a RadGridView column.
    The original image is much to large to display in this tooltip.
    Is there some way to (automatically) resize the image to the defined size of the tooltip (done with new System.Drawing.Size(200, 150))

    Thanks
    Didier

  2. Hristo
    Admin
    Hristo avatar
    1522 posts

    Posted 17 Jan 2017 Link to this post

    Hi Didier,

    Thank you for writing.

    You can access the ImagePrimitive responsible for displaying it and set the ScaleSize property to a desired size. Please also note, that ScaleSize property assumes that you have the ImageScaling set to SizeToFit:
    RadOffice2007ScreenTipElement screenTip = new RadOffice2007ScreenTipElement();
    private void btn_ScreenTipNeeded(object sender, Telerik.WinControls.ScreenTipNeededEventArgs e)
    {
        RadButtonElement btn = e.Item as RadButtonElement;
        if (btn != null)
        {
            screenTip.MainTextLabel.Image = Image.FromFile(@"..\..\location.png");
            screenTip.MainTextLabel.Padding = new Padding(2);
            screenTip.CaptionLabel.Padding = new Padding(2);
            screenTip.CaptionLabel.Text = "Caption";
            screenTip.MainTextLabel.Text = "Label";
            screenTip.MainTextLabel.ImageAlignment = ContentAlignment.MiddleLeft;
            screenTip.MainTextLabel.TextImageRelation = TextImageRelation.ImageBeforeText;
            screenTip.MainTextLabel.LabelImage.ImageScaling = Telerik.WinControls.Enumerations.ImageScaling.SizeToFit;
            screenTip.MainTextLabel.LabelImage.ScaleSize = new Size(25, 25);
            screenTip.EnableCustomSize = true;
            btn.ScreenTip = this.screenTip;  
        }
    }
     
    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Den Duze
    Den Duze avatar
    18 posts
    Member since:
    Nov 2014

    Posted 17 Jan 2017 in reply to Hristo Link to this post

    Hi Hristo,

    This works fine BUT after trying this I notice that the Aspect ratio of the image could be changed.
    So now I want that the new Size will be <the size of the displayed image in the Telerik.WinControls.UI.GridDataCellElement> multiplied with <some value>.
    This way I will always keep the correct Aspect Ratio of the image shown in that row of the RadGridView (I think)

    So the image on disk can have the size 4752, 3168
    But it will be rendered in the RadGridView  much smaller (I use gridViewImageColumn1:ImageLayout = System.Windows.Forms.ImageLayout:Zoom.).
    So how can I get the size of the image that is shown in the RadGridView-column??
    Or can't that be done?

    Regards
    Didier

  4. Hristo
    Admin
    Hristo avatar
    1522 posts

    Posted 18 Jan 2017 Link to this post

    Hello Didier,

    Thank you for writing back.

    Setting the ImageLayout to Zoom will not change the aspect ratio so knowing the original resolution you can calculate it. The height of the displayed image depends on the height of the row where it is located. So knowing the height and the initial aspect ratio you can size the images displayed in the tooltip.

    I hope this helps. Please let me know if you need further assistance.
    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Den Duze
    Den Duze avatar
    18 posts
    Member since:
    Nov 2014

    Posted 18 Jan 2017 in reply to Hristo Link to this post

    So this means there is no way of retrieving the height and width of the image that is displayed in a RadGridView-column?
  6. Hristo
    Admin
    Hristo avatar
    1522 posts

    Posted 18 Jan 2017 Link to this post

    Hi Didier,

    Thank you for writing back.

    The actual size of the image does not change. It is simply painted to zoom and fit the available space. 
    You cannot directly receive the displayed width and height of the image and you will need to calculate it according to the ratio.

    I hope this helps. Please let me know if you need further assistance.

    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top