Torna al Thread

Imports System.IO Public Class Form1 Private Sub btnLOAD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLOAD.Click 'Questo codice carica il file in una ListBox OpenFileDialog1.InitialDirectory = "c:\" openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" openFileDialog1.FilterIndex = 2 openFileDialog1.RestoreDirectory = True If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Try Dim readText() As String = File.ReadAllLines(OpenFileDialog1.FileName) Dim s As String For Each s In readText Me.ListBox1.Items.Add(s) Next Catch Ex As Exception MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message) End Try End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Questo codice disegna le linee che trova nella ListBox in una PictureBox If Me.ListBox1.Items.Count > 0 Then Dim bmp As New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height) Dim gr As Graphics = Graphics.FromImage(bmp) Dim blackPen As New Pen(Color.Red, 3) Dim x1 As Single = Nothing Dim y1 As Single = Nothing Dim x2 As Single = Nothing Dim y2 As Single = Nothing For i As Integer = 0 To Me.ListBox1.Items.Count - 1 Dim line() As String line = Split(Me.ListBox1.Items(i), ";") x1 = line(0) y1 = line(1) x2 = line(2) y2 = line(3) gr.DrawLine(blackPen, x1, y1, x2, y2) Next Me.PictureBox1.Image = bmp Else MsgBox("Nessuna riga da processare") End If End Sub End Class
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5