frmHistory.vb
上传用户:szledliu
上传日期:2021-01-29
资源大小:13805k
文件大小:5k
源码类别:

C#编程

开发平台:

C#

  1. '///////////////////////////////////////////////////////////
  2. 'This form provided from an article found at:
  3. 'http://www.freevbcode.com/ShowCode.asp?ID=6702
  4. 'Author: Anonymous  
  5. 'The code is a little "quirky" and I did not take time to
  6. 'Clean it up, it is provided as a means of showing
  7. 'dealing with the history and cache files.
  8. '///////////////////////////////////////////////////////////
  9. Public Class frmHistory
  10.     Enum LoadModes
  11.         History = 2097153
  12.         Cache = 0
  13.     End Enum
  14.     Public LoadMode As LoadModes = LoadModes.History 'Default
  15.     Public Sub fillday2()
  16.         Dim i As Object
  17.         On Error GoTo rt
  18.         Dim sdate As Date
  19.         sdate = DateAdd(DateInterval.Day, -1, Today)
  20.         For i = 0 To 30
  21.             sdate = DateAdd(DateInterval.Day, -i, Today)
  22.             cmbDay.Items.Add(CStr(sdate))
  23.         Next i
  24.         Exit Sub
  25. rt:
  26.         MsgBox(ErrorToString())
  27.         Resume rte
  28. rte:
  29.     End Sub
  30.     Private Sub frmHistory_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  31.         Dim mtdate As Object
  32.         Dim xk As Object
  33.         Dim fdate As Object
  34.         fillday2()
  35.         fdate = cmbDay.Text
  36.         If IsDate(fdate) = False Then GoTo mm
  37.         xk = Weekday(fdate, FirstDayOfWeek.Sunday)
  38.         Select Case xk
  39.             Case 1
  40.                 mtdate = "Monday"
  41.             Case 2
  42.                 mtdate = "Sunday"
  43.             Case 3
  44.                 mtdate = "Tuesday"
  45.             Case 4
  46.                 mtdate = "Wenesday"
  47.             Case 5
  48.                 mtdate = "Thursday"
  49.             Case 6
  50.                 mtdate = "Friday"
  51.             Case 7
  52.                 mtdate = "Saturday"
  53.         End Select
  54. mm:
  55.         ListView1.Columns.Add("Item name", 350, HorizontalAlignment.Left)
  56.         ListView1.Columns.Add("Last access date", 150, HorizontalAlignment.Left)
  57.         ListView1.Columns.Add("hitrate", 50, HorizontalAlignment.Left)
  58.         ListView1.Columns.Add("last modiefied date", 100, HorizontalAlignment.Left)
  59.         ListView1.Columns.Add("last syntime", 100, HorizontalAlignment.Left)
  60.         ListView1.Columns.Add("usecount", 50, HorizontalAlignment.Left)
  61.         ListView1.Columns.Add("local file name", 300, HorizontalAlignment.Left)
  62.         ListView1.Columns.Add("File extension", 150, HorizontalAlignment.Left)
  63.         ListView1.Columns.Add("Fiel header info", 150, HorizontalAlignment.Left)
  64.         ListView1.Columns.Add("File type", 100, HorizontalAlignment.Left)
  65.         cmbDay.SelectedIndex = 0
  66.         getcachentry(LoadMode)
  67.     End Sub
  68.     Private Sub getcachentry(ByVal type As String)
  69.         Dim x As Object
  70.         Dim sdate As Date
  71.         If IsDate(cmbDay.Text) Then
  72.             sdate = DateValue(cmbDay.Text)
  73.         Else
  74.             MsgBox("No valid date choosen)")
  75.         End If
  76.         sdate = Format(sdate, "short date")
  77.         x = GetURLCache(ListView1, sdate, type)
  78.     End Sub
  79.     Private Sub cmbDay_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbDay.SelectedIndexChanged
  80.         Dim mtdate As Object
  81.         Dim xk As Object
  82.         Dim fdate As Object
  83.         Dim sdate As Date
  84.         fdate = cmbDay.Text
  85.         If IsDate(fdate) = False Then Exit Sub
  86.         xk = Weekday(fdate, FirstDayOfWeek.Sunday)
  87.         Select Case xk
  88.             Case 1
  89.                 mtdate = "Monday"
  90.             Case 2
  91.                 mtdate = "Sunday"
  92.             Case 3
  93.                 mtdate = "Tuesday"
  94.             Case 4
  95.                 mtdate = "Wenesday"
  96.             Case 5
  97.                 mtdate = "Thursday"
  98.             Case 6
  99.                 mtdate = "Friday"
  100.             Case 7
  101.                 mtdate = "Saturday"
  102.         End Select
  103.         sdate = DateValue(cmbDay.Text)
  104.         getcachentry(LoadMode)
  105.     End Sub
  106.     Private Sub cmbDay_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbDay.TextChanged
  107.     End Sub
  108.     Private Sub cmbDay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbDay.Click
  109.     End Sub
  110.     Private Sub ListView1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDoubleClick
  111.         Dim strURL As String
  112.         If ListView1.SelectedIndices.Count > 0 Then
  113.             Dim li As ListViewItem = ListView1.SelectedItems(0)
  114.             Select Case Me.LoadMode
  115.                 Case LoadModes.Cache
  116.                     strURL = li.Text
  117.                 Case LoadModes.History
  118.                     Dim s() As String = Split(li.Text, "@")
  119.                     strURL = s(1)
  120.             End Select
  121.             Dim ofrm As frmBrowser
  122.             Dim i As Integer
  123.             For i = 0 To AppManager.MainForm.tc1.TabPages.Count - 1
  124.                 If TypeOf AppManager.MainForm.tc1.TabPages(i).Form Is frmBrowser Then
  125.                     ofrm = AppManager.MainForm.tc1.TabPages(i).Form
  126.                     If ofrm.wb Is AppManager.CurrentBrowser Then
  127.                         AppManager.CurrentBrowser.Navigate(strURL)
  128.                         AppManager.MainForm.tc1.TabPages(i).Select()
  129.                         Exit Sub
  130.                     End If
  131.                 End If
  132.             Next
  133.         End If
  134.     End Sub
  135. End Class