Imports Microsoft.Win32
Public Class frmHelper
Public Structure Text_
Dim Open, Music, Out As String
End Structure
Public Structure Image
Dim W, H As Int16
Dim Init, Music As String
End Structure
Public Structure Link
Dim Name, Path As String
End Structure
Public Structure Setting
Dim Texts As Text_
Dim Images As Image
Dim Links, Musics As ArrayList
Dim MusicExe As String
End Structure
Public Shared Settings As Setting
'Public MON As Boolean = False
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Carica le impostazioni
strLinks.DropDownItems.Clear()
strMusics.DropDownItems.Clear()
Dim RT As New IO.StreamReader(Application.StartupPath + "\Settings\Texts.dat")
Dim RI As New IO.StreamReader(Application.StartupPath + "\Settings\Images.dat")
Dim RM As New IO.StreamReader(Application.StartupPath + "\Settings\ExeMus.dat")
Dim L As Link
Dim T As ToolStripMenuItem
Settings.Texts.Open = RT.ReadLine
Settings.Texts.Music = RT.ReadLine
Settings.Texts.Out = RT.ReadLine
Settings.Images.W = RI.ReadLine
Settings.Images.H = RI.ReadLine
Settings.Images.Init = RI.ReadLine
Settings.Images.Music = RI.ReadLine
Settings.MusicExe = RM.ReadLine
Settings.Links = New ArrayList
Settings.Musics = New ArrayList
RT.Close()
RI.Close()
RM.Close()
'Carica i collegamtni
Try
Dim RL As New IO.StreamReader(Application.StartupPath + "\Settings\Links.dat")
While Not RL.EndOfStream
L.Name = RL.ReadLine
L.Path = RL.ReadLine
T = New ToolStripMenuItem()
T.Text = L.Name
T.Tag = L.Path
strLinks.DropDownItems.Add(T)
Settings.Links.Add(L)
End While
RL.Close()
Catch FNFE As IO.FileNotFoundException
T.Text = "Nessun collegamento"
T.Tag = "exit"
strLinks.DropDownItems.Add(T)
End Try
'Carica le musiche
Try
Dim RL As New IO.StreamReader(Application.StartupPath + "\Settings\Musics.dat")
While Not RL.EndOfStream
L.Name = RL.ReadLine
L.Path = RL.ReadLine
T = New ToolStripMenuItem()
T.Text = L.Name
T.Tag = L.Path
strMusics.DropDownItems.Add(T)
Settings.Musics.Add(L)
End While
RL.Close()
Catch FNFE As IO.FileNotFoundException
T.Text = "Nessun brano"
T.Tag = "exit"
strMusics.DropDownItems.Add(T)
End Try
sysIcon.Visible = True
sysIcon.BalloonTipTitle = "Aiutante virtuale"
sysIcon.BalloonTipText = Settings.Texts.Open
sysIcon.ShowBalloonTip(2000)
Me.Size = New Drawing.Size(Settings.Images.W, Settings.Images.H)
imgMain.Image = Drawing.Image.FromFile(Application.StartupPath + "\Imms\" + Settings.Images.Init)
AddHandler strLinks.DropDownItemClicked, AddressOf CallLink
AddHandler strMusics.DropDownItemClicked, AddressOf CallMusic
End Sub
Private Sub NascondiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strHid.Click
If strHid.Text = "Nascondi" Then
Me.Visible = False
strHid.Text = "Mostra"
Else
Me.Visible = True
strHid.Text = "Nascondi"
End If
End Sub
Private Sub EsciToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EsciToolStripMenuItem.Click
MsgBox(Settings.Texts.Out, MsgBoxStyle.Information)
sysIcon.Visible = False
Me.Close()
End Sub
Private Sub OraToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OraToolStripMenuItem.Click
Dim D As Date = Date.Now
sysIcon.BalloonTipTitle = "Data e ora"
sysIcon.BalloonTipText = D.ToLongDateString + ", Ore " + D.ToLongTimeString
sysIcon.ShowBalloonTip(3000)
End Sub
Private Sub CalcolatriceToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalcolatriceToolStripMenuItem.Click
Shell("C:\WINDOWS\system32\calc.exe")
End Sub
Private Sub AgendaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AgendaToolStripMenuItem.Click
Dim A As New frmDiary
A.Show()
End Sub
Private Sub CallLink(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs)
Try
Shell(e.ClickedItem.Tag)
Catch FNFE As IO.FileNotFoundException
End Try
End Sub
Private Sub CallMusic(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs)
Try
Shell(Settings.MusicExe + " " + Chr(34) + e.ClickedItem.Tag + Chr(34))
sysIcon.BalloonTipText = Settings.Texts.Music
sysIcon.ShowBalloonTip(2000)
imgMain.Image = Drawing.Image.FromFile(Application.StartupPath + "\Imms\" + Settings.Images.Music)
Me.Focus()
Catch FNFE As IO.FileNotFoundException
End Try
End Sub
Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click
Dim O As New frmOption
O.ShowDialog()
End Sub
Private Sub NormaleToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NormaleToolStripMenuItem.Click
imgMain.Image = Drawing.Image.FromFile(Application.StartupPath + "\Imms\" + Settings.Images.Init)
End Sub
Private Sub MusicaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MusicaToolStripMenuItem.Click
imgMain.Image = Drawing.Image.FromFile(Application.StartupPath + "\Imms\" + Settings.Images.Music)
End Sub
Private Sub ToolStripMenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem4.Click
Dim A As New frmAutoStart
A.ShowDialog()
End Sub
Private Sub ToolStripMenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem6.Click
Dim A As New frmAbout
A.ShowDialog()
End Sub
'Private Sub imgMain_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles imgMain.MouseMove
'If MON And Mode Then
' Me.Location = MousePosition
' End If
' End Sub
'Private Sub imgMain_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles imgMain.MouseDown
'MON = True
'End Sub
'Private Sub imgMain_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles imgMain.MouseUp
'MON = False
' End Sub
Private Sub ToolStripMenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem7.Click
Form1_Load(ToolStripMenuItem7, New System.EventArgs)
End Sub
End Class