Imports System.Windows.Forms
Public Class NewDrawingDialog
Private _BgImage As Image
Public Property BgImage() As Image
Get
Return _BgImage
End Get
Set(ByVal Value As Image)
_BgImage = Value
End Set
End Property
Public ReadOnly Property DrawingName() As String
Get
Return txtName.Text
End Get
End Property
Public ReadOnly Property Center() As Boolean
Get
Return chbCenter.Checked
End Get
End Property
Public ReadOnly Property Zoom() As Single
Get
Return nudZoom.Value
End Get
End Property
Public ReadOnly Property Alpha() As Byte
Get
Return trkAlpha.Value
End Get
End Property
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
If _BgImage Is Nothing Then
MessageBox.Show("Scegliere un'immagine di sfondo prima di continuare!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub
Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
Private Sub imgPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imgPreview.Click
Dim Open As New OpenFileDialog
Open.Filter = "File immagine|*.jpg;*.png;*.bmp;*.gif"
If Open.ShowDialog = Windows.Forms.DialogResult.OK Then
_BgImage = Image.FromFile(Open.FileName)
imgPreview.Refresh()
End If
End Sub
Private Sub imgPreview_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles imgPreview.Paint
If Me.BgImage IsNot Nothing Then
Dim M As New Imaging.ColorMatrix
Dim A As New Imaging.ImageAttributes
Dim R As New Rectangle(0, 0, imgPreview.Width, imgPreview.Height)
M.Matrix00 = 1
M.Matrix11 = 1
M.Matrix22 = 1
M.Matrix33 = trkAlpha.Value / 255
M.Matrix44 = 1
A.SetColorMatrix(M)
e.Graphics.DrawImage(Me.BgImage, R, 0, 0, Me.BgImage.Width, Me.BgImage.Height, GraphicsUnit.Pixel, A)
End If
End Sub
Private Sub trkAlpha_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trkAlpha.Scroll
imgPreview.Refresh()
End Sub
End Class