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
Global Web 2.2 - Form1.vb

Form1.vb

Caricato da: Totem
Scarica il programma completo

  1. Imports System
  2. Imports System.Net
  3. Imports System.Drawing.Printing
  4. Public Class frmBrowser
  5.     Public Structure Motor
  6.         Dim Name As String
  7.         Dim URL As String
  8.     End Structure
  9.     Public Structure Favorite
  10.         Dim Name, URL As String
  11.     End Structure
  12.     Public CurrentPage As Int16
  13.     Public LastAddress As Int16
  14.     Public Motors As New ArrayList
  15.     Public Forbiddens As New ArrayList
  16.     Public Favorites As New ArrayList
  17.     Public Shared Chronos As New ArrayList
  18.     Public ChronoEnabled As Boolean
  19.     Public Forbpassword As String
  20.     Public FavoritesFile As String = Application.StartupPath & "\Favorites.dat"
  21.     Public HomePageFile As String = Application.StartupPath & "\Settings.dat"
  22.     Public ChronosFile As String = Application.StartupPath + "\Chronos.dat"
  23.     Public HomePage As String
  24.     Public Iph As IPHostEntry
  25. #Region "Metodi personalizzati"
  26. #Region "Preferiti"
  27.     Public Sub AddFavorite(ByVal Fav As Favorite)
  28.         Favorites.Add(Fav)
  29.         FavoritesButton.DropDownItems.Add(Fav.Name)
  30.         FavoritesButton.DropDownItems(FavoritesButton.DropDownItems.Count - 1).Tag = Fav.URL
  31.         strRemove.DropDownItems.Add(Fav.Name)
  32.     End Sub
  33.     Public Sub DeleteFavorites(ByVal ToDel As String)
  34.         Dim F As Favorite
  35.         Dim i As Int16 = 0
  36.  
  37.         For Each F In Favorites
  38.             If F.Name = ToDel Then
  39.                 Favorites.RemoveAt(i)
  40.                 Exit Sub
  41.             End If
  42.             i += 1
  43.         Next
  44.     End Sub
  45.     Public Sub RefreshFavorites()
  46.         Try
  47.             Dim F As Favorite
  48.             Dim i As Int16 = 0
  49.  
  50.             FavoritesButton.DropDownItems.Clear()
  51.             strRemove.DropDownItems.Clear()
  52.  
  53.             For Each F In Favorites
  54.                 FavoritesButton.DropDownItems.Add(F.Name)
  55.                 FavoritesButton.DropDownItems(i).Tag = F.URL
  56.                 strRemove.DropDownItems.Add(F.Name)
  57.                 i += 1
  58.             Next
  59.         Catch ex As IO.FileNotFoundException
  60.             CreateFile(FavoritesFile)
  61.         End Try
  62.     End Sub
  63.     Public Sub LoadFavorites()
  64.         Try
  65.             Dim R As New IO.StreamReader(FavoritesFile)
  66.             Dim F As Favorite
  67.             Dim I As Int16 = 0
  68.  
  69.             While Not R.EndOfStream
  70.                 F.Name = Decrypt(R.ReadLine)
  71.                 F.URL = Decrypt(R.ReadLine)
  72.                 FavoritesButton.DropDownItems.Add(F.Name)
  73.                 FavoritesButton.DropDownItems(I).Tag = F.URL
  74.                 strRemove.DropDownItems.Add(F.Name)
  75.                 Favorites.Add(F)
  76.                 I += 1
  77.             End While
  78.  
  79.             R.Close()
  80.             R = Nothing
  81.         Catch ex As IO.FileNotFoundException
  82.             Dim WN As New IO.StreamWriter(FavoritesFile)
  83.             WN.Close()
  84.             WN = Nothing
  85.         End Try
  86.     End Sub
  87. #End Region
  88. #Region "Altro"
  89.     Public Function GetExtension(ByVal name As String) As String
  90.         Dim s As String = ""
  91.         Dim i, a As Int16
  92.  
  93.         For i = 0 To name.Length - 1
  94.             If name.Chars(i) = "." Then
  95.                 a = i + 1
  96.             End If
  97.         Next
  98.         For i = a To name.Length - 1
  99.             s = s & name.Chars(i)
  100.         Next
  101.         GetExtension = s
  102.     End Function
  103.     Public Function GetName(ByVal name As String) As String
  104.         Dim s As String = ""
  105.         Dim i, LastBS, LastDot As Int16
  106.  
  107.         For i = 0 To name.Length - 1
  108.             If name.Chars(i) = "\" Then
  109.                 LastBS = i + 1
  110.             End If
  111.             If name.Chars(i) = "." Then
  112.                 LastDot = i
  113.             End If
  114.         Next
  115.         For i = LastBS To LastDot - 1
  116.             s = s & name.Chars(i)
  117.         Next
  118.         GetName = s
  119.     End Function
  120.     Public Sub ControlDownload()
  121.         If GetExtension(txtURL.Text) = "zip" Then
  122.             Dim down As New Web_Browser_2.frmDownload
  123.             down.lstDown.Items.Add(txtURL.Text)
  124.             down.DList(down.lstDown.Items.Count - 1).URL = txtURL.Text
  125.             down.DList(down.lstDown.Items.Count - 1).path = "C:\Documents and settings\Proprietario\Documenti\" & GetName(txtURL.Text) & "." & GetExtension(txtURL.Text)
  126.             down.Show()
  127.         End If
  128.     End Sub
  129.     Public Sub LoadMotors()
  130.         'Carica i motori di ricerca
  131.         Dim readh As IO.StreamReader
  132.         Dim M As Motor
  133.  
  134.         Motors = New ArrayList
  135.         readh = New IO.StreamReader(Application.StartupPath & "\Motors.dat")
  136.  
  137.         While Not ReadH.EndOfStream
  138.             M.Name = readh.ReadLine
  139.             M.URL = readh.ReadLine
  140.             Motors.Add(M)
  141.             IperSearch.DropDownItems.Add(M.Name)
  142.         End While
  143.  
  144.         ReadH.Close()
  145.         ReadH = Nothing
  146.     End Sub
  147.     Public Sub LoadForbiddens()
  148.         'Carica i siti proibiti
  149.         Dim readh As IO.StreamReader
  150.         Dim M As String
  151.  
  152.         Forbiddens = New ArrayList
  153.         readh = New IO.StreamReader(Application.StartupPath & "\Forbiddens.dat")
  154.  
  155.         While Not readh.EndOfStream
  156.             M = Decrypt(readh.ReadLine)
  157.             Forbiddens.Add(M)
  158.         End While
  159.  
  160.         readh.Close()
  161.         readh = Nothing
  162.     End Sub
  163.     Public Shared Sub AddForbidden(ByVal NewText As String)
  164.         Dim WTemp As New IO.StreamWriter("Temp.txt")
  165.         Dim RFile As New IO.StreamReader(Application.StartupPath + "\Forbiddens.dat")
  166.  
  167.         While Not RFile.EndOfStream
  168.             WTemp.WriteLine(RFile.ReadLine)
  169.         End While
  170.         WTemp.Write(NewText)
  171.  
  172.         WTemp.Close()
  173.         WTemp = Nothing
  174.         RFile.Close()
  175.         RFile = Nothing
  176.  
  177.         FileCopy("Temp.txt", Application.StartupPath + "\Forbiddens.dat")
  178.         Kill("Temp.txt")
  179.     End Sub
  180.     Public Sub Append(ByVal File As String, ByVal NewText As String)
  181.         Dim WTemp As New IO.StreamWriter("Temp.txt")
  182.         Dim RFile As New IO.StreamReader(File)
  183.  
  184.         While Not RFile.EndOfStream
  185.             WTemp.WriteLine(RFile.ReadLine)
  186.         End While
  187.         WTemp.Write(NewText)
  188.  
  189.         WTemp.Close()
  190.         WTemp = Nothing
  191.         RFile.Close()
  192.         RFile = Nothing
  193.  
  194.         FileCopy("Temp.txt", Application.StartupPath + "\Forbiddens.dat")
  195.         Kill("Temp.txt")
  196.     End Sub
  197.     Public Function IsForbidden(ByVal Name As String) As Boolean
  198.         Dim F As String
  199.         For Each F In Forbiddens
  200.             If Name.StartsWith(F) Then
  201.                 Return True
  202.             End If
  203.         Next
  204.  
  205.         Return False
  206.     End Function
  207.     Public Function IsUrlForbidden() As Boolean
  208.         Return IsForbidden(txtURL.Text)
  209.     End Function
  210.     Public Sub CreateFile(ByVal Path As String)
  211.         Dim Wh As New IO.StreamWriter(Path)
  212.         Wh.Close()
  213.         Wh = Nothing
  214.     End Sub
  215.     Public Sub LoadChronos()
  216.         Dim R As New IO.StreamReader(ChronosFile)
  217.         Dim F As Favorite
  218.         Dim Count As Int16
  219.  
  220.         While Not R.EndOfStream
  221.             F.Name = Decrypt(R.ReadLine)
  222.             F.URL = Decrypt(R.ReadLine)
  223.  
  224.             Chronos.Add(F)
  225.             strChrono.DropDownItems.Add(F.Name)
  226.             strChrono.DropDownItems(Count).Tag = F.URL
  227.  
  228.             Count += 1
  229.         End While
  230.  
  231.         R.Close()
  232.         R = Nothing
  233.     End Sub
  234.     Public Sub AddChrono(ByVal F As Favorite)
  235.         Dim Count As Int16
  236.  
  237.         Count = Chronos.Count
  238.  
  239.         If Count > 0 Then
  240.             If Chronos(Count - 1).Name = F.Name Then
  241.                 Exit Sub
  242.             End If
  243.         End If
  244.  
  245.         If Count < LastAddress Then
  246.             Chronos.Add(F)
  247.             strChrono.DropDownItems.Add(F.Name)
  248.             strChrono.DropDownItems(Count).Tag = F.URL
  249.         Else
  250.             Chronos.RemoveAt(0)
  251.             Chronos.Add(F)
  252.             strChrono.DropDownItems.Add(F.Name)
  253.             strChrono.DropDownItems(Count).Tag = F.URL
  254.         End If
  255.     End Sub
  256.     Public Shared Sub RefreshChronos()
  257.         Dim F As Favorite
  258.         Dim Count As Int16
  259.  
  260.         frmBrowser.strChrono.DropDownItems.Clear()
  261.  
  262.         For Each F In Chronos
  263.             frmBrowser.strChrono.DropDownItems.Add(F.Name)
  264.             frmBrowser.strChrono.DropDownItems(Count).Tag = F.URL
  265.             Count += 1
  266.         Next
  267.     End Sub
  268.     Public Function Encrypt(ByVal S As String) As String
  269.         Dim I As Int64
  270.         Dim Cifra As Int16
  271.         Dim Temp As String = ""
  272.  
  273.         For I = 0 To S.Length - 1
  274.             Cifra = Val(CType(I, String).Chars(CType(I, String).Length - 1))
  275.             If Asc(S.Chars(I)) + Cifra < 255 Then
  276.                 Temp += Chr(Asc(S.Chars(I)) + Cifra)
  277.             Else
  278.                 Temp += S.Chars(I)
  279.             End If
  280.         Next
  281.  
  282.         Return Temp
  283.     End Function
  284.     Public Function Decrypt(ByVal S As String) As String
  285.         Dim I As Int64
  286.         Dim Cifra As Int16
  287.         Dim Temp As String = ""
  288.  
  289.         For I = 0 To S.Length - 1
  290.             Cifra = Val(CType(I, String).Chars(CType(I, String).Length - 1))
  291.             If Asc(S.Chars(I)) - Cifra < 0 Then
  292.                 Temp += S.Chars(I)
  293.             Else
  294.                 Temp += Chr(Asc(S.Chars(I)) - Cifra)
  295.             End If
  296.         Next
  297.  
  298.         Return Temp
  299.     End Function
  300. #End Region
  301. #End Region
  302.     Private Sub frmBrowser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  303.         Try
  304.             Dim ReadH As New IO.StreamReader(Application.StartupPath & "\Settings.dat")
  305.             txtURL.Text = Decrypt(ReadH.ReadLine)
  306.             Forbpassword = Decrypt(ReadH.ReadLine)
  307.             ChronoEnabled = Decrypt(ReadH.ReadLine)
  308.             LastAddress = Decrypt(ReadH.ReadLine)
  309.             strActivate.Checked = ChronoEnabled
  310.             ReadH.Close()
  311.             ReadH = Nothing
  312.  
  313.             'Carica l'HomePage
  314.             HomePage = txtURL.Text
  315.             WebBrowser.Navigate(New Uri(txtURL.Text))
  316.             'Carica i preferiti
  317.             LoadFavorites()
  318.             'Carica i motori di ricerca
  319.             LoadMotors()
  320.             'Carica i siti proibiti
  321.             LoadForbiddens()
  322.  
  323.             If ChronoEnabled Then
  324.                 'Carica la cronologia
  325.                 LoadChronos()
  326.                 strActivate.Text = "Attiva (max " & LastAddress & " url)"
  327.             Else
  328.                 strChrono.DropDownItems.Add("[Cronologia disattivata]")
  329.             End If
  330.         Catch ex As IO.FileNotFoundException
  331.             Dim NewReadH As New IO.StreamWriter(HomePageFile)
  332.             NewReadH.WriteLine("http://www.pierotofy.it")
  333.             NewReadH.Close()
  334.             NewReadH = Nothing
  335.             WebBrowser.Navigate(New Uri("http://www.pierotofy.it"))
  336.         End Try
  337.  
  338.         AddHandler FavoritesButton.DropDownItemClicked, AddressOf OpenFavorites
  339.         AddHandler strRemove.DropDownItemClicked, AddressOf FavoritesOption
  340.         AddHandler IperSearch.DropDownItemClicked, AddressOf ChargeMotor
  341.         AddHandler strChrono.DropDownItemClicked, AddressOf OpenChrono
  342.     End Sub
  343.     Private Sub ToolStripButton9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton9.Click, VaiToolStripMenuItem.Click
  344.         On Error Resume Next
  345.  
  346.         If IsUrlForbidden() Then
  347.             MsgBox("Il sito appartiene alla categoria dei siti bloccati dal browser. Per modificare le impostazioni, vedere la voce Strumenti->Blocco dei siti.", MsgBoxStyle.Exclamation, "403 - Forbidden")
  348.             Exit Sub
  349.         End If
  350.  
  351.         WebBrowser.Navigate(New Uri(txtURL.Text))
  352.     End Sub
  353.     Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click, IndietroToolStripMenuItem.Click
  354.         On Error Resume Next
  355.         WebBrowser.GoBack()
  356.     End Sub
  357.     Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click, AvantiToolStripMenuItem.Click
  358.         On Error Resume Next
  359.         WebBrowser.GoForward()
  360.     End Sub
  361.     Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click, AggiornaToolStripMenuItem.Click
  362.         On Error Resume Next
  363.         StatusLabel.Text = "Aggiornamento pagina"
  364.         WebBrowser.Refresh()
  365.     End Sub
  366.     Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click, InterrompiToolStripMenuItem.Click
  367.         On Error Resume Next
  368.         StatusLabel.Text = "Interruzione operazione"
  369.         WebBrowser.Stop()
  370.     End Sub
  371.     Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click, VisualizzaSorgenteToolStripMenuItem.Click
  372.         Dim source As New Source
  373.         source.ShowDialog()
  374.     End Sub
  375.     Private Sub ToolStripButton7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton7.Click, DownloadManagerToolStripMenuItem.Click
  376.         Shell(Application.StartupPath + "\DM\DownloadManager2.exe", AppWinStyle.NormalFocus)
  377.     End Sub
  378.     Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click, BugReportToolStripMenuItem.Click
  379.         WebBrowser.Navigate("http://www.pierotofy.it/pages/conctat/writeus.php?mail=nicolo1990@yahoo.it")
  380.         txtURL.Text = "http://www.pierotofy.it/pages/conctat/writeus.php?mail=nicolo1990@yahoo.it"
  381.     End Sub
  382.     Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
  383.         Dim About As New AboutBox1
  384.         About.ShowDialog()
  385.     End Sub
  386.     Private Sub AggiungiManulamenteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AggiungiManulamenteToolStripMenuItem.Click
  387.         Dim Name, URL As String
  388.         URL = InputBox("URL della pagina da aggiungere:", "Global Web")
  389.         If URL = Nothing Then
  390.             MsgBox("E' obbligatorio inserire un indirizzo!", MsgBoxStyle.Exclamation, "Global Web")
  391.             Exit Sub
  392.         End If
  393.         Name = InputBox("Nome dell'elemento da aggiungere ai Preferiti:", "Global Web")
  394.         If Name = Nothing Then
  395.             MsgBox("E' obbligatorio inserire un nome!", MsgBoxStyle.Exclamation, "Global Web")
  396.             Exit Sub
  397.         End If
  398.  
  399.         Dim F As Favorite
  400.         F.Name = Name
  401.         F.URL = URL
  402.         AddFavorite(F)
  403.     End Sub
  404.     Private Sub AggiungiQuestaPaginaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AggiungiQuestaPaginaToolStripMenuItem.Click
  405.         Dim Name As String
  406.         StatusLabel.Text = "Aggiunta ai preferiti"
  407.         Name = InputBox("Nome dell'elemento da aggiungere ai Preferiti:", "Global Web", WebBrowser.Document.Title)
  408.  
  409.         If Name = Nothing Then
  410.             MsgBox("E' obbligatorio inserire un nome!", MsgBoxStyle.Exclamation, "Global Web")
  411.             Exit Sub
  412.         End If
  413.  
  414.         Dim F As Favorite
  415.         F.Name = Name
  416.         F.URL = txtURL.Text
  417.         AddFavorite(F)
  418.         StatusLabel.Text = WebBrowser.Document.Url.AbsolutePath
  419.     End Sub
  420.     Private Sub OpenFavorites(ByVal sender As Object, ByVal e As Windows.Forms.ToolStripItemClickedEventArgs)
  421.         txtURL.Text = e.ClickedItem.Tag
  422.         StatusLabel.Text = "Apertura pagina " & txtURL.Text & " in corso"
  423.  
  424.         If IsUrlForbidden() Then
  425.             MsgBox("Il sito appartiene alla categoria dei siti bloccati dal browser. Per modificare le impostazioni, vedere la voce Strumenti->Blocco dei siti.", MsgBoxStyle.Exclamation, "403 - Forbidden")
  426.             Exit Sub
  427.         End If
  428.  
  429.         WebBrowser.Navigate(New Uri(txtURL.Text))
  430.     End Sub
  431.     Private Sub FavoritesOption(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles strRemove.DropDownItemClicked
  432.         If MsgBox("Eliminare questa voce?", MsgBoxStyle.Question + vbYesNo, "Eliminazione") = MsgBoxResult.Yes Then
  433.             DeleteFavorites(e.ClickedItem.Text)
  434.             RefreshFavorites()
  435.         End If
  436.     End Sub
  437.     Private Sub RimuoviTuttiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RimuoviTuttiToolStripMenuItem.Click
  438.         Kill(FavoritesFile)
  439.         CreateFile(FavoritesFile)
  440.     End Sub
  441.     Private Sub CambiaManualmenteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CambiaManualmenteToolStripMenuItem.Click
  442.         Dim S As String
  443.         S = InputBox("Nuova home page:")
  444.         If S <> Nothing Then
  445.             HomePage = S
  446.         End If
  447.     End Sub
  448.     Private Sub SettaQuestaPaginaComeHomePageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SettaQuestaPaginaComeHomePageToolStripMenuItem.Click
  449.         If WebBrowser.Document.Url.AbsolutePath <> Nothing Then
  450.             HomePage = WebBrowser.Document.Url.AbsolutePath
  451.         End If
  452.     End Sub
  453.     Private Sub ToolStripButton10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton10.Click
  454.         On Error Resume Next
  455.  
  456.         If IsForbidden(HomePage) Then
  457.             MsgBox("Il sito appartiene alla categoria dei siti bloccati dal browser. Per modificare le impostazioni, vedere la voce Strumenti->Blocco dei siti.", MsgBoxStyle.Exclamation, "403 - Forbidden")
  458.         End If
  459.  
  460.         WebBrowser.Navigate(New Uri(HomePage))
  461.         txtURL.Text = WebBrowser.Document.Url.AbsoluteUri
  462.     End Sub
  463.     Private Sub AttaccaIlSitoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AttaccaIlSitoToolStripMenuItem.Click, AttaccaIlSitoToolStripMenuItem1.Click
  464.         Dim Attacca As New Attacca
  465.         Attacca.ShowDialog()
  466.     End Sub
  467.     Private Sub RilevaIPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RilevaIPToolStripMenuItem.Click, RilevaIPToolStripMenuItem1.Click
  468.         Try
  469.             Dim Iph As IPHostEntry
  470.             Iph = Dns.Resolve(WebBrowser.Url.Host)
  471.             MsgBox("L'Ip Del Sito " & WebBrowser.Url.Host & " è: " & Iph.AddressList(0).ToString, MsgBoxStyle.Information, "GLoBaL WeB - Show Ip")
  472.         Catch ex As System.NullReferenceException
  473.             MsgBox("Il sito deve ancora essere caricato. Attendere.", MsgBoxStyle.Exclamation, "Errore")
  474.         End Try
  475.     End Sub
  476.     Private Sub WebBrowser_Navigating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser.Navigating
  477.         StatusLabel.Text = "Apertura pagina " & e.Url.ToString & " in corso"
  478.         Me.Text = "Global Web"
  479.         ControlDownload()
  480.     End Sub
  481.     Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click
  482.         'Crea il file da stampare
  483.         Dim HTMLPage As New IO.StreamWriter("HTMLTemp.html")
  484.         HTMLPage.Write(WebBrowser.DocumentText)
  485.         HTMLPage.Close()
  486.         HTMLPage = Nothing
  487.  
  488.         Dim Proc As New Process
  489.         Proc.StartInfo.FileName = "HTMLTemp.html"
  490.         Proc.StartInfo.Verb = "Print"
  491.         Proc.Start()
  492.     End Sub
  493.     Private Sub WebBrowser_ProgressChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser.ProgressChanged
  494.         DownloadProgB.Visible = True
  495.         DownloadProgB.Value = e.CurrentProgress * 100 / e.MaximumProgress
  496.         If e.CurrentProgress = e.MaximumProgress Or e.CurrentProgress = 0 Then
  497.             DownloadProgB.Visible = False
  498.         End If
  499.     End Sub
  500.     Private Sub EseguiScansioneToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EseguiScansioneToolStripMenuItem.Click, EseguiScansioneToolStripMenuItem1.Click
  501.         Dim PortScan As New Portscan
  502.         PortScan.ShowDialog()
  503.     End Sub
  504.     Private Sub ToolStripButton8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton8.Click
  505.         WebBrowser.Navigate("http://www.insecurity.altervista.org/browser/anonymous.htm")
  506.     End Sub
  507.     Private Sub NavigazioneAnonimaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NavigazioneAnonimaToolStripMenuItem.Click
  508.         WebBrowser.Navigate("http://www.insecurity.altervista.org/browser/anonymous.htm")
  509.     End Sub
  510.     Private Sub ChargeMotor(ByVal sender As Object, ByVal e As Windows.Forms.ToolStripItemClickedEventArgs)
  511.         Dim M As Motor
  512.  
  513.         For Each M In Motors
  514.             If M.Name = e.ClickedItem.Text Then
  515.                 txtURL.Text = M.URL
  516.                 WebBrowser.Navigate(M.URL)
  517.                 Exit Sub
  518.             End If
  519.         Next
  520.     End Sub
  521.     Private Sub ToolStripButton11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  522.         Dim C As New ToolStripButton
  523.         C.Text = WebBrowser.DocumentTitle
  524.         C.Tag = txtURL.Text
  525.     End Sub
  526.     Private Sub BloccoDeiSitiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BloccoDeiSitiToolStripMenuItem.Click
  527.         Dim B As New Forbidden
  528.         B.ShowDialog()
  529.     End Sub
  530.     Private Sub txtURL_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtURL.KeyPress
  531.         If e.KeyChar = vbCrLf Then
  532.             On Error Resume Next
  533.  
  534.             If IsUrlForbidden() Then
  535.                 MsgBox("Il sito appartiene alla categoria dei siti bloccati dal browser. Per modificare le impostazioni, vedere la voce Strumenti->Blocco dei siti.", MsgBoxStyle.Exclamation, "403 - Forbidden")
  536.                 Exit Sub
  537.             End If
  538.  
  539.             WebBrowser.Navigate(New Uri(txtURL.Text))
  540.         End If
  541.     End Sub
  542.     Private Sub txtURL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtURL.Click
  543.         txtURL.SelectionStart = 0
  544.         txtURL.SelectionLength = txtURL.Text.Length
  545.     End Sub
  546.     Private Sub txtURL_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtURL.DoubleClick
  547.         txtURL.SelectionLength = 0
  548.         txtURL.SelectionStart = txtURL.GetCharIndexFromPosition(MousePosition)
  549.     End Sub
  550.     Private Sub frmBrowser_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
  551.         'Salva tutti i siti proibiti
  552.         Dim W As New IO.StreamWriter(Application.StartupPath + "\Forbiddens.dat")
  553.         Dim S As String
  554.  
  555.         For Each S In Forbiddens
  556.             W.WriteLine(Encrypt(S))
  557.         Next
  558.         W.Close()
  559.         W = Nothing
  560.  
  561.         'Salva tutti i preferiti
  562.         Dim F As Favorite
  563.         W = New IO.StreamWriter(FavoritesFile)
  564.  
  565.         For Each F In Favorites
  566.             W.WriteLine(Encrypt(F.Name))
  567.             W.WriteLine(Encrypt(F.URL))
  568.         Next
  569.         W.Close()
  570.         W = Nothing
  571.  
  572.         'Salva la cronologia
  573.         W = New IO.StreamWriter(ChronosFile)
  574.         For Each F In Chronos
  575.             W.WriteLine(Encrypt(F.Name))
  576.             W.WriteLine(Encrypt(F.URL))
  577.         Next
  578.         W.Close()
  579.         W = Nothing
  580.  
  581.         'Salva i settaggi generali
  582.         W = New IO.StreamWriter(HomePageFile)
  583.         W.WriteLine(Encrypt(HomePage))
  584.         If Forbpassword <> Nothing Then
  585.             W.WriteLine(Encrypt(Forbpassword))
  586.         End If
  587.         W.WriteLine(Encrypt(ChronoEnabled))
  588.         W.WriteLine(Encrypt(LastAddress))
  589.         W.Close()
  590.         W = Nothing
  591.     End Sub
  592.     Private Sub AttivaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strActivate.Click
  593.         ChronoEnabled = strActivate.Checked
  594.  
  595.         If Not ChronoEnabled Then
  596.             strChrono.DropDownItems.Clear()
  597.             strChrono.DropDownItems.Add("[Cronologia disattivata]")
  598.         Else
  599.             strChrono.DropDownItems.Clear()
  600.             RefreshChronos()
  601.             strActivate.Text = "Attiva (max " & LastAddress & " url)"
  602.         End If
  603.     End Sub
  604.     Private Sub MemorizzaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MemorizzaToolStripMenuItem.Click
  605.         LastAddress = InputBox("Inserire il numero massimo dei siti che verranno ricordati nella cronologia:")
  606.     End Sub
  607.     Private Sub OpenChrono(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs)
  608.         On Error Resume Next
  609.  
  610.         If IsForbidden(e.ClickedItem.Tag) Then
  611.             MsgBox("Il sito appartiene alla categoria dei siti bloccati dal browser. Per modificare le impostazioni, vedere la voce Strumenti->Blocco dei siti.", MsgBoxStyle.Exclamation, "403 - Forbidden")
  612.             Exit Sub
  613.         End If
  614.  
  615.         WebBrowser.Navigate(New Uri(e.ClickedItem.Tag))
  616.     End Sub
  617.     Private Sub WebBrowser_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser.DocumentCompleted
  618.         txtURL.Text = WebBrowser.Document.Url.ToString
  619.         StatusLabel.Text = "Pagina corrente: " + txtURL.Text
  620.  
  621.         If ChronoEnabled = True Then
  622.             Dim F As Favorite
  623.             F.Name = WebBrowser.DocumentTitle
  624.             F.URL = txtURL.Text
  625.             AddChrono(F)
  626.         End If
  627.  
  628.         WebBrowser.Focus()
  629.  
  630.         If IsUrlForbidden() Then
  631.             MsgBox("Il sito appartiene alla categoria dei siti bloccati dal browser. Per modificare le impostazioni, vedere la voce Strumenti->Blocco dei siti.", MsgBoxStyle.Exclamation, "403 - Forbidden")
  632.             WebBrowser.Navigate(New Uri(HomePage))
  633.         End If
  634.     End Sub
  635.     Private Sub CancellaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CancellaToolStripMenuItem.Click
  636.         Dim C As New fmrChrono
  637.         C.ShowDialog()
  638.     End Sub
  639. End Class