Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Curve Art - NewDrawingDialog.vb

NewDrawingDialog.vb

Caricato da: Totem
Scarica il programma completo

  1. Imports System.Windows.Forms
  2.  
  3. Public Class NewDrawingDialog
  4.     Private _BgImage As Image
  5.  
  6.     Public Property BgImage() As Image
  7.         Get
  8.             Return _BgImage
  9.         End Get
  10.         Set(ByVal Value As Image)
  11.             _BgImage = Value
  12.         End Set
  13.     End Property
  14.  
  15.     Public ReadOnly Property DrawingName() As String
  16.         Get
  17.             Return txtName.Text
  18.         End Get
  19.     End Property
  20.  
  21.     Public ReadOnly Property Center() As Boolean
  22.         Get
  23.             Return chbCenter.Checked
  24.         End Get
  25.     End Property
  26.  
  27.     Public ReadOnly Property Zoom() As Single
  28.         Get
  29.             Return nudZoom.Value
  30.         End Get
  31.     End Property
  32.  
  33.     Public ReadOnly Property Alpha() As Byte
  34.         Get
  35.             Return trkAlpha.Value
  36.         End Get
  37.     End Property
  38.  
  39.     Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
  40.         If _BgImage Is Nothing Then
  41.             MessageBox.Show("Scegliere un'immagine di sfondo prima di continuare!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  42.             Exit Sub
  43.         End If
  44.         Me.DialogResult = System.Windows.Forms.DialogResult.OK
  45.         Me.Close()
  46.     End Sub
  47.  
  48.     Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
  49.         Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
  50.         Me.Close()
  51.     End Sub
  52.  
  53.     Private Sub imgPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imgPreview.Click
  54.         Dim Open As New OpenFileDialog
  55.         Open.Filter = "File immagine|*.jpg;*.png;*.bmp;*.gif"
  56.         If Open.ShowDialog = Windows.Forms.DialogResult.OK Then
  57.             _BgImage = Image.FromFile(Open.FileName)
  58.             imgPreview.Refresh()
  59.         End If
  60.     End Sub
  61.  
  62.     Private Sub imgPreview_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles imgPreview.Paint
  63.         If Me.BgImage IsNot Nothing Then
  64.             Dim M As New Imaging.ColorMatrix
  65.             Dim A As New Imaging.ImageAttributes
  66.             Dim R As New Rectangle(0, 0, imgPreview.Width, imgPreview.Height)
  67.  
  68.             M.Matrix00 = 1
  69.             M.Matrix11 = 1
  70.             M.Matrix22 = 1
  71.             M.Matrix33 = trkAlpha.Value / 255
  72.             M.Matrix44 = 1
  73.             A.SetColorMatrix(M)
  74.  
  75.             e.Graphics.DrawImage(Me.BgImage, R, 0, 0, Me.BgImage.Width, Me.BgImage.Height, GraphicsUnit.Pixel, A)
  76.         End If
  77.     End Sub
  78.  
  79.     Private Sub trkAlpha_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trkAlpha.Scroll
  80.         imgPreview.Refresh()
  81.     End Sub
  82. End Class