Imports Curve_Art.Mix
Imports Microsoft.Win32
Public Class Form1
Private CurveBuffer As ClosedCurve
Private LineBuffer As ClosedLine
Private MixBuffer As Mix
Private ActiveBuffer As FillableItem
Private CopiedItem As FillableItem
Private PickingColor As Boolean = False
Private MaxIndex = 0
Private Sub RegisterIcon()
Dim RegKey As RegistryKey = Registry.ClassesRoot.OpenSubKey(".cva")
Dim WParam As RegistryKeyPermissionCheck = RegistryKeyPermissionCheck.ReadWriteSubTree
If RegKey IsNot Nothing Then
Exit Sub
Else
Dim Result As DialogResult
Result = MessageBox.Show("Impostare Curve Art come programma predefinito per aprire i file con estensione *.cva?", Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = Windows.Forms.DialogResult.No Then
Exit Sub
End If
End If
RegKey = Registry.ClassesRoot.CreateSubKey(".cva", WParam)
RegKey.SetValue("", "CurveArtProjectFile")
RegKey = Registry.ClassesRoot.CreateSubKey("CurveArtProjectFile", WParam)
RegKey.SetValue("", "File progetto di Curve Art")
RegKey = RegKey.CreateSubKey("DefaultIcon", WParam)
RegKey.SetValue("", Application.StartupPath & "\cva.ico")
RegKey = Registry.ClassesRoot.OpenSubKey("CurveArtProjectFile", True)
RegKey = RegKey.CreateSubKey("shell\open\command", WParam)
RegKey.SetValue("", String.Format("""{0}"" ""%1""", Application.ExecutablePath))
End Sub
Private Function GetHexColor(ByVal C As Color) As String
Return String.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", C.A, C.R, C.G, C.B)
End Function
Private Sub SetNodeInfo(ByVal Item As FillableItem, ByVal Node As TreeNode)
With Node
.Nodes.Clear()
.Nodes.Add("Spessore = " & Item.Width & " pt").ImageIndex = 2
.Nodes.Add("Colore tratto = " & GetHexColor(Item.Color)).ImageIndex = 2
.Nodes.Add("Tratto = " & IIf(Item.DrawOutline, "Sì", "No")).ImageIndex = 2
.Nodes.Add("Colore riempimento = " & GetHexColor(Item.FillColor)).ImageIndex = 2
.Nodes.Add("Riempimento = " & IIf(Item.Fill, "Sì", "No")).ImageIndex = 2
.Nodes.Add("Angolo di sfumatura = " & Item.BlendAngle).ImageIndex = 2
.Nodes.Add("Colore sfumatura = " & GetHexColor(Item.BlendColor)).ImageIndex = 2
.Nodes.Add("Sfumatura = " & IIf(Item.Blend, "Sì", "No")).ImageIndex = 2
End With
End Sub
Private Sub SetItemInfo(ByVal Layer As Layer, ByVal Item As ListViewItem)
With Item
.Text = Layer.Name
.ImageIndex = 0
.Tag = Layer
.SubItems.Add(Layer.Index.ToString)
.SubItems.Add(Layer.Index.ToString)
End With
End Sub
Private Sub SaveDrawing
(ByVal File As String)
Dim B As New Bitmap(pnlCanavas.Width, pnlCanavas.Height)
Dim G As Graphics = Graphics.FromImage(B)
G.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
For Each L As ListViewItem In lstLayers.CheckedItems
Dim Layer As Layer = L.Tag
Layer.Draw(G)
Next
End Sub
Private Sub strAddLayer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strAddLayer.Click
Dim Layer As New Layer
Dim L As New ListViewItem
Layer.Name = "Nuovo livello"
If lstLayers.Items.Count = 0 Then
Layer.Name = "Sfondo"
End If
Layer.Index = MaxIndex * 10
MaxIndex += 1
SetItemInfo(Layer, L)
L.Checked = True
L.Selected = True
lstLayers.Items.Add(L)
End Sub
Private Sub lstLayers_AfterLabelEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LabelEditEventArgs) Handles lstLayers.AfterLabelEdit
Dim Layer As Layer = lstLayers.Items(e.Item).Tag
Layer.Name = e.Label
End Sub
Private Sub lstLayers_ItemChecked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles lstLayers.ItemChecked
If e.Item.Index = 0 Then
Dim Layer0 As Layer = e.Item.Tag
If Not e.Item.Checked Then
pnlCanavas.BackgroundImage = Nothing
Else
If Layer0.BgImage IsNot Nothing Then
pnlCanavas.BackgroundImage = Layer0.BgImage.Image
If Layer0.BgImage.Center Then
pnlCanavas.BackgroundImageLayout = ImageLayout.Center
Else
pnlCanavas.BackgroundImageLayout = ImageLayout.None
End If
End If
End If
End If
pnlCanavas.Refresh()
End Sub
Private Sub lstLayers_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstLayers.SelectedIndexChanged
If lstLayers.SelectedIndices.Count = 0 Then
Exit Sub
End If
Dim Layer As Layer = lstLayers.SelectedItems(0).Tag
Label2.Text = "Oggetti livello '" & Layer.Name & "' :"
trwItems.Nodes.Clear()
For Each Item As FillableItem In Layer.Items
Dim T As New TreeNode
T.Tag = Item
T.ImageIndex = 1
If TypeOf Item Is ClosedCurve Then
T.Text = "Curva"
ElseIf TypeOf Item Is ClosedLine Then
T.Text = "Spezzata"
Else
T.Text = "Spezzata + Curva"
End If
SetNodeInfo(Item, T)
trwItems.Nodes.Add(T)
Next
End Sub
Private Sub strCurve_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strCurve.Click
If lstLayers.SelectedIndices.Count = 0 Then
MessageBox.Show("Nessun livello selezionato!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
Dim Layer As Layer = lstLayers.SelectedItems(0).Tag
CurveBuffer = New ClosedCurve
ActiveBuffer = CurveBuffer
Layer.Items.Add(CurveBuffer)
lstLayers_SelectedIndexChanged(Me, EventArgs.Empty)
chbMixCurve.Visible = False
lblStatus.Text = "Strumento curva"
End Sub
Private Sub pnlCanavas_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlCanavas.MouseClick
If PickingColor Then
Dim B As New Bitmap(pnlCanavas.Width, pnlCanavas.Height)
Dim P As New Point(MousePosition.X - Me.Location.X - 5, MousePosition.Y - Me.Location.Y - 55)
Dim C As Color
pnlCanavas.DrawToBitmap(B, New Rectangle(0, 0, pnlCanavas.Width, pnlCanavas.Height))
C = B.GetPixel(P.X, P.Y)
imgSavedColor.BackColor = C
Me.Cursor = Cursors.Default
PickingColor = False
Exit Sub
End If
If e.Button = Windows.Forms.MouseButtons.Left And ActiveBuffer IsNot Nothing Then
If (TypeOf ActiveBuffer Is ClosedCurve) Or (TypeOf ActiveBuffer Is ClosedLine) Then
DirectCast(ActiveBuffer, PointConnectionItem).Points.Add( _
New Point(MousePosition.X - Me.Location.X - 5, MousePosition.Y - Me.Location.Y - 55))
ElseIf TypeOf ActiveBuffer Is Mix Then
DirectCast(ActiveBuffer, Mix).Points.Add(New MixPoint( _
New Point(MousePosition.X - Me.Location.X - 5, MousePosition.Y - Me.Location.Y - 55), chbMixCurve.Checked))
End If
pnlCanavas.Refresh()
End If
End Sub
Private Sub pnlCanavas_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pnlCanavas.Paint
Dim Temp As New List(Of Layer)
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
For Each L As ListViewItem In lstLayers.CheckedItems
Dim Layer As Layer = L.Tag
Temp.Add(Layer)
Next
Temp.Sort(New LayerByIndexComparer)
For Each L As Layer In Temp
L.Draw(e.Graphics)
Next
End Sub
Private Sub trwItems_NodeMouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles trwItems.NodeMouseDoubleClick
Dim Item As FillableItem = e.Node.Tag
If e.Node.Parent IsNot Nothing Then
Exit Sub
End If
Dim Dialog As New ItemPropertiesDialog(Item)
If Dialog.ShowDialog = Windows.Forms.DialogResult.OK Then
With Item
.Color = Dialog.OutlineColor
.DrawOutline = Dialog.DrawOutline
.Fill = Dialog.Fill
.FillColor = Dialog.FillColor
.Width = Dialog.OutlineWidth
End With
SetNodeInfo(Item, e.Node)
pnlCanavas.Refresh()
End If
End Sub
Private Sub strDelLayer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strDelLayer.Click
If lstLayers.SelectedIndices.Count = 0 Then
Exit Sub
End If
If lstLayers.SelectedIndices(0) = 0 Then
MessageBox.Show("Impossibile eliminare il livello di sfondo!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
lstLayers.Items.RemoveAt(lstLayers.SelectedIndices(0))
Me.Refresh()
End Sub
Private Sub strLayerProperties_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strLayerProperties.Click
If lstLayers.SelectedIndices.Count = 0 Then
Exit Sub
End If
If lstLayers.SelectedIndices(0) = 0 Then
Dim N As New NewDrawingDialog
Dim Layer0 As Layer = lstLayers.SelectedItems(0).Tag
Dim LItem As ListViewItem = lstLayers.SelectedItems(0)
If Layer0.BgImage IsNot Nothing Then
N.BgImage = Layer0.BgImage.BufferImage
N.trkAlpha.Value = Layer0.BgImage.Alpha
N.chbCenter.Checked = Layer0.BgImage.Center
End If
If Me.Text.Length >= "Curve Art - ".Length Then
N.txtName.Text = Me.Text.Remove(0, "Curve Art - ".Length)
End If
If N.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim BG As New BackgroundImage
BG.Image = N.BgImage
BG.Center = N.Center
BG.Zoom = N.Zoom
BG.Alpha = N.Alpha
BG.CreateBuffer()
pnlCanavas.BackgroundImage = BG.BufferImage
If BG.Center Then
pnlCanavas.BackgroundImageLayout = ImageLayout.Center
End If
Me.Text = "Curva Art - " & N.DrawingName
Layer0.BgImage = BG
Layer0.Index = 0
pnlCanavas.Refresh()
End If
Exit Sub
End If
Try
Dim Layer As Layer = lstLayers.SelectedItems(0).Tag
Dim NewIndex As Int32 = _
InputBox("L'indice di rendering di questo livello è " & Layer.Index & ". Inserire un nuovo indice:", Me.Text)
Layer.Index = NewIndex
SetItemInfo(Layer, lstLayers.SelectedItems(0))
Catch Ex As Exception
End Try
End Sub
Private Sub strNewDrawing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strNewDrawing.Click
If lstLayers.Items.Count > 0 Then
Dim Result As DialogResult
Result = MessageBox.Show("C'è un altro disegno in corso. Salvarlo prima di continuare?", Me.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
If Result = Windows.Forms.DialogResult.Yes Then
strSave_Click(Me, EventArgs.Empty)
ElseIf Result = Windows.Forms.DialogResult.Cancel Then
Exit Sub
End If
End If
Dim N As New NewDrawingDialog
If N.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim BG As New BackgroundImage
BG.Image = N.BgImage
BG.Center = N.Center
BG.Zoom = N.Zoom
BG.Alpha = N.Alpha
BG.CreateBuffer()
pnlCanavas.BackgroundImage = BG.BufferImage
If BG.Center Then
pnlCanavas.BackgroundImageLayout = ImageLayout.Center
End If
Me.Text = "Curve Art - " & N.DrawingName
Dim Layer0 As New Layer
Dim L As New ListViewItem
Layer0.Name = "Sfondo"
Layer0.BgImage = BG
Layer0.Index = 0
SetItemInfo(Layer0, L)
MaxIndex = 1
lstLayers.Items.Add(L)
pnlCanavas.Refresh()
End If
End Sub
Private Sub strUndo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strUndo.Click
If ActiveBuffer IsNot Nothing Then
Dim Un As IUndoable = ActiveBuffer
Un.Undo()
pnlCanavas.Refresh()
End If
End Sub
Private Sub strCloseFigure_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strCloseFigure.Click
If ActiveBuffer IsNot Nothing Then
Dim Cl As ICloseable = ActiveBuffer
Cl.IsClosed = True
pnlCanavas.Refresh()
End If
End Sub
Private Sub strLine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strLine.Click
If lstLayers.SelectedIndices.Count = 0 Then
MessageBox.Show("Nessun livello selezionato!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
Dim Layer As Layer = lstLayers.SelectedItems(0).Tag
LineBuffer = New ClosedLine
ActiveBuffer = LineBuffer
Layer.Items.Add(LineBuffer)
lstLayers_SelectedIndexChanged(Me, EventArgs.Empty)
chbMixCurve.Visible = False
lblStatus.Text = "Strumento Spezzata"
End Sub
Private Sub strMix_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strMix.Click
If lstLayers.SelectedIndices.Count = 0 Then
MessageBox.Show("Nessun livello selezionato!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
Dim Layer As Layer = lstLayers.SelectedItems(0).Tag
MixBuffer = New Mix
ActiveBuffer = MixBuffer
Layer.Items.Add(MixBuffer)
lstLayers_SelectedIndexChanged(Me, EventArgs.Empty)
chbMixCurve.Visible = True
lblStatus.Text = "Strumento Curva + Spezzata"
End Sub
Private Sub trwItems_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles trwItems.AfterSelect
If trwItems.SelectedNode Is Nothing Then
Exit Sub
End If
Dim Selected As TreeNode = trwItems.SelectedNode
If Selected.Parent IsNot Nothing Then
Selected = Selected.Parent
End If
ActiveBuffer = Selected.Tag
End Sub
Private Sub strDelItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strDelItem.Click
If trwItems.SelectedNode Is Nothing Then
MessageBox.Show("Nessun oggetto selezionato!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
Dim Selected As TreeNode = trwItems.SelectedNode
If Selected.Parent IsNot Nothing Then
MessageBox.Show("Nessun oggetto selezionato!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
Dim Layer As Layer = lstLayers.SelectedItems(0).Tag
Layer.Items.Remove(Selected.Tag)
trwItems.Nodes.Remove(Selected)
pnlCanavas.Refresh()
End Sub
Private Sub strSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strSave.Click
If lstLayers.Items.Count = 0 Then
MessageBox.Show("Non c'è niente da salvare.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
Dim Save As New SaveFileDialog
Save.Filter = "Immagine JPEG|*.jpg|Immagine Bitmap|*.bmp|Immagine PNG|*.png|Immagine GIF|*.gif|Immagine TIFF|*.tif|Immagine WMF|*.wmf|File progetto di Curve Art|*.cva"
If Save.ShowDialog = Windows.Forms.DialogResult.OK Then
If Save.FilterIndex = 7 Then
Dim Serializer As New Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim Current As New Project
Dim Stream As New IO.FileStream(Save.FileName, IO.FileMode.Create)
Current.PickedColor = imgSavedColor.BackColor
Current.CanavasWidth = splitMain.SplitterDistance
Current.WindowState = Me.WindowState
Current.WindowSize = Me.Size
If Me.Text.Length >= "Curve Art - ".Length Then
Current.Name = Me.Text.Replace(0, "Curve Art - ".Length)
End If
For Each L As ListViewItem In lstLayers.Items
Current.Layers.Add(L.Tag)
Next
Serializer.Serialize(Stream, Current)
Stream.Close()
Else
SaveDrawing(Save.FileName)
End If
End If
End Sub
Private Sub strOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strOpen.Click
If lstLayers.Items.Count > 0 Then
Dim Result As DialogResult
Result = MessageBox.Show("C'è un altro disegno in corso. Salvarlo prima di continuare?", Me.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
If Result = Windows.Forms.DialogResult.Yes Then
strSave_Click(Me, EventArgs.Empty)
ElseIf Result = Windows.Forms.DialogResult.Cancel Then
Exit Sub
End If
End If
Dim Open As New OpenFileDialog
Open.Filter = "File progetto di Curve Art|*.cva"
If Open.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim Serializer As New Runtime.Serialization.Formatters.Binary.BinaryFormatter()
Dim Proj As Project
Dim Stream As New IO.FileStream(Open.FileName, IO.FileMode.Open)
Proj = Serializer.Deserialize(Stream)
Stream.Close()
lstLayers.Items.Clear()
trwItems.Nodes.Clear()
With Proj
If .WindowState = FormWindowState.Normal Then
Me.Size = .WindowSize
Else
Me.WindowState = .WindowState
End If
imgSavedColor.BackColor = .PickedColor
splitMain.SplitterDistance = .CanavasWidth
Me.Text = "Curve Art - " & .Name
End With
For Each Layer As Layer In Proj.Layers
Dim L As New ListViewItem
SetItemInfo(Layer, L)
lstLayers.Items.Add(L)
If Layer.Index > MaxIndex * 10 Then
MaxIndex = Layer.Index \ 10 + 2
End If
Next
End If
End Sub
Private Sub strColorPicker_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strColorPicker.Click
PickingColor = True
Me.Cursor = Cursors.Cross
lblStatus.Text = "Strumento Preleva"
End Sub
Private Sub strOpenFigure_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strOpenFigure.Click
If ActiveBuffer IsNot Nothing Then
Dim Cl As ICloseable = ActiveBuffer
Cl.IsClosed = False
pnlCanavas.Refresh()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Args As Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Application.CommandLineArgs
AddHandler My.Application.UnhandledException, AddressOf Exception_Manager
RegisterIcon()
If Args.Count > 0 Then
Dim FileName As String = Args(0)
Dim Serializer As New Runtime.Serialization.Formatters.Binary.BinaryFormatter()
Dim Proj As New Project
Dim Stream As New IO.FileStream(FileName, IO.FileMode.Open)
Proj = Serializer.Deserialize(Stream)
Stream.Close()
lstLayers.Items.Clear()
trwItems.Nodes.Clear()
With Proj
If .WindowState = FormWindowState.Normal Then
Me.Size = .WindowSize
Else
Me.WindowState = .WindowState
End If
imgSavedColor.BackColor = .PickedColor
splitMain.SplitterDistance = .CanavasWidth
Me.Text = "Curve Art - " & .Name
End With
For Each Layer As Layer In Proj.Layers
Dim L As New ListViewItem
SetItemInfo(Layer, L)
lstLayers.Items.Add(L)
If Layer.Index > MaxIndex * 10 Then
MaxIndex = Layer.Index \ 10 + 2
End If
Next
End If
End Sub
Private Sub strExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strExit.Click
If lstLayers.Items.Count > 0 Then
Dim Result As DialogResult
Result = MessageBox.Show("C'è un altro disegno in corso. Salvarlo prima di uscire?", Me.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
If Result = Windows.Forms.DialogResult.Yes Then
strSave_Click(Me, EventArgs.Empty)
ElseIf Result = Windows.Forms.DialogResult.Cancel Then
Exit Sub
End If
Me.Close()
End If
End Sub
Private Sub strAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strAbout.Click
My.Forms.The_Lair_AboutBox1.ShowDialog()
End Sub
Private Sub strSortLevel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strSortLevel.Click
Dim Layers As New List(Of ListViewItem)
For Each L As ListViewItem In lstLayers.Items
Layers.Add(L)
Next
Layers.Sort(New ItemByIndexComparer())
lstLayers.Items.Clear()
For Each L As ListViewItem In Layers
lstLayers.Items.Add(L)
Next
End Sub
Private Sub strListDetails_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strListDetails.Click
If lstLayers.View = View.List Then
lstLayers.View = View.Details
strListDetails.Text = "Lista"
Else
lstLayers.View = View.List
strListDetails.Text = "Dettagli"
End If
End Sub
Private Sub strCheckAllLayers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strCheckAllLayers.Click
For Each L As ListViewItem In lstLayers.Items
L.Checked = True
Next
pnlCanavas.Refresh()
End Sub
Private Sub strUncheckAllLayers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strUncheckAllLayers.Click
For Each L As ListViewItem In lstLayers.Items
L.Checked = False
Next
pnlCanavas.Refresh()
End Sub
Private Sub strDupeItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strDupeItem.Click
If trwItems.SelectedNode Is Nothing Then
MessageBox.Show("Nessun oggetto selezionato!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
Dim Selected As TreeNode = trwItems.SelectedNode
Dim Copy As TreeNode = Selected.Clone
trwItems.Nodes.Add(Copy)
End Sub
Private Sub strCopyPoints_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strCopyPoints.Click
If trwItems.SelectedNode Is Nothing Then
MessageBox.Show("Nessun oggetto selezionato!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
Dim Selected As TreeNode = trwItems.SelectedNode
Dim Item As FillableItem = Selected.Tag
Dim PDialog As New CopyPointsDialog(Item)
If PDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
CopiedItem = PDialog.FinalItem
End If
End Sub
Private Sub strPastePoints_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strPastePoints.Click
If lstLayers.SelectedIndices.Count = 0 Then
MessageBox.Show("Nessun livello selezionato!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
If CopiedItem Is Nothing Then
MessageBox.Show("Non sono stati copiati punti da incollare!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
Dim Layer As Layer = lstLayers.SelectedItems(0).Tag
Layer.Items.Add(CopiedItem)
lstLayers_SelectedIndexChanged(Me, EventArgs.Empty)
If TypeOf CopiedItem Is Mix Then
chbMixCurve.Checked = True
End If
lblStatus.Text = "Punti copiati sul livello '" & Layer.Name & "'"
End Sub
Private Sub Exception_Manager(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs)
Dim ErrorData As String
ErrorData = e.Exception.GetType.FullName & vbCrLf
ErrorData &= e.Exception.Message & vbCrLf & vbCrLf
MessageBox.Show(ErrorData & "Si è verificato un errore nell'applicazione. Contattare lo sviluppatore.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
e.ExitApplication = False
End Sub
End Class