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

Form1.vb

Caricato da: Progman-92
Scarica il programma completo

  1. Imports System
  2. Imports System.IO
  3. Imports System.Net
  4. Public Class Form1
  5.     Public HomePageFile As String = Application.StartupPath & "\Impostazioni.dat"
  6.     Public HomePage As String
  7.  
  8.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  9.         Try
  10.             Dim ReadH As New IO.StreamReader(Application.StartupPath & "\Impostazioni.dat")
  11.             Me.ToolStripComboBox1.Text = ReadH.ReadLine
  12.             ReadH.Close()
  13.             ReadH = Nothing
  14.             Me.WebBrowser1.Navigate(New Uri(ToolStripComboBox1.Text))
  15.             HomePage = ToolStripComboBox1.Text
  16.         Catch ex As IO.FileNotFoundException
  17.             Dim NewReadH As New IO.StreamWriter(HomePageFile)
  18.             NewReadH.WriteLine("http://www.pierotofy.it/")
  19.             NewReadH.Close()
  20.             NewReadH = Nothing
  21.             Me.WebBrowser1.Navigate(New Uri("http://www.pierotofy.it/"))
  22.         End Try
  23.     End Sub
  24.  
  25.     Private Sub Time_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
  26.         Me.Stato.Text = Me.WebBrowser1.StatusText
  27.     End Sub
  28.  
  29.     Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
  30.         Me.WebBrowser1.Navigate(ToolStripComboBox1.Text)
  31.     End Sub
  32.  
  33.     Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
  34.         Me.WebBrowser1.Navigate(My.Settings.homepage)
  35.     End Sub
  36.  
  37.     Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
  38.         Me.WebBrowser1.GoBack()
  39.     End Sub
  40.  
  41.     Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
  42.         Me.WebBrowser1.GoForward()
  43.     End Sub
  44.     Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
  45.         Me.Stato.Text = "Aggiorna pagina"
  46.         Me.WebBrowser1.Refresh()
  47.     End Sub
  48.     Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
  49.         Me.Stato.Text = "Interrompi pagina"
  50.         Me.WebBrowser1.Stop()
  51.     End Sub
  52.  
  53.     Private Sub ToolStripButton7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton7.Click
  54.         WebBrowser1.Navigate(My.Settings.newspage)
  55.     End Sub
  56.  
  57.     Private Sub ToolStripButton8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton8.Click
  58.         Me.WebBrowser1.ShowPropertiesDialog()
  59.     End Sub
  60.  
  61.     Private Sub ToolStripButton9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton9.Click
  62.         If ToolStripTextBox2.Text = Nothing Then
  63.             MessageBox.Show("Impossibile ricercare una chiave di ricerca vuota", "Ricerca", MessageBoxButtons.OK, MessageBoxIcon.Warning)
  64.             Exit Sub
  65.         End If
  66.         Me.WebBrowser1.Navigate("http://www.google.it/search?hl=it&q=" & ToolStripTextBox2.Text.ToString)
  67.     End Sub
  68.  
  69.     Private Sub ToolStripComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ToolStripComboBox1.KeyPress
  70.         If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
  71.             e.Handled = True
  72.             Me.WebBrowser1.Navigate(ToolStripComboBox1.Text)
  73.         End If
  74.         Me.ToolStripComboBox1.Items.Add(WebBrowser1.Url.ToString)
  75.     End Sub
  76.  
  77.     Private Sub AvantiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AvantiToolStripMenuItem.Click
  78.         Me.WebBrowser1.GoForward()
  79.     End Sub
  80.  
  81.     Private Sub IndietroToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IndietroToolStripMenuItem.Click
  82.         Me.WebBrowser1.GoBack()
  83.     End Sub
  84.  
  85.     Private Sub StopToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StopToolStripMenuItem.Click
  86.         Me.Stato.Text = "Interrompi pagina"
  87.         Me.WebBrowser1.Stop()
  88.     End Sub
  89.  
  90.     Private Sub AggiornaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AggiornaToolStripMenuItem.Click
  91.         Me.Stato.Text = "Aggiornamento pagina"
  92.         Me.WebBrowser1.Refresh()
  93.     End Sub
  94.  
  95.     Private Sub SalvaConNomeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalvaConNomeToolStripMenuItem.Click
  96.         Me.WebBrowser1.ShowSaveAsDialog()
  97.     End Sub
  98.  
  99.     Private Sub AggiungiQuestaPaginaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  100.  
  101.     End Sub
  102.  
  103.     Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
  104.         Me.ToolStripProgressBar2.Value = ToolStripProgressBar2.Maximum
  105.         Dim titolo = Me.WebBrowser1.DocumentTitle.ToString & " - "
  106.         Me.Text = titolo + "Browser Internet"
  107.     End Sub
  108.  
  109.     Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
  110.         Me.Stato.Text = Me.ToolStripComboBox1.Text
  111.         Me.ToolStripComboBox1.Text = Me.WebBrowser1.Document.Url.AbsoluteUri
  112.  
  113.     End Sub
  114.  
  115.     Private Sub WebBrowser1_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser1.Navigating
  116.         Me.Stato.Text = "Navigazione in corso....."
  117.         Me.Stato.Text = "Apertura pagina " & e.Url.AbsoluteUri & " in corso....."
  118.         Me.ToolStripComboBox1.Text = Me.WebBrowser1.Url.ToString()
  119.     End Sub
  120.  
  121.     Private Sub WebBrowser1_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
  122.         Me.ToolStripProgressBar2.Minimum = 0
  123.         Me.ToolStripProgressBar2.Maximum = e.MaximumProgress
  124.         Me.ToolStripProgressBar2.Value = e.CurrentProgress
  125.         Me.Stato.Text = Me.WebBrowser1.Url.ToString
  126.     End Sub
  127.  
  128.     Private Sub SalvaConNomeToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalvaConNomeToolStripMenuItem1.Click
  129.         WebBrowser1.ShowSaveAsDialog()
  130.     End Sub
  131.  
  132.     Private Sub EsciToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EsciToolStripMenuItem.Click
  133.         Close()
  134.     End Sub
  135.  
  136.     Private Sub NToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NToolStripMenuItem.Click
  137.         WebBrowser1.Navigate(My.Settings.newspage)
  138.     End Sub
  139.  
  140.     Private Sub HomePageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HomePageToolStripMenuItem.Click
  141.         WebBrowser1.Navigate(My.Settings.homepage)
  142.     End Sub
  143.  
  144.     Private Sub ProprietaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProprietaToolStripMenuItem.Click
  145.         WebBrowser1.ShowPropertiesDialog()
  146.     End Sub
  147.  
  148.     Private Sub StampaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StampaToolStripMenuItem.Click
  149.         WebBrowser1.ShowPrintDialog()
  150.     End Sub
  151.  
  152.     Private Sub AnteprimaStampaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AnteprimaStampaToolStripMenuItem.Click
  153.         WebBrowser1.ShowPrintPreviewDialog()
  154.     End Sub
  155.  
  156.     Private Sub IToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IToolStripMenuItem.Click
  157.         WebBrowser1.ShowPageSetupDialog()
  158.     End Sub
  159.  
  160.     Private Sub ToolStripMenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem4.Click
  161.         WebBrowser1.Navigate(My.Settings.homepage)
  162.     End Sub
  163.  
  164.     Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click
  165.         WebBrowser1.Navigate(My.Settings.newspage)
  166.     End Sub
  167.  
  168.     Private Sub ToolStripMenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem9.Click
  169.         WebBrowser1.ShowPropertiesDialog()
  170.     End Sub
  171.  
  172.     Private Sub ToolStripMenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem6.Click
  173.         WebBrowser1.ShowPageSetupDialog()
  174.     End Sub
  175.  
  176.     Private Sub ToolStripMenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem7.Click
  177.         WebBrowser1.ShowPrintPreviewDialog()
  178.     End Sub
  179.  
  180.     Private Sub ToolStripMenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem8.Click
  181.         WebBrowser1.ShowPrintDialog()
  182.     End Sub
  183.  
  184.     Private Sub ToolStripButton11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton11.Click
  185.         Stato.Text = "visualizza sorgente"
  186.         Dim b As String = WebBrowser1.DocumentText.ToString
  187.         Dim c As String = WebBrowser1.Document.Title.ToString
  188.         Dim patc As String = Application.StartupPath + "\Visualizza sorgente.txt"
  189.         Dim WTemp As New IO.StreamWriter(patc)
  190.         Dim Processo As Process = New Process
  191.         WTemp.WriteLine(b)
  192.         Process.Start(patc)
  193.         WTemp.Close()
  194.     End Sub
  195.  
  196.     Private Sub VisualizzaSorgenteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VisualizzaSorgenteToolStripMenuItem.Click
  197.         Stato.Text = "visualizza sorgente"
  198.         Dim b As String = WebBrowser1.DocumentText.ToString
  199.         Dim c As String = WebBrowser1.Document.Title.ToString
  200.         Dim patc As String = Application.StartupPath + "\Visualizza sorgente.txt"
  201.         Dim WTemp As New IO.StreamWriter(patc)
  202.         Dim Processo As Process = New Process
  203.         WTemp.WriteLine(b)
  204.         Process.Start(patc)
  205.         WTemp.Close()
  206.     End Sub
  207.  
  208.     Private Sub VisualizzaSorgenteToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VisualizzaSorgenteToolStripMenuItem1.Click
  209.         Stato.Text = "visualizza sorgente"
  210.         Dim b As String = WebBrowser1.DocumentText.ToString
  211.         Dim c As String = WebBrowser1.Document.Title.ToString
  212.         Dim patc As String = Application.StartupPath + "\Visualizza sorgente.txt"
  213.         Dim WTemp As New IO.StreamWriter(patc)
  214.         Dim Processo As Process = New Process
  215.         WTemp.WriteLine(b)
  216.         Process.Start(patc)
  217.         WTemp.Close()
  218.     End Sub
  219.  
  220.     Private Sub ToolStripTextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ToolStripTextBox2.KeyPress
  221.         If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
  222.             e.Handled = True
  223.             WebBrowser1.Navigate(ToolStripTextBox2.Text)
  224.         End If
  225.     End Sub
  226.  
  227.     Private Sub InfoSuToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InfoSuToolStripMenuItem.Click
  228.         Form2.Show()
  229.     End Sub
  230. End Class