Imports System
Imports System.Net
Public Class frmBrowser
Public FavoritesFile As String = Application.StartupPath & "\Favorites.dat"
Public HomePageFile As String = Application.StartupPath & "\Settings.dat"
Public HomePage As String
Public Iph As IPHostEntry
#Region "Metodi personalizzati"
#Region "Preferiti"
Public Sub AddFavorites(ByVal NewText As String)
Dim WTemp As New IO.StreamWriter("Temp.txt")
Dim RFile As New IO.StreamReader(FavoritesFile)
While Not RFile.EndOfStream
WTemp.WriteLine(RFile.ReadLine)
End While
WTemp.Write(NewText)
WTemp.Close()
WTemp = Nothing
RFile.Close()
RFile = Nothing
FileCopy("Temp.txt", FavoritesFile)
Kill("Temp.txt")
End Sub
Public Sub DeleteFavorites(ByVal ToDel As String)
Dim WTemp As New IO.StreamWriter("Temp.txt")
Dim RFile As New IO.StreamReader(FavoritesFile)
Dim S As String
While Not RFile.EndOfStream
S = RFile.ReadLine
If S = ToDel Then
RFile.ReadLine()
Else
WTemp.WriteLine(S)
End If
End While
WTemp.Close()
WTemp = Nothing
RFile.Close()
RFile = Nothing
FileCopy("Temp.txt", FavoritesFile)
Kill("Temp.txt")
End Sub
Public Function GetURL(ByVal Name As String)
Dim RFile As New IO.StreamReader(FavoritesFile)
Dim S As String = ""
While Not RFile.EndOfStream
If RFile.ReadLine = Name Then
S = RFile.ReadLine
Exit While
End If
End While
RFile.Close()
RFile = Nothing
Return S
End Function
Public Sub RefreshFavorites()
Try
Dim Fav As New IO.StreamReader(FavoritesFile)
Dim S As String
Dim i As Int16 = 0
FavoritesButton.DropDownItems.Clear()
strRemove.DropDownItems.Clear()
While Not Fav.EndOfStream
S = Fav.ReadLine
FavoritesButton.DropDownItems.Add(S)
strRemove.DropDownItems.Add(S)
AddHandler FavoritesButton.DropDownItemClicked, AddressOf OpenFavorites
Fav.ReadLine()
i += 1
End While
Fav.Close()
Fav = Nothing
Catch ex As IO.FileNotFoundException
Dim NewFav As New IO.StreamWriter(FavoritesFile)
NewFav.Close()
NewFav = Nothing
End Try
End Sub
#End Region
#Region "Altro"
Public Function GetExtension(ByVal name As String) As String
Dim s As String = ""
Dim i, a As Int16
For i = 0 To name.Length - 1
If name.Chars(i) = "." Then
a = i + 1
End If
Next
For i = a To name.Length - 1
s = s & name.Chars(i)
Next
Getextension = s
End Function
Public Function GetName(ByVal name As String) As String
Dim s As String = ""
Dim i, LastBS, LastDot As Int16
For i = 0 To name.Length - 1
If name.Chars(i) = "\" Then
LastBS = i + 1
End If
If name.Chars(i) = "." Then
LastDot = i
End If
Next
For i = LastBS To LastDot - 1
s = s & name.Chars(i)
Next
GetName = s
End Function
Public Sub ControlDownload()
If GetExtension(txtURL.Text) = "zip" Then
Dim down As New Internet_Navigator_4.frmDownload
down.lstDown.Items.Add(txtURL.Text)
down.DList(down.lstDown.Items.Count - 1).URL = txtURL.Text
down.DList(down.lstDown.Items.Count - 1).path = "C:\Documents and settings\Proprietario\Documenti\" & GetName(txtURL.Text) & "." & GetExtension(txtURL.Text)
down.Show()
End If
End Sub
#End Region
#End Region
Private Sub frmBrowser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim ReadH As New IO.StreamReader(Application.StartupPath & "\Settings.dat")
txtURL.Text = ReadH.ReadLine
ReadH.Close()
ReadH = Nothing
WebBrowser.Navigate(New Uri(txtURL.Text))
HomePage = txtURL.Text
RefreshFavorites()
Catch ex As IO.FileNotFoundException
Dim NewReadH As New IO.StreamWriter(HomePageFile)
NewReadH.WriteLine("http://www.newspoint.altervista.org/Software_Center/")
NewReadH.Close()
NewReadH = Nothing
WebBrowser.Navigate(New Uri("http://www.newspoint.altervista.org/Software_Center/"))
End Try
End Sub
Private Sub ToolStripButton9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton9.Click, VaiToolStripMenuItem.Click
On Error Resume Next
WebBrowser.Navigate(txtURL.Text)
End Sub
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click, IndietroToolStripMenuItem.Click
On Error Resume Next
WebBrowser.GoBack()
txtURL.Text = WebBrowser.Url.AbsoluteUri
End Sub
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click, AvantiToolStripMenuItem.Click
On Error Resume Next
WebBrowser.GoForward()
txtURL.Text = WebBrowser.Url.AbsoluteUri
End Sub
Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click, AggiornaToolStripMenuItem.Click
On Error Resume Next
StatusLabel.Text = "Aggiornamento pagina"
WebBrowser.Refresh()
txtURL.Text = WebBrowser.Url.AbsolutePath
End Sub
Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click, InterrompiToolStripMenuItem.Click
On Error Resume Next
StatusLabel.Text = "Interruzione operazione"
WebBrowser.Stop()
txtURL.Text = WebBrowser.Url.AbsoluteUri
End Sub
Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click, VisualizzaSorgenteToolStripMenuItem.Click
Dim source As New Source
source.ShowDialog()
End Sub
Private Sub ToolStripButton7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton7.Click, DownloadManagerToolStripMenuItem.Click
Try
Shell("C:\Programmi\Newspoint Software\Internet Navigator 4\DownloadManager2\DownloadManager2\bin\Relase\DownloadManager2.exe", AppWinStyle.NormalFocus)
Catch FNFE As IO.FileNotFoundException
MsgBox("Probabilmente il modulo richiesto è dannegiato o non installato correttamente nel programma! Ragion per qui si avviera il modulo di riserva", MsgBoxStyle.Exclamation)
Dim Down As New frmDownload
Down.Show()
End Try
End Sub
Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click, BugReportToolStripMenuItem.Click
WebBrowser.Navigate("http://www.newspoint.altervista.org/Software_Center/")
txtURL.Text = "http://www.newspoint.altervista.org/Software_Center/"
End Sub
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
End Sub
Private Sub AggiungiManulamenteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AggiungiManulamenteToolStripMenuItem.Click
Dim Name, URL As String
URL = InputBox("URL della pagina da aggiungere:")
Name = InputBox("Nome dell'elemento da aggiungere ai Preferiti:")
AddFavorites(Name & vbCrLf & URL)
RefreshFavorites()
End Sub
Private Sub AggiungiQuestaPaginaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AggiungiQuestaPaginaToolStripMenuItem.Click
Dim Name As String
StatusLabel.Text = "Aggiunta ai preferiti"
Name = InputBox("Nome dell'elemento da aggiungere ai Preferiti:")
AddFavorites(Name & vbCrLf & txtURL.Text)
RefreshFavorites()
StatusLabel.Text = WebBrowser.Document.Url.AbsolutePath
End Sub
Private Sub OpenFavorites(ByVal sender As Object, ByVal e As Windows.Forms.ToolStripItemClickedEventArgs)
txtURL.Text = GetURL(e.ClickedItem.Text)
StatusLabel.Text = "Apertura pagina " & txtURL.Text & " in corso"
WebBrowser.Navigate(New Uri(txtURL.Text))
End Sub
Private Sub FavoritesOption(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles strRemove.DropDownItemClicked
If MsgBox("Eliminare questa voce?", MsgBoxStyle.Question + vbYesNo, "Eliminazione") = MsgBoxResult.Yes Then
DeleteFavorites(e.ClickedItem.Text)
RefreshFavorites()
End If
End Sub
Private Sub RimuoviTuttiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RimuoviTuttiToolStripMenuItem.Click
Kill(FavoritesFile)
Dim W As New IO.StreamWriter(FavoritesFile)
W.Close()
W = Nothing
RefreshFavorites()
End Sub
Private Sub CambiaManualmenteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CambiaManualmenteToolStripMenuItem.Click
Dim S As String
Dim W As New IO.StreamWriter(HomePageFile)
S = InputBox("Nuova home page:")
W.WriteLine(S)
W.Close()
W = Nothing
End Sub
Private Sub SettaQuestaPaginaComeHomePageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SettaQuestaPaginaComeHomePageToolStripMenuItem.Click
Dim W As New IO.StreamWriter(HomePageFile)
W.WriteLine(WebBrowser.Url.AbsoluteUri)
W.Close()
W = Nothing
End Sub
Private Sub ToolStripButton10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton10.Click
On Error Resume Next
WebBrowser.Navigate(New Uri(HomePage))
txtURL.Text = WebBrowser.Document.Url.AbsoluteUri
End Sub
Private Sub AttaccaIlSitoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Attacca As New Attacca
Attacca.ShowDialog()
End Sub
Private Sub RilevaIPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RilevaIPToolStripMenuItem.Click, RilevaIPToolStripMenuItem1.Click
Try
Dim Iph As IPHostEntry
Iph = Dns.Resolve(WebBrowser.Url.Host)
MsgBox("L'Ip Del Sito " & WebBrowser.Url.Host & " ・ " & Iph.AddressList(0).ToString, MsgBoxStyle.Information, "Newspoin Software Internet Navigator 3 - Show Ip")
Catch ex As System.NullReferenceException
MsgBox("Il sito deve ancora essere caricato. Attendere.", MsgBoxStyle.Exclamation, "Errore")
End Try
End Sub
Private Sub WebBrowser_Navigated(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser.Navigated
StatusLabel.Text = txtURL.Text
txtURL.Text = WebBrowser.Document.Url.AbsoluteUri
End Sub
Private Sub WebBrowser_Navigating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser.Navigating
StatusLabel.Text = "Apertura pagina " & e.Url.AbsoluteUri & " in corso"
ControlDownload()
End Sub
Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click
Dim HTMLPage As New IO.StreamWriter("http://www.newspoint.altervista.org/Software_Center/")
HTMLPage.Write(WebBrowser.DocumentText)
HTMLPage.Close()
HTMLPage = Nothing
Dim Proc As New Process
Proc.StartInfo.FileName = "http://www.newspoint.altervista.org/Software_Center/.html"
Proc.StartInfo.Verb = "Print"
Proc.Start()
End Sub
Private Sub WebBrowser_ProgressChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser.ProgressChanged
DownloadProgB.Visible = True
DownloadProgB.Value = e.CurrentProgress * 100 / e.MaximumProgress
If e.CurrentProgress = e.MaximumProgress Or e.CurrentProgress = 0 Then
DownloadProgB.Visible = False
End If
End Sub
Private Sub EseguiScansioneToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim PortScan As New Portscan
PortScan.ShowDialog()
End Sub
Private Sub ToolStripButton8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton8.Click
WebBrowser.Navigate("http://www.newspoint.altervista.org/Software_Center/")
End Sub
Private Sub NavigazioneAnonimaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NavigazioneAnonimaToolStripMenuItem.Click
WebBrowser.Navigate("http://www.newspoint.altervista.org/Software_Center/")
End Sub
Private Sub ToolStripButton11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TaskManager.Click
StatusLabel.Text = "Apertura Modulo Task Manager"
Dim Down As New Extra
Down.Show()
StatusLabel.Text = "Chiusura Modulo Completata....."
End Sub
Private Sub ShutDownBeta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShutDownBeta.Click
StatusLabel.Text = "Apertira Modulo Shut Dows Beta"
Dim Down As New Shut
Down.Show()
StatusLabel.Text = "Chiusura Modulo Completata....."
End Sub
Private Sub ToolStripButton18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton18.Click
Try
Shell("C:\Programmi\Newspoint Software\Internet Navigator 4\FTP\FTP.exe", AppWinStyle.NormalFocus)
Catch FNFE As IO.FileNotFoundException
MsgBox("Probabilmente il modulo richiesto è dannegiato o non installato correttamente nel programma!", MsgBoxStyle.Exclamation)
End Try
End Sub
Private Sub ToolStripButton16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton16.Click
WebBrowser.Navigate("http://www.mail.live.com/")
End Sub
Private Sub ToolStripButton15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton15.Click
WebBrowser.Navigate("http://www.microsoft.com/")
End Sub
Private Sub ToolStripButton13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton13.Click
WebBrowser.Navigate("http://it.babelfish.yahoo.com/")
End Sub
Private Sub ToolStripButton17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton17.Click
'txtSearch è la textbox In cui si inseriscono
'le parole da cercare
Dim Str As String = txtSearch.Text
Dim Words As New List(Of String)
'Separa il testo In base agli spazi, aggiungendo
'ogni singola parola alla lista
For Each S As String In Str.Split(" ")
If Not String.IsNullOrEmpty(S) Then
Words.Add(S)
End If
Next
'Costruisce la query
Dim Query As String = _
"hl=it&safe=off&rls=GGGL%2CGGGL%3A2006-18%2CGGGL%3Ait&q="
'Accoda le singole parole, separate da '+'
For I As Int16 = 0 To Words.Count - 1
If I > 0 Then Query &= "+"
Query &= Words(I)
Next
'Conclude la query
Query &= "&btnG=Cerca&meta="
'Effettua la ricerca
WebBrowser.Navigate("http://www.google.it/search?" & Query)
End Sub
Private Sub ToolStripButton19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton19.Click
WebBrowser.Navigate("http://newspoint.altervista.org/")
End Sub
Private Sub ToolStripButton20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton20.Click
Try
Shell("C:\Programmi\Newspoint Software\Internet Navigator 4\Update File\Download Update Center.exe", AppWinStyle.NormalFocus)
Catch FNFE As IO.FileNotFoundException
MsgBox("Probabilmente la rete è temporaneamente offline ho non configurata per l'applicazione!", MsgBoxStyle.Exclamation)
End Try
End Sub
Private Sub ToolStripButton12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton12.Click
Try
Shell("C:\Programmi\Newspoint Software\Internet Navigator 4\Mail Send\VBMOutlook.exe", AppWinStyle.NormalFocus)
Catch FNFE As IO.FileNotFoundException
MsgBox("Probabilmente la rete è temporaneamente offline ho non configurata per l'applicazione!", MsgBoxStyle.Exclamation)
End Try
End Sub
End Class