2017-01-06 2 views
0

私の問題は、画像内にカーソルがある場合は、画像がsupertooltipであることです。しかし、supertooltip内の画像が大きすぎます。プログラムでサイズを変更する方法supertooltipで画像を最小化またはサイズ変更する方法

Public com As New MySql.Data.MySqlClient.MySqlCommand 
Public da As New MySql.Data.MySqlClient.MySqlDataAdapter 
Public dr As MySql.Data.MySqlClient.MySqlDataReader 
Public ds As DataSet 

Dim confirm As String 

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 
    con.Close() 
    con.Open() 
    confirm = "select PPhoto From user_tbl" 
    dr = com.ExecuteReader 

    While dr.Read 
    BarEditItem10.EditValue = Image.FromFile(pathfrm.PathPhoto.Text & dr.GetString("PPhoto")) 
    Dim resImage As Image = Image.FromFile(pathfrm.PathPhoto.Text & dr.GetString("PPhoto")) 
    Dim sTooltip2 As SuperToolTip = New SuperToolTip 
    ' Create an object to initialize the SuperToolTip. 
    Dim args As SuperToolTipSetupArgs = New SuperToolTipSetupArgs 
    args.Title.Text = "Profile Picture" 
    args.Contents.Text = "This is a Profile Picture" 
    args.Contents.Image = resImage 
    sTooltip2.Setup(args) 
    BarEditItem10.SuperTip = sTooltip2 
    End While 
    con.Close() 
End sub 

First Image

私は私があなたのSuperToolTipに割り当てる前にリサイズ画像を示唆している画像にカーソル(第二の画像)

Second Image

答えて

0

を指摘するとき。私はPreviewing Images in a SuperToolTipのブログ記事でこれを行う方法を詳しく説明します。

基本的に私はちょうど画像再サイズに静的なヘルパークラスを使用します。

static internal Image ScaleThumbnailImage(Image ImageToScale, int MaxWidth, int MaxHeight) 
{ 
    double ratioX = (double)MaxWidth/ImageToScale.Width; 
    double ratioY = (double)MaxHeight/ImageToScale.Height; 
    double ratio = Math.Min(ratioX, ratioY); 

    int newWidth = (int)(ImageToScale.Width * ratio); 
    int newHeight = (int)(ImageToScale.Height * ratio); 

    Image newImage = new Bitmap(newWidth, newHeight); 
    Graphics.FromImage(newImage).DrawImage(ImageToScale, 0, 0, newWidth, newHeight); 

    return newImage; 
} 

はこれがToolTipControllerのGetActiveObjectInfoイベントハンドラ内で行われます:

private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e) 
{ 

Image MyImage = Image.FromFile("C:\\your_file_here.jpg"); 

ToolTipControlInfo toolTipInfo = null; 
SuperToolTip toolTip = new SuperToolTip(); 

toolTipInfo = new ToolTipControlInfo(Guid.NewGuid(), "My Image"); 
ToolTipItem item1 = new ToolTipItem(); 

item1.Image = ScaleThumbnailImage(MyImage, 640, 480); 

toolTip.Items.Add(item1); 

toolTipInfo.SuperTip = toolTip; 
e.Info = toolTipInfo; 
} 
関連する問題