Torna al Thread

[CODE] Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.PictureBox1.Image = Nothing Dim bmp As New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height) Dim gr As Graphics = Graphics.FromImage(bmp) 'Dal momento che ho coordinate positive e negative traslo l'origine al centro della PictureBox 'gr.TranslateTransform(Me.PictureBox1.Width / 2, Me.PictureBox1.Height / 2) ' Create pen. Dim blackPen As New Pen(Color.Black, 3) 'Elenco dei punti Dim mPoints As ArrayList = New ArrayList() 'Le coordinate che inserirò nella lista mPoints per disegnare il mio poligono Dim X As Decimal = 0 Dim Y As Decimal = 0 'Ciclo le righe della ListBox For i As Integer = 0 To Me.ListBox1.Items.Count - 1 'Analizzo la linea e sostituisco il punto con la virgola (il separatore dei decimali) Dim selLine As String = Me.ListBox1.Items(i).ToString.Replace(".", ",") 'Cerco il primo carattere della linea Dim myChar As Char = selLine.Chars(0) ' In base al primo carattere eseguo le varie operazioni Select Case selLine.StartsWith(myChar) Case myChar = "X" If selLine.Contains("Y") = True Then Dim coord As String() = Split(selLine.Replace("X", Nothing), "Y") X = CDec(coord(0)) Y = coord(1).Replace(";", Nothing) Else X = selLine.Replace("X", Nothing) End If Case myChar = ("Y") Y = selLine.Replace("Y", Nothing) Case myChar = "G" Exit For End Select 'Aggiungo i punti alla lista mPoints.Add(New Point(X, Y)) Next 'Trasformo la mia lista in Punti Dim pointArray() As Point = mPoints.ToArray(mPoints(0).GetType()) 'Disegno il poligono 'gr.DrawLines(blackPen, pointArray) gr.DrawPolygon(blackPen, pointArray) Me.PictureBox1.Image = bmp End Sub[/CODE]
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5