codeXecutable

Web Browser

Oct 6th, 2013
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 6.69 KB | None | 0 0
  1. Form 1
  2.  
  3.  
  4. Imports System.Net
  5. Imports System.IO
  6.  
  7. Public Class frmVortex
  8.  
  9.     Private Declare Sub keybd_event Lib "user32" (ByVal volumeUpOrDown As Byte, ByVal v1 As Byte, ByVal v2 As Integer, ByVal v3 As Integer)
  10.  
  11.     Private Sub frmVortex_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  12.  
  13.         For Each link As String In History.lstHistory.Items
  14.             File.AppendAllText("F:\Vortex\history.txt", link & vbNewLine)
  15.         Next
  16.  
  17.  
  18.     End Sub
  19.  
  20.     Private Sub frmVortex_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  21.         cmbSearchEngines.Items.Add("Google")
  22.         cmbSearchEngines.Items.Add("YouTube")
  23.         cmbSearchEngines.Items.Add("Wikipedia")
  24.  
  25.         cmbSearchEngines.SelectedIndex = 0
  26.  
  27.         If My.Settings.HomePageOrBlankPage = 0 Then
  28.             WebBrowser1.Navigate(My.Settings.homePage)
  29.         Else
  30.         End If
  31.  
  32.         Try
  33.             History.Show()
  34.  
  35.             For Each link As String In File.ReadAllLines("F:\Vortex\history.txt")
  36.                 History.lstHistory.Items.Add(link.ToString)
  37.             Next
  38.  
  39.             History.Visible = False
  40.         Catch ex As Exception
  41.  
  42.         End Try
  43.     End Sub
  44.  
  45.     Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click
  46.         WebBrowser1.GoBack()
  47.     End Sub
  48.  
  49.     Private Sub btnForward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnForward.Click
  50.         WebBrowser1.GoForward()
  51.     End Sub
  52.  
  53.     Private Sub btnReload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReload.Click
  54.         WebBrowser1.Refresh()
  55.     End Sub
  56.  
  57.     Private Sub txtUrl_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtUrl.KeyUp
  58.         If e.KeyCode = Keys.Enter Then
  59.             WebBrowser1.Navigate(txtUrl.Text)
  60.         End If
  61.     End Sub
  62.  
  63.     Private Sub webIcons()
  64.         Dim wc As New WebClient
  65.         Dim memorystream As New MemoryStream(wc.DownloadData("http://" & New Uri(WebBrowser1.Url.ToString).Host & "/favicon.ico"))
  66.  
  67.         Try
  68.             Dim icon As New Icon(memorystream)
  69.         Catch ex As Exception
  70.         End Try
  71.  
  72.  
  73.         If ImageList1.Images.Count = -1 Then
  74.             ImageList1.Images.Add(icon.ToBitmap)
  75.             TabControl1.SelectedTab.ImageIndex = 0
  76.         Else
  77.             ImageList1.Images.Clear()
  78.             ImageList1.Images.Add(icon.ToBitmap)
  79.             TabControl1.SelectedTab.ImageIndex = 0
  80.         End If
  81.     End Sub
  82.  
  83.     Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
  84.         txtUrl.Text = WebBrowser1.Url.ToString
  85.         webIcons()
  86.  
  87.         TabControl1.SelectedTab.Text = WebBrowser1.DocumentTitle.ToString
  88.  
  89.         History.lstHistory.Items.Add(txtUrl.Text)
  90.     End Sub
  91.  
  92.     Private Sub txtUrlSearchEngines_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtUrlSearchEngines.KeyUp
  93.         Select Case (cmbSearchEngines.SelectedIndex)
  94.             Case 0
  95.                 If e.KeyCode = Keys.Enter Then
  96.                     WebBrowser1.Navigate("https://www.google.com/#q=" + txtUrlSearchEngines.Text)
  97.                 End If
  98.             Case 1
  99.                 If e.KeyCode = Keys.Enter Then
  100.                     WebBrowser1.Navigate("http://www.youtube.com/results?search_query=" + txtUrlSearchEngines.Text)
  101.                 End If
  102.             Case 2
  103.                 If e.KeyCode = Keys.Enter Then
  104.                     WebBrowser1.Navigate("http://en.wikipedia.org/wiki/" + txtUrlSearchEngines.Text)
  105.                 End If
  106.         End Select
  107.     End Sub
  108.  
  109.     Private Sub btnHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHome.Click
  110.         WebBrowser1.Navigate(My.Settings.homePage)
  111.     End Sub
  112.  
  113.     Private Sub btnVolumUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVolumUp.Click
  114.         Call keybd_event(System.Windows.Forms.Keys.VolumeUp, 0, 0, 0)
  115.     End Sub
  116.  
  117.     Private Sub btnVolumeDown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVolumeDown.Click
  118.         Call keybd_event(System.Windows.Forms.Keys.VolumeDown, 0, 0, 0)
  119.     End Sub
  120.  
  121.     Private Sub OptionsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptionsToolStripMenuItem.Click
  122.         frmProperties.Show()
  123.     End Sub
  124.  
  125.     Private Sub tmrDate_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrDate.Tick
  126.         lblDate.Text = Now
  127.     End Sub
  128.  
  129.     Private Sub HistoryToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HistoryToolStripMenuItem.Click
  130.         History.Visible = True
  131.     End Sub
  132.  
  133.  
  134.     Private Sub txtUrl_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtUrl.TextChanged
  135.         txtUrl.AutoCompleteCustomSource.Clear()
  136.         For i As Integer = 0 To History.lstHistory.Items.Count - 1
  137.             txtUrl.AutoCompleteCustomSource.Add(History.lstHistory.Items(i))
  138.         Next
  139.     End Sub
  140. End Class
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148. frmProperties
  149.  
  150.  
  151. Public Class frmProperties
  152.  
  153.     Private Sub frmProperties_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  154.         txtHomePage.Text = My.Settings.homePage
  155.  
  156.         If My.Settings.HomePageOrBlankPage = 0 Then
  157.             cmbStartUp.SelectedIndex = 0
  158.         ElseIf My.Settings.HomePageOrBlankPage = 1 Then
  159.             cmbStartUp.SelectedIndex = 1
  160.         End If
  161.  
  162.        
  163.     End Sub
  164.  
  165.     Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
  166.         My.Settings.homePage = txtHomePage.Text
  167.         My.Settings.Save()
  168.         My.Settings.Reload()
  169.  
  170.         My.Settings.HomePageOrBlankPage = cmbStartUp.SelectedIndex.ToString
  171.         My.Settings.Save()
  172.         My.Settings.Reload()
  173.     End Sub
  174. End Class
  175.  
  176.  
  177.  
  178. History form
  179.  
  180.  
  181. Imports System.IO
  182.  
  183. Public Class History
  184.  
  185.  
  186.  
  187.     Private Sub History_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  188.         e.Cancel = True
  189.         Me.Visible = False
  190.     End Sub
  191.  
  192.     Private Sub btnDeleteAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteAll.Click
  193.         lstHistory.Items.Clear()
  194.         File.Delete("F:\vortex\history.txt")
  195.     End Sub
  196.  
  197.     Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
  198.         Me.Visible = False
  199.     End Sub
  200. End Class
Advertisement
Add Comment
Please, Sign In to add comment