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

RadOffice2007ScreenTipElement - Image resize

5 Answers 119 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Den Duze
Top achievements
Rank 1
Den Duze asked on 17 Jan 2017, 10:04 AM

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

5 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 17 Jan 2017, 03:42 PM
Hi Didier,

Thank you for writing.

You can access the ImagePrimitive responsible for displaying it and set the ScaleSize property to 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.
0
Den Duze
Top achievements
Rank 1
answered on 17 Jan 2017, 08:33 PM

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

0
Hristo
Telerik team
answered on 18 Jan 2017, 01:06 PM
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.
0
Den Duze
Top achievements
Rank 1
answered on 18 Jan 2017, 01:21 PM
So this means there is no way of retrieving the height and width of the image that is displayed in a RadGridView-column?
0
Hristo
Telerik team
answered on 18 Jan 2017, 01:47 PM
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.
Tags
General Discussions
Asked by
Den Duze
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Den Duze
Top achievements
Rank 1
Share this question
or