Pouknouki

ImagePanel Class

Jan 9th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. Imports System.Collections.Generic
  2. Imports System.ComponentModel
  3. Imports System.Drawing
  4. Imports System.Data
  5. Imports System.Linq
  6. Imports System.Text
  7. Imports System.Windows.Forms
  8.  
  9. Partial Public Class ImagePanel
  10. Inherits Panel
  11. Private imgUrl As [String] = ""
  12. Private title As [String] = ""
  13. Private pict As PictureBox = Nothing
  14. Private label1 As Label = Nothing
  15.  
  16. Public Sub New()
  17. MyBase.New()
  18. InitializeComponent()
  19. End Sub
  20. Public Sub New(img As [String], title As [String])
  21. MyBase.New()
  22. imgUrl = img
  23. Me.title = title
  24.  
  25. Me.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
  26. Me.Name = "panel2"
  27. Me.Size = New System.Drawing.Size(108, 108)
  28.  
  29. ' pictureBox
  30. Me.pict = New PictureBox()
  31. Me.pict.Image = New Bitmap(img)
  32. Me.pict.Location = New System.Drawing.Point(4, 4)
  33. Me.pict.Size = New System.Drawing.Size(100, 100)
  34. Me.pict.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
  35. Me.pict.BringToFront()
  36.  
  37. '' label
  38. 'Me.label1 = New Label()
  39. 'Me.label1.AutoSize = True
  40. 'Me.label1.Location = New System.Drawing.Point(4, 99)
  41. 'Me.label1.Size = New System.Drawing.Size(131, 13)
  42. 'Me.label1.Text = title
  43.  
  44. 'Me.Controls.Add(Me.label1)
  45.  
  46. AddHandler Me.pict.Click, AddressOf picture_click
  47. AddHandler Me.Click, AddressOf Picture_Click
  48.  
  49. InitializeComponent()
  50. End Sub
  51.  
  52. Public Property Selected As Boolean
  53.  
  54. Private Sub Picture_Click(sender As Object, e As EventArgs)
  55. 'Me.Selected = Not Me.Selected
  56. 'If Selected Then
  57. ' Me.BackColor = Color.LightBlue
  58. 'Else
  59. ' Me.BackColor = Color.Transparent
  60. 'End If
  61. End Sub
  62.  
  63. Public Sub setImageURL(url As [String])
  64. Me.imgUrl = url
  65. Me.pict.Image = New Bitmap(url)
  66. End Sub
  67. End Class
Advertisement
Add Comment
Please, Sign In to add comment