📄 frmbrowser.vb
字号:
'Here we will just use the blocked sites list
'as an example of what to do
'///////////////////////////////////////////////////////////
Dim BadLink As Boolean = False
Dim oEl As HtmlElement
Dim s As String
Dim li As ListItem
Dim ofrm As New frmPhising
For Each oEl In oDoc.Links
For Each s In My.Settings.PhishingSites
If InStr(oEl.GetAttribute("HREF"), s) Then
li = New ListItem
li.Text = oEl.GetAttribute("HREF")
ofrm.lbPhishing.Items.Add(li)
BadLink = True
End If
Next
Next
If BadLink = True Then
ofrm.ShowDialog()
Else
ofrm.Dispose()
End If
End Sub
Private Sub DetectFeeds()
Try
Dim oEl As HtmlElement
For Each oEl In wb.Document.All
If oEl.GetAttribute("Type") = "application/rss+xml" Then
NumFeeds = NumFeeds + 1
End If
Next
If NumFeeds = 0 Then
AppManager.MainForm.mnuFeeds.Enabled = False
Else
AppManager.MainForm.mnuFeeds.Enabled = True
End If
Catch ex As Exception
NumFeeds = 0
AppManager.MainForm.mnuFeeds.Enabled = False
End Try
End Sub
#End Region
#Region " Context Menu "
Private Sub mnuImageSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuImageSave.Click
Dim opb As New PictureBox
Dim sfd As New SaveFileDialog
Try
Dim odir As String = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)
sfd.InitialDirectory = odir.ToString
Dim ofile() As String = Split(oElement.GetAttribute("src"), "/")
sfd.Title = "Save web image"
sfd.FileName = ofile(UBound(ofile)).ToString
If sfd.ShowDialog() = Windows.Forms.DialogResult.OK Then
If sfd.FileName = String.Empty Then
Exit Sub
Else
AppManager.LoadWebImageToPictureBox(opb, oElement.GetAttribute("src"))
opb.Image.Save(sfd.FileName, Imaging.ImageFormat.Gif)
End If
End If
Catch ex As Exception
Dim ofrm As New frmError
ofrm.err = ex
ofrm.ShowDialog()
Finally
opb.Dispose()
sfd.Dispose()
End Try
End Sub
Private Sub ContextMenuStrip1_Opening(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening
If Not IsNothing(oElement) Then
If oElement.TagName = "IMG" Then
mnuImage.Enabled = True
Else
mnuImage.Enabled = False
End If
If oElement.TagName = "A" Then
mnuLink.Enabled = True
Else
mnuLink.Enabled = False
End If
End If
mnuBack.Enabled = AppManager.CurrentBrowser.CanGoBack
mnuForward.Enabled = AppManager.CurrentBrowser.CanGoForward
End Sub
Private Sub ElemToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ElemToolStripMenuItem.Click
ShowProps()
End Sub
Private Sub mnuLinkNewTab_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuLinkNewTab.Click
Dim ofrm As New frmBrowser
AppManager.AddTab(ofrm, oElement.GetAttribute("HREF"))
End Sub
Private Sub mnuImageProperties_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuImageProperties.Click
ShowProps()
End Sub
Private Sub ShowProps()
Dim ofrm As New frmProperties
ofrm.obj = oElement
ofrm.Show()
End Sub
Private Sub PrToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrToolStripMenuItem.Click
ShowProps()
End Sub
Private Sub PropertiesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PropertiesToolStripMenuItem.Click
AppManager.CurrentBrowser.ShowPropertiesDialog()
End Sub
Private Sub mnuPageSaveAs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPageSaveAs.Click
AppManager.CurrentBrowser.ShowSaveAsDialog()
End Sub
Private Sub mnuPageToDesktop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPageToDesktop.Click
Try
AppManager.CurrentBrowser.SendToDesktop()
Catch ex As Exception
MessageBox.Show("An error occured saving to desktop" & vbCrLf & _
"There seems to be an issue if you have Internet Explorer 7 installed.", _
My.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub AdToFavoritesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AdToFavoritesToolStripMenuItem.Click
AppManager.CurrentBrowser.AddToFavorites()
End Sub
Private Sub mnuPagePrintSetup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPagePrintSetup.Click
AppManager.CurrentBrowser.ShowPageSetupDialog()
End Sub
Private Sub mnuPagePrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPagePrint.Click
AppManager.CurrentBrowser.ShowPrintDialog()
End Sub
Private Sub mnuPagePrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPagePrintPreview.Click
AppManager.CurrentBrowser.ShowPrintPreviewDialog()
End Sub
Private Sub mnuCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCopy.Click
AppManager.CurrentBrowser.Document.ExecCommand("Copy", False, System.DBNull.Value)
End Sub
Private Sub mnuPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPaste.Click
AppManager.CurrentBrowser.Document.ExecCommand("Paste", False, System.DBNull.Value)
End Sub
Private Sub mnuCopyLink_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCopyLink.Click
Clipboard.SetText(oElement.GetAttribute("HREF"))
End Sub
Private Sub mnuViewImageNewTab_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuViewImageNewTab.Click
Dim ofrm As New frmBrowser
AppManager.AddTab(ofrm, oElement.GetAttribute("src"))
End Sub
Private Sub mnuFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFind.Click
AppManager.CurrentBrowser.ShowFindDialog()
End Sub
Private Sub wb_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles wb.ProgressChanged
If AppManager.CurrentBrowser Is Me.wb Then
AppManager.MainForm.lblStatus.Text = wb.StatusText
AppManager.MainForm.pBar.Value = ((e.CurrentProgress / e.MaximumProgress) * 100)
End If
End Sub
Private Sub mnuImageCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuImageCopy.Click
Dim opb As New PictureBox
AppManager.LoadWebImageToPictureBox(opb, oElement.GetAttribute("src"))
Clipboard.SetImage(opb.Image)
opb.Dispose()
End Sub
Private Sub mnuShowRuler_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuShowRuler.Click
Ruler1.Visible = mnuShowRuler.Checked
End Sub
Private Sub mnuShowLabels_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuShowLabels.Click
Ruler1.DrawLabels = mnuShowLabels.Checked
End Sub
Private Sub muShowBorder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles muShowBorder.Click
Ruler1.ShowBorder = muShowBorder.Checked
End Sub
Private Sub mnuTopOnly_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuTopOnly.Click
Ruler1.DrawMode = Ruler.DrawModes.TopOnly
mnuBottomOnly.Checked = False
mnuTopandBottom.Checked = False
End Sub
Private Sub mnuBottomOnly_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuBottomOnly.Click
Ruler1.DrawMode = Ruler.DrawModes.BottomOnly
mnuTopOnly.Checked = False
mnuTopandBottom.Checked = False
End Sub
Private Sub mnuTopandBottom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuTopandBottom.Click
Ruler1.DrawMode = Ruler.DrawModes.TopAndBottom
mnuTopOnly.Checked = False
mnuBottomOnly.Checked = False
End Sub
Private Sub mnuLeftToRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuLeftToRight.Click
AppManager.MainForm.mnuLeftToRight.PerformClick()
mnuRightToLeft.Checked = False
End Sub
Private Sub mnuRightToLeft_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuRightToLeft.Click
AppManager.MainForm.mnuRightToLeft.PerformClick()
mnuLeftToRight.Checked = False
End Sub
Private Sub mnuPage_DropDownOpening(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuPage.DropDownOpening
Select Case wb.Document.RightToLeft
Case True
mnuLeftToRight.Checked = False
mnuRightToLeft.Checked = True
Case False
mnuLeftToRight.Checked = True
mnuRightToLeft.Checked = False
End Select
End Sub
Private Sub mnuPopTempAllow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPopTempAllow.Click
Me.TempPopAllowed = True
InfoBar1.Text = "Popups Temporarily allowed."
InfoBar1.PictureBox1.Image = My.Resources.popallowed
If Me.popURL = "" Then
'Nothing to do
Else
Dim oFrm As New frmBrowser
AppManager.AddTab(oFrm, popURL)
InfoBar1.Visible = False
End If
End Sub
Private Sub mnuPopAllowthissite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPopAllowthissite.Click
My.Settings.AllowedPopSites.Add(wb.Document.Domain)
End Sub
Private Sub mnuPopBlockEnabled_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPopBlockEnabled.Click
My.Settings.PopUpBlockerEnabled = mnuPopBlockEnabled.Checked
End Sub
Private Sub mnuPopShowInfoBar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPopShowInfoBar.Click
My.Settings.PopInfoBar = mnuPopShowInfoBar.Checked
End Sub
Private Sub mnuPopMoreSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPopMoreSettings.Click
Dim ofrm As New frmSettings
ofrm.TabControl1.SelectedIndex = 0
ofrm.ShowDialog(AppManager.MainForm)
End Sub
Private Sub cmiInfoBar_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles cmiInfoBar.Opening
Select Case My.Settings.PopUpBlockerEnabled
Case True
mnuPopBlockEnabled.Text = "Pop up Blocker Enabled."
Case False
mnuPopBlockEnabled.Text = "Pop up Blocker Disabled."
End Select
mnuPopBlockEnabled.Checked = My.Settings.PopUpBlockerEnabled
mnuPopShowInfoBar.Checked = My.Settings.PopInfoBar
End Sub
Private Sub mnuPageNewTab_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPageNewTab.Click
Dim ofrm As New frmBrowser
AppManager.AddTab(ofrm, wb.Document.Url.ToString)
End Sub
Private Sub SaveAsImageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveAsImageToolStripMenuItem.Click
Dim ofrm As New frmImage
Dim op2i As New Page2Image
ofrm.pb.Image = op2i.CapturePage(wb.Document)
ofrm.Show()
End Sub
Private Sub mnuSaveAllImages_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSaveAllImages.Click
Dim ofrm As New frmScrapeImages
ofrm.ShowDialog(AppManager.MainForm)
End Sub
#End Region
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -