Public Class Form1
Private Sub LoadChart(ByVal FileName As String)
Dim Formatter As New Runtime.Serialization.Formatters.Binary.BinaryFormatter()
Dim File As New IO.
FileStream(FileName, IO.
FileMode.
Open)
Dim G As New frmGraph
G.TopLevel = False
G.MdiParent = Me
Try
G.
Chart = Formatter.
Deserialize(File)
G.Text = G.Chart.Properties.Name
G.Chart.Surface = G.daGraph
G.pgChart.SelectedObject = G.Chart.Properties
G.pgPlane.SelectedObject = G.Chart.Plane
If G.Chart.Data IsNot Nothing Then
G.dgvData.DataSource = G.Chart.Data
G.Chart.Plane.XLabel = G.Chart.Data.Columns(0).ColumnName
G.Chart.Plane.YLabel = "Valori"
End If
G.Show()
Catch Ex As Exception
MessageBox.Show(Ex.Message, "Errore apertura", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub strNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strNew.Click
Dim Open As New SelectGraphDialog
If Open.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim G As New frmGraph
G.TopLevel = False
G.MdiParent = Me
'Nome del grafico
G.Text = Open.ChartName
'Tipologia grafico
Select Case Open.ChartType
Case ChartType.Istogramma
G.Chart = New Histogram()
G.Chart.Properties = New HistogramProperties()
Case ChartType.Torta
G.Chart = New PieChart()
G.Chart.Properties = New PieChartProperties()
Case ChartType.Linee
G.Chart = New LinesChart()
G.Chart.Properties = New LinesChartProperties()
Case ChartType.Dispersione
G.Chart = New DispersionChart()
G.Chart.Properties = New DispersionChartProperties()
End Select
G.Chart.Type = Open.ChartType
G.Chart.Properties.Name = Open.ChartName
G.Chart.Properties.LegendPosition = New Point(G.daGraph.Width - 200, G.daGraph.Height - 100)
'Superficie di disegno
G.Chart.Surface = G.daGraph
'Piano cartesiano
G.Chart.Plane = New CartesianPlane(New Point(60, G.daGraph.Height - 20))
'Proprietà del piano
With G.Chart.Plane
.Color = Color.Black
.GridColor = Color.Gainsboro
.GridInterval = 10
.PixelsPerDot = 2
.UnitsPerDot = 1
.XLabel = "Asse X"
.YLabel = "Asse Y"
End With
G.pgPlane.SelectedObject = G.Chart.Plane
G.pgChart.SelectedObject = G.Chart.Properties
'Dati
If Open.DefaultData IsNot Nothing Then
G.dgvData.DataSource = Open.DefaultData
G.Chart.Plane.XLabel = Open.DefaultData.Columns(0).ColumnName
G.Chart.Plane.YLabel = "Valori"
End If
G.Show()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.IsMdiContainer = True
AddHandler My.Application.UnhandledException, AddressOf UnhandledException
End Sub
Private Sub strOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strOpen.Click
Dim Open As New OpenFileDialog
Open.Filter = "File Totem Charting|*.tch"
If Open.ShowDialog = Windows.Forms.DialogResult.OK Then
LoadChart(Open.FileName)
End If
End Sub
Private Sub strExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strExit.Click
Me.Close()
End Sub
Private Sub UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs)
MessageBox.Show("Si è verificata un'eccezione non gestita dal programma: " & vbCrLf & e.Exception.Message & vbCrLf & "Contattare il programmatore per maggiori informazioni (vedi About).", "Eccezione non gestita", MessageBoxButtons.OK, MessageBoxIcon.Error)
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
End Class