2017-01-06 10 views
0

Моя проблема в том, когда я указал курсором на картинке, это supertooltip с изображением. Но изображение внутри supertooltip слишком велико. Как изменить размер программного обеспечения.Как свернуть или изменить размер изображения на supertooltip at pictureedit

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

Когда я указал курсор на изображение (второе изображение)

Second Image

ответ

0

Я хотел бы предложить изменение размера изображения перед назначением его на SuperToolTip. Я подробно расскажу, как это сделать в своем блоге 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; 
} 

Это делается в GetActiveObjectInfo обработчик события ToolTipController в:

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; 
}