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

CopyPointsDialog.vb

Caricato da: Totem
Scarica il programma completo

  1. Imports System.Windows.Forms
  2.  
  3. Public Class CopyPointsDialog
  4.     Private StartItem, EndItem As FillableItem
  5.  
  6.     Public ReadOnly Property FinalItem() As FillableItem
  7.         Get
  8.             Return EndItem
  9.         End Get
  10.     End Property
  11.  
  12.     Sub New(ByVal Item As FillableItem)
  13.         Me.InitializeComponent()
  14.         Me.StartItem = Item
  15.         If TypeOf Item Is PointConnectionItem Then
  16.             If TypeOf Item Is ClosedCurve Then
  17.                 Me.EndItem = New ClosedCurve
  18.             ElseIf TypeOf Item Is ClosedLine Then
  19.                 Me.EndItem = New ClosedLine
  20.             End If
  21.             For I As Int32 = 0 To DirectCast(Item, PointConnectionItem).Points.Count - 1
  22.                 lstPoints.Items.Add("Punto " & I)
  23.             Next
  24.         Else
  25.             Me.EndItem = New Mix
  26.             Dim Temp As Mix = Item
  27.             For I As Int32 = 0 To Temp.Points.Count - 1
  28.                 lstPoints.Items.Add("Punto " & I & " (" & IIf(Temp.Points(I).BelongsToCurve, "Curva", "Spezzata") & ")")
  29.             Next
  30.         End If
  31.  
  32.         For I As Int32 = 0 To lstPoints.Items.Count - 1
  33.             lstPoints.SetItemChecked(I, True)
  34.         Next
  35.         imgPreviewStart.Refresh()
  36.         imgPreviewEnd.Refresh()
  37.  
  38.         With Me.EndItem
  39.             .DrawOutline = StartItem.DrawOutline
  40.             .Fill = StartItem.Fill
  41.             .Color = StartItem.Color
  42.             .FillColor = StartItem.FillColor
  43.             .Width = StartItem.Width
  44.         End With
  45.     End Sub
  46.  
  47.     Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
  48.         If lstPoints.CheckedIndices.Count = 0 Then
  49.             MessageBox.Show("Selezionare almeno un punto!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  50.             Exit Sub
  51.         End If
  52.  
  53.         Me.DialogResult = System.Windows.Forms.DialogResult.OK
  54.         Me.Close()
  55.     End Sub
  56.  
  57.     Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
  58.         Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
  59.         Me.Close()
  60.     End Sub
  61.  
  62.     Private Sub imgPreview_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles imgPreviewStart.Paint
  63.         e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
  64.         StartItem.DrawPreview(e.Graphics, New Rectangle(0, 0, imgPreviewStart.Width - 1, imgPreviewStart.Height - 1))
  65.     End Sub
  66.  
  67.     Private Sub lstPoints_ItemCheck(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles lstPoints.ItemCheck
  68.         If TypeOf EndItem Is PointConnectionItem Then
  69.             Dim Temp As PointConnectionItem = EndItem
  70.             Dim Start As PointConnectionItem = StartItem
  71.             Temp.Points.Clear()
  72.             For I As Int32 = 0 To lstPoints.Items.Count - 1
  73.                 If I = e.Index Then
  74.                     If e.NewValue Then
  75.                         Temp.Points.Add(Start.Points(I))
  76.                     End If
  77.                     Continue For
  78.                 End If
  79.                 If lstPoints.GetItemChecked(I) Then
  80.                     Temp.Points.Add(Start.Points(I))
  81.                 End If
  82.             Next
  83.             EndItem = Temp
  84.         Else
  85.             Dim Temp As Mix = EndItem
  86.             Dim Start As Mix = StartItem
  87.             Temp.Points.Clear()
  88.             For I As Int32 = 0 To lstPoints.Items.Count - 1
  89.                 If I = e.Index Then
  90.                     If e.NewValue Then
  91.                         Temp.Points.Add(Start.Points(I))
  92.                     End If
  93.                     Continue For
  94.                 End If
  95.                 If lstPoints.GetItemChecked(I) Then
  96.                     Temp.Points.Add(Start.Points(I))
  97.                 End If
  98.             Next
  99.             EndItem = Temp
  100.         End If
  101.         imgPreviewStart.Refresh()
  102.         imgPreviewEnd.Refresh()
  103.     End Sub
  104.  
  105.     Private Sub imgPreviewEnd_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles imgPreviewEnd.Paint
  106.         e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
  107.         EndItem.DrawPreview(e.Graphics, New Rectangle(0, 0, imgPreviewStart.Width - 1, imgPreviewStart.Height - 1))
  108.     End Sub
  109. End Class