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 - Items.vb

Items.vb

Caricato da: Totem
Scarica il programma completo

  1. <Serializable()> _
  2. Public MustInherit Class Item
  3.     Private _Color As Color
  4.     Private _Width As Single
  5.  
  6.     Public Property Color() As Color
  7.         Get
  8.             Return _Color
  9.         End Get
  10.         Set(ByVal value As Color)
  11.             _Color = value
  12.         End Set
  13.     End Property
  14.  
  15.     Public Property Width() As Single
  16.         Get
  17.             Return _Width
  18.         End Get
  19.         Set(ByVal value As Single)
  20.             _Width = value
  21.         End Set
  22.     End Property
  23.  
  24.     Public MustOverride Sub Draw(ByVal G As Graphics)
  25. End Class
  26.  
  27. <Serializable()> _
  28. Public MustInherit Class FillableItem
  29.     Inherits Item
  30.  
  31.     Private _Fill As Boolean = False
  32.     Private _DrawOutline As Boolean = True
  33.     Private _Blend As Boolean = False
  34.     Private _FillColor As Color
  35.     Private _BlendColor As Color
  36.     Private _BlendAngle As Single
  37.     <NonSerialized()> _
  38.     Protected _Region As Region
  39.  
  40.     Public Property FillColor() As Color
  41.         Get
  42.             Return _FillColor
  43.         End Get
  44.         Set(ByVal value As Color)
  45.             _FillColor = value
  46.         End Set
  47.     End Property
  48.  
  49.     Public Property BlendColor() As Color
  50.         Get
  51.             Return _BlendColor
  52.         End Get
  53.         Set(ByVal value As Color)
  54.             _BlendColor = value
  55.         End Set
  56.     End Property
  57.  
  58.     Public Property Fill() As Boolean
  59.         Get
  60.             Return _Fill
  61.         End Get
  62.         Set(ByVal value As Boolean)
  63.             _Fill = value
  64.         End Set
  65.     End Property
  66.  
  67.     Public Property Blend() As Boolean
  68.         Get
  69.             Return _Blend
  70.         End Get
  71.         Set(ByVal value As Boolean)
  72.             _Blend = value
  73.         End Set
  74.     End Property
  75.  
  76.     Public Property DrawOutline() As Boolean
  77.         Get
  78.             Return _DrawOutline
  79.         End Get
  80.         Set(ByVal value As Boolean)
  81.             _DrawOutline = value
  82.         End Set
  83.     End Property
  84.  
  85.     Public Property BlendAngle() As Single
  86.         Get
  87.             Return _BlendAngle
  88.         End Get
  89.         Set(ByVal value As Single)
  90.             _BlendAngle = value
  91.         End Set
  92.     End Property
  93.  
  94.     Public ReadOnly Property CoveredRegion() As Region
  95.         Get
  96.             Return _Region
  97.         End Get
  98.     End Property
  99.  
  100.     Protected Sub TranslateAndScalePath(ByRef Path As Drawing2D.GraphicsPath, ByVal Area As Rectangle, Optional ByVal ZoomIfSmaller As Boolean = False)
  101.         Dim StartArea As RectangleF = Path.GetBounds
  102.         Dim Matrix As New Drawing2D.Matrix
  103.         Dim Vector As New Point
  104.         Dim Wider As Boolean
  105.         Dim Zoom As Single
  106.  
  107.         If (StartArea.Width <= Area.Width) And (StartArea.Height <= Area.Height) And (Not ZoomIfSmaller) Then
  108.             Zoom = 1
  109.         Else
  110.             If Area.Width / StartArea.Width < Area.Height / StartArea.Height Then
  111.                 Zoom = Area.Width / StartArea.Width
  112.                 Wider = True
  113.             Else
  114.                 Zoom = Area.Height / StartArea.Height
  115.                 Wider = False
  116.             End If
  117.         End If
  118.  
  119.         Matrix.Scale(Zoom, Zoom)
  120.         Path.Transform(Matrix)
  121.  
  122.         Matrix = New Drawing2D.Matrix
  123.         StartArea = Path.GetBounds
  124.         Vector.X = -StartArea.X
  125.         Vector.Y = -StartArea.Y
  126.         Matrix.Translate(Vector.X, Vector.Y)
  127.         Path.Transform(Matrix)
  128.  
  129.         If Zoom = 1 Then
  130.             Vector.X = Area.Width / 2 - StartArea.Width / 2
  131.             Vector.Y = Area.Height / 2 - StartArea.Height / 2
  132.             Matrix = New Drawing2D.Matrix
  133.             Matrix.Translate(Vector.X, Vector.Y)
  134.             Path.Transform(Matrix)
  135.         Else
  136.             If Wider Then
  137.                 Vector.X = 0
  138.                 Vector.Y = Area.Height / 2 - StartArea.Height / 2
  139.             Else
  140.                 Vector.Y = 0
  141.                 Vector.X = Area.Width / 2 - StartArea.Width / 2
  142.             End If
  143.             Matrix = New Drawing2D.Matrix
  144.             Matrix.Translate(Vector.X, Vector.Y)
  145.             Path.Transform(Matrix)
  146.         End If
  147.     End Sub
  148.  
  149.     Public Overrides Sub Draw(ByVal G As System.Drawing.Graphics)
  150.  
  151.     End Sub
  152.  
  153.     Public MustOverride Sub DrawPreview(ByVal G As Graphics, ByVal Area As Rectangle)
  154. End Class
  155.  
  156. Public Interface IUndoable
  157.     Sub Undo()
  158. End Interface
  159.  
  160. Public Interface ICloseable
  161.     Property IsClosed() As Boolean
  162. End Interface
  163.  
  164. <Serializable()> _
  165. Public MustInherit Class PointConnectionItem
  166.     Inherits FillableItem
  167.     Implements IUndoable, ICloseable
  168.  
  169.     Private _Points As List(Of Point)
  170.     Private _IsClosed As Boolean = False
  171.  
  172.     Public Property IsClosed() As Boolean Implements ICloseable.IsClosed
  173.         Get
  174.             Return _IsClosed
  175.         End Get
  176.         Set(ByVal value As Boolean)
  177.             _IsClosed = value
  178.         End Set
  179.     End Property
  180.  
  181.     Public ReadOnly Property Points() As List(Of Point)
  182.         Get
  183.             Return _Points
  184.         End Get
  185.     End Property
  186.  
  187.     Public Overridable Sub Undo() Implements IUndoable.Undo
  188.         If Me.Points.Count >= 1 Then
  189.             Me.Points.RemoveAt(Me.Points.Count - 1)
  190.         End If
  191.     End Sub
  192.  
  193.     Sub New()
  194.         _Points = New List(Of Point)
  195.         Me.Width = 1.7
  196.         Me.Color = Drawing.Color.Black
  197.     End Sub
  198.  
  199.     Protected Sub DrawFirstPoint(ByVal G As Graphics)
  200.         Dim P As Point = Me.Points(0)
  201.         G.DrawLine(Pens.Red, P.X - 1, P.Y, P.X + 1, P.Y)
  202.         G.DrawLine(Pens.Red, P.X, P.Y - 1, P.X, P.Y + 1)
  203.     End Sub
  204.  
  205.     Public Overrides Sub Draw(ByVal G As System.Drawing.Graphics)
  206.  
  207.     End Sub
  208.  
  209.     Public Overrides Sub DrawPreview(ByVal G As Graphics, ByVal Area As Rectangle)
  210.  
  211.     End Sub
  212. End Class
  213.  
  214. <Serializable()> _
  215. Public Class ClosedCurve
  216.     Inherits PointConnectionItem
  217.    
  218.     Public Overrides Sub Draw(ByVal G As System.Drawing.Graphics)
  219.         Dim Path As New Drawing2D.GraphicsPath
  220.  
  221.         If Me.Points.Count = 0 Then
  222.             Exit Sub
  223.         End If
  224.  
  225.         If Me.Points.Count = 1 Then
  226.             Me.DrawFirstPoint(G)
  227.             Exit Sub
  228.         End If
  229.  
  230.         Path.AddCurve(Me.Points.ToArray)
  231.  
  232.         If Me.IsClosed Then
  233.             Path.CloseFigure()
  234.         End If
  235.  
  236.         If Me.Fill Then
  237.             If Me.Blend Then
  238.                 Dim BlendBrush As New Drawing2D.LinearGradientBrush(Path.GetBounds, Me.FillColor, Me.BlendColor, -Me.BlendAngle)
  239.                 G.FillPath(BlendBrush, Path)
  240.             Else
  241.                 G.FillPath(New SolidBrush(Me.FillColor), Path)
  242.             End If
  243.         End If
  244.  
  245.             If Me.DrawOutline Then
  246.                 G.DrawPath(New Pen(Me.Color, Me.Width), Path)
  247.             End If
  248.  
  249.             _Region = New Region(Path.GetBounds)
  250.     End Sub
  251.  
  252.     Public Overrides Sub DrawPreview(ByVal G As Graphics, ByVal Area As Rectangle)
  253.         Dim Path As New Drawing2D.GraphicsPath
  254.  
  255.         If Me.Points.Count = 0 Then
  256.             Exit Sub
  257.         End If
  258.  
  259.         If Me.Points.Count = 1 Then
  260.             Me.DrawFirstPoint(G)
  261.             Exit Sub
  262.         End If
  263.  
  264.         Path.AddCurve(Me.Points.ToArray)
  265.         Me.TranslateAndScalePath(Path, Area)
  266.  
  267.         If Me.IsClosed Then
  268.             Path.CloseFigure()
  269.         End If
  270.  
  271.         If Me.Fill Then
  272.             If Me.Blend Then
  273.                 Dim BlendBrush As New Drawing2D.LinearGradientBrush(Path.GetBounds, Me.FillColor, Me.BlendColor, -Me.BlendAngle)
  274.                 G.FillPath(BlendBrush, Path)
  275.             Else
  276.                 G.FillPath(New SolidBrush(Me.FillColor), Path)
  277.             End If
  278.         End If
  279.  
  280.         If Me.DrawOutline Then
  281.             G.DrawPath(New Pen(Me.Color, Me.Width), Path)
  282.         End If
  283.  
  284.         _Region = New Region(Path.GetBounds)
  285.     End Sub
  286. End Class
  287.  
  288. <Serializable()> _
  289. Public Class ClosedLine
  290.     Inherits PointConnectionItem
  291.  
  292.     Public Overrides Sub Draw(ByVal G As System.Drawing.Graphics)
  293.         Dim Path As New Drawing2D.GraphicsPath
  294.  
  295.         If Me.Points.Count = 0 Then
  296.             Exit Sub
  297.         End If
  298.  
  299.         If Me.Points.Count = 1 Then
  300.             Me.DrawFirstPoint(G)
  301.             Exit Sub
  302.         End If
  303.  
  304.         Path.AddLines(Me.Points.ToArray)
  305.  
  306.         If Me.IsClosed Then
  307.             Path.CloseFigure()
  308.         End If
  309.  
  310.         If Me.Fill Then
  311.             If Me.Blend Then
  312.                 Dim BlendBrush As New Drawing2D.LinearGradientBrush(Path.GetBounds, Me.FillColor, Me.BlendColor, -Me.BlendAngle)
  313.                 G.FillPath(BlendBrush, Path)
  314.             Else
  315.                 G.FillPath(New SolidBrush(Me.FillColor), Path)
  316.             End If
  317.         End If
  318.  
  319.         If Me.DrawOutline Then
  320.             G.DrawPath(New Pen(Me.Color, Me.Width), Path)
  321.         End If
  322.  
  323.         _Region = New Region(Path.GetBounds)
  324.     End Sub
  325.  
  326.     Public Overrides Sub DrawPreview(ByVal G As Graphics, ByVal Area As Rectangle)
  327.         Dim Path As New Drawing2D.GraphicsPath
  328.  
  329.         If Me.Points.Count = 0 Then
  330.             Exit Sub
  331.         End If
  332.  
  333.         If Me.Points.Count = 1 Then
  334.             Me.DrawFirstPoint(G)
  335.             Exit Sub
  336.         End If
  337.  
  338.         Path.AddLines(Me.Points.ToArray)
  339.         Me.TranslateAndScalePath(Path, Area)
  340.  
  341.         If Me.IsClosed Then
  342.             Path.CloseFigure()
  343.         End If
  344.  
  345.         If Me.Fill Then
  346.             If Me.Blend Then
  347.                 Dim BlendBrush As New Drawing2D.LinearGradientBrush(Path.GetBounds, Me.FillColor, Me.BlendColor, -Me.BlendAngle)
  348.                 G.FillPath(BlendBrush, Path)
  349.             Else
  350.                 G.FillPath(New SolidBrush(Me.FillColor), Path)
  351.             End If
  352.         End If
  353.  
  354.         If Me.DrawOutline Then
  355.             G.DrawPath(New Pen(Me.Color, Me.Width), Path)
  356.         End If
  357.  
  358.         _Region = New Region(Path.GetBounds)
  359.     End Sub
  360. End Class
  361.  
  362. <Serializable()> _
  363. Public Class Mix
  364.     Inherits FillableItem
  365.     Implements IUndoable, ICloseable
  366.  
  367.     <Serializable()> _
  368.     Public Structure MixPoint
  369.         Private _Base As Point
  370.         Private _BelongsToCurve As Boolean
  371.  
  372.         Public Property Base() As Point
  373.             Get
  374.                 Return _Base
  375.             End Get
  376.             Set(ByVal value As Point)
  377.                 _Base = value
  378.             End Set
  379.         End Property
  380.  
  381.         Public Property BelongsToCurve() As Boolean
  382.             Get
  383.                 Return _BelongsToCurve
  384.             End Get
  385.             Set(ByVal value As Boolean)
  386.                 _BelongsToCurve = value
  387.             End Set
  388.         End Property
  389.  
  390.         Sub New(ByVal Pt As Point, ByVal IsInCurve As Boolean)
  391.             Me.Base = Pt
  392.             Me.BelongsToCurve = IsInCurve
  393.         End Sub
  394.     End Structure
  395.  
  396.     Private _Points As List(Of MixPoint)
  397.     Private _IsClosed As Boolean = False
  398.  
  399.     Public Property IsClosed() As Boolean Implements ICloseable.IsClosed
  400.         Get
  401.             Return _IsClosed
  402.         End Get
  403.         Set(ByVal value As Boolean)
  404.             _IsClosed = value
  405.         End Set
  406.     End Property
  407.  
  408.     Public ReadOnly Property Points() As List(Of MixPoint)
  409.         Get
  410.             Return _Points
  411.         End Get
  412.     End Property
  413.  
  414.     Sub New()
  415.         _Points = New List(Of MixPoint)
  416.         Me.Width = 1.7
  417.         Me.Color = Drawing.Color.Black
  418.     End Sub
  419.  
  420.     Public Overridable Sub Undo() Implements IUndoable.Undo
  421.         If Me.Points.Count >= 1 Then
  422.             Me.Points.RemoveAt(Me.Points.Count - 1)
  423.         End If
  424.     End Sub
  425.  
  426.     Public Overrides Sub Draw(ByVal G As System.Drawing.Graphics)
  427.         Dim Path As New Drawing2D.GraphicsPath
  428.         Dim Temp As New List(Of Point)
  429.         Dim Type As Boolean
  430.  
  431.         If Me.Points.Count = 0 Then
  432.             Exit Sub
  433.         End If
  434.  
  435.         If Me.Points.Count = 1 Then
  436.             Dim P As Point = Me.Points(0).Base
  437.             G.DrawLine(Pens.Red, P.X - 1, P.Y, P.X + 1, P.Y)
  438.             G.DrawLine(Pens.Red, P.X, P.Y - 1, P.X, P.Y + 1)
  439.             Exit Sub
  440.         End If
  441.  
  442.         Type = Me.Points(0).BelongsToCurve
  443.         For Each M As MixPoint In Me.Points
  444.             'Raggruppa i punti dello stesso tipo in una lista
  445.             If M.BelongsToCurve = Type Then
  446.                 Temp.Add(M.Base)
  447.             Else
  448.                 'Quando c'è un punto di tipo diverso, termina la linea o
  449.                 'la curva e inizia un altro tipo
  450.                 If Type = True Then
  451.                     Path.AddCurve(Temp.ToArray)
  452.                 Else
  453.                     Path.AddLines(Temp.ToArray)
  454.                 End If
  455.  
  456.                 Dim Last As Point = Temp(Temp.Count - 1)
  457.                 Type = M.BelongsToCurve
  458.                 Temp.Clear()
  459.                 If Type = True Then
  460.                     'Le curve necessitano di iniziare dallo stesso punto finale
  461.                     'delle linee
  462.                     Temp.Add(Last)
  463.                 End If
  464.                 Temp.Add(M.Base)
  465.             End If
  466.         Next
  467.         If Type = True Then
  468.             Path.AddCurve(Temp.ToArray)
  469.         Else
  470.             Path.AddLines(Temp.ToArray)
  471.         End If
  472.  
  473.         If Me.IsClosed Then
  474.             Path.CloseFigure()
  475.         End If
  476.  
  477.         If Me.Fill Then
  478.             If Me.Blend Then
  479.                 Dim BlendBrush As New Drawing2D.LinearGradientBrush(Path.GetBounds, Me.FillColor, Me.BlendColor, -Me.BlendAngle)
  480.                 G.FillPath(BlendBrush, Path)
  481.             Else
  482.                 G.FillPath(New SolidBrush(Me.FillColor), Path)
  483.             End If
  484.         End If
  485.  
  486.         If Me.DrawOutline Then
  487.             G.DrawPath(New Pen(Me.Color, Me.Width), Path)
  488.         End If
  489.  
  490.         _Region = New Region(Path.GetBounds)
  491.     End Sub
  492.  
  493.     Public Overrides Sub DrawPreview(ByVal G As Graphics, ByVal Area As Rectangle)
  494.         Dim Path As New Drawing2D.GraphicsPath
  495.         Dim Temp As New List(Of Point)
  496.         Dim Type As Boolean
  497.  
  498.         If Me.Points.Count = 0 Then
  499.             Exit Sub
  500.         End If
  501.  
  502.         If Me.Points.Count = 1 Then
  503.             Dim P As Point = Me.Points(0).Base
  504.             G.DrawLine(Pens.Red, P.X - 1, P.Y, P.X + 1, P.Y)
  505.             G.DrawLine(Pens.Red, P.X, P.Y - 1, P.X, P.Y + 1)
  506.             Exit Sub
  507.         End If
  508.  
  509.         Type = Me.Points(0).BelongsToCurve
  510.         For Each M As MixPoint In Me.Points
  511.             'Raggruppa i punti dello stesso tipo in una lista
  512.             If M.BelongsToCurve = Type Then
  513.                 Temp.Add(M.Base)
  514.             Else
  515.                 'Quando c'è un punto di tipo diverso, termina la linea o
  516.                 'la curva e inizia un altro tipo
  517.                 If Type = True Then
  518.                     Path.AddCurve(Temp.ToArray)
  519.                 Else
  520.                     Path.AddLines(Temp.ToArray)
  521.                 End If
  522.  
  523.                 Dim Last As Point = Temp(Temp.Count - 1)
  524.                 Type = M.BelongsToCurve
  525.                 Temp.Clear()
  526.                 If Type = True Then
  527.                     'Le curve necessitano di iniziare dallo stesso punto finale
  528.                     'delle linee
  529.                     Temp.Add(Last)
  530.                 End If
  531.                 Temp.Add(M.Base)
  532.             End If
  533.         Next
  534.         If Type = True Then
  535.             Path.AddCurve(Temp.ToArray)
  536.         Else
  537.             Path.AddLines(Temp.ToArray)
  538.         End If
  539.  
  540.         Me.TranslateAndScalePath(Path, Area)
  541.  
  542.         If Me.IsClosed Then
  543.             Path.CloseFigure()
  544.         End If
  545.  
  546.         If Me.Fill Then
  547.             If Me.Blend Then
  548.                 Dim BlendBrush As New Drawing2D.LinearGradientBrush(Path.GetBounds, Me.FillColor, Me.BlendColor, -Me.BlendAngle)
  549.                 G.FillPath(BlendBrush, Path)
  550.             Else
  551.                 G.FillPath(New SolidBrush(Me.FillColor), Path)
  552.             End If
  553.         End If
  554.  
  555.         If Me.DrawOutline Then
  556.             G.DrawPath(New Pen(Me.Color, Me.Width), Path)
  557.         End If
  558.  
  559.         _Region = New Region(Path.GetBounds)
  560.     End Sub
  561. End Class
  562.  
  563. <Serializable()> _
  564. Public Class BackgroundImage
  565.     Private _Alpha As Byte
  566.     Private _Image As Image
  567.     Private _Center As Boolean
  568.     Private _Zoom As Single
  569.     Private _BufferImage As Image
  570.  
  571.     Public Property Alpha() As Byte
  572.         Get
  573.             Return _Alpha
  574.         End Get
  575.         Set(ByVal value As Byte)
  576.             _Alpha = value
  577.         End Set
  578.     End Property
  579.  
  580.     Public Property Image() As Image
  581.         Get
  582.             Return _Image
  583.         End Get
  584.         Set(ByVal value As Image)
  585.             _Image = value
  586.         End Set
  587.     End Property
  588.  
  589.     Public Property Center() As Boolean
  590.         Get
  591.             Return _Center
  592.         End Get
  593.         Set(ByVal value As Boolean)
  594.             _Center = value
  595.         End Set
  596.     End Property
  597.  
  598.     Public Property Zoom() As Single
  599.         Get
  600.             Return _Zoom
  601.         End Get
  602.         Set(ByVal value As Single)
  603.             _Zoom = value
  604.         End Set
  605.     End Property
  606.  
  607.     Public ReadOnly Property BufferImage() As Image
  608.         Get
  609.             Return _BufferImage
  610.         End Get
  611.     End Property
  612.  
  613.     Public Sub CreateBuffer()
  614.         Dim Buffer As New Bitmap(CInt(Image.Width * Zoom), CInt(Image.Height * Zoom))
  615.         Dim G As Graphics = Graphics.FromImage(Buffer)
  616.         Dim M As New Imaging.ColorMatrix
  617.         Dim A As New Imaging.ImageAttributes
  618.         Dim R As New Rectangle(New Point(0, 0), New Size(Image.Width * Zoom, Image.Height * Zoom))
  619.  
  620.         M.Matrix00 = 1
  621.         M.Matrix11 = 1
  622.         M.Matrix22 = 1
  623.         M.Matrix33 = Me.Alpha / 255
  624.         M.Matrix44 = 1
  625.         A.SetColorMatrix(M)
  626.  
  627.         G.DrawImage(Me.Image, R, 0, 0, Me.Image.Width, Me.Image.Height, GraphicsUnit.Pixel, A)
  628.  
  629.         Dim Memory As New IO.MemoryStream()
  630.         If Me.Alpha >= 240 Then
  631.             Buffer.Save(Memory, Drawing.Imaging.ImageFormat.Jpeg)
  632.         Else
  633.             Buffer.Save(Memory, Drawing.Imaging.ImageFormat.Png)
  634.         End If
  635.         _BufferImage = Drawing.Image.FromStream(Memory)
  636.     End Sub
  637.  
  638.     Public Sub Draw(ByVal G As System.Drawing.Graphics)
  639.         'G.DrawImage(BufferImage, Me.Location)
  640.     End Sub
  641. End Class
  642.  
  643. Public Class ItemByIndexComparer
  644.     Implements IComparer(Of ListViewItem)
  645.  
  646.     Public Function Compare(ByVal x As ListViewItem, ByVal y As ListViewItem) As Integer Implements System.Collections.Generic.IComparer(Of ListViewItem).Compare
  647.         Return DirectCast(x.Tag, Layer).Index.CompareTo(DirectCast(y.Tag, Layer).Index)
  648.     End Function
  649. End Class
  650.  
  651. Public Class LayerByIndexComparer
  652.     Implements IComparer(Of Layer)
  653.  
  654.     Public Function Compare(ByVal x As Layer, ByVal y As Layer) As Integer Implements System.Collections.Generic.IComparer(Of Layer).Compare
  655.         Return x.Index.CompareTo(y.Index)
  656.     End Function
  657. End Class
  658.  
  659. <Serializable()> _
  660. Public Class Layer
  661.     Inherits Item
  662.  
  663.     Private _Items As List(Of FillableItem)
  664.     Private _Name As String
  665.     Private _BgImage As BackgroundImage
  666.     Private _Index As Int32
  667.  
  668.     Public ReadOnly Property Items() As List(Of FillableItem)
  669.         Get
  670.             Return _Items
  671.         End Get
  672.     End Property
  673.  
  674.     Public Property Name() As String
  675.         Get
  676.             Return _Name
  677.         End Get
  678.         Set(ByVal value As String)
  679.             _Name = value
  680.         End Set
  681.     End Property
  682.  
  683.     Public Property BgImage() As BackgroundImage
  684.         Get
  685.             Return _BgImage
  686.         End Get
  687.         Set(ByVal value As BackgroundImage)
  688.             _BgImage = value
  689.         End Set
  690.     End Property
  691.  
  692.     Public Property Index() As Int32
  693.         Get
  694.             Return _Index
  695.         End Get
  696.         Set(ByVal value As Int32)
  697.             _Index = value
  698.         End Set
  699.     End Property
  700.  
  701.     Sub New()
  702.         _Items = New List(Of FillableItem)
  703.     End Sub
  704.  
  705.     Public Overrides Sub Draw(ByVal G As System.Drawing.Graphics)
  706.         For Each I As Item In Me.Items
  707.             I.Draw(G)
  708.         Next
  709.     End Sub
  710. End Class
  711.  
  712. <Serializable()> _
  713. Public Class Project
  714.     Private _CanavasWidth As Int32
  715.     Private _PickedColor As Color
  716.     Private _Layers As List(Of Layer)
  717.     Private _Name As String
  718.     Private _WindowState As FormWindowState
  719.     Private _WindowSize As Size
  720.  
  721.     Public Property CanavasWidth() As Int32
  722.         Get
  723.             Return _CanavasWidth
  724.         End Get
  725.         Set(ByVal value As Int32)
  726.             _CanavasWidth = value
  727.         End Set
  728.     End Property
  729.  
  730.     Public Property PickedColor() As Color
  731.         Get
  732.             Return _PickedColor
  733.         End Get
  734.         Set(ByVal value As Color)
  735.             _PickedColor = value
  736.         End Set
  737.     End Property
  738.  
  739.     Public Property Name() As String
  740.         Get
  741.             Return _Name
  742.         End Get
  743.         Set(ByVal value As String)
  744.             _Name = value
  745.         End Set
  746.     End Property
  747.  
  748.     Public Property WindowState() As FormWindowState
  749.         Get
  750.             Return _WindowState
  751.         End Get
  752.         Set(ByVal value As FormWindowState)
  753.             _WindowState = value
  754.         End Set
  755.     End Property
  756.  
  757.     Public Property WindowSize() As Size
  758.         Get
  759.             Return _WindowSize
  760.         End Get
  761.         Set(ByVal value As Size)
  762.             _WindowSize = value
  763.         End Set
  764.     End Property
  765.  
  766.     Public ReadOnly Property Layers() As List(Of Layer)
  767.         Get
  768.             Return _Layers
  769.         End Get
  770.     End Property
  771.  
  772.     Sub New()
  773.         _Layers = New List(Of Layer)
  774.     End Sub
  775. End Class