投稿者 Public   (社会人) 投稿日時 2012/1/25 14:24:16
= New HistoryList With {.day = Today.AddDays(-1)}
        End If
    End Sub
    Inherits TreeNode
    Public Property History As History
End ClassPublic Class Form1
    Private TodayHistoryList As New HistoryList
    Private YesterDayHistoryList As New HistoryList
    Private ParentToday, ParentYesterDay As TreeNode

    Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        TodayHistoryList.WriteFile()
        YesterDayHistoryList.WriteFile()
    End Sub
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'TreeViewの初期化 
        InitTreeView()

        '今日 
        TodayHistoryList = HistoryList.ReadFile(Today)
        If Not IsNothing(TodayHistoryList) Then
            TodayHistoryList.TreeViewColumnsAdd(ParentToday)
        Else
            TodayHistoryList = New HistoryList
        End If

        '昨日 
        YesterDayHistoryList = HistoryList.ReadFile(Today.AddDays(-1))
        If Not IsNothing(YesterDayHistoryList) Then
            YesterDayHistoryList.TreeViewColumnsAdd(ParentYesterDay)
        Else
            YesterDayHistoryList = New HistoryList With {.day = Today.AddDays(-1)}
        End If
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(sender As System.Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        Dim NowDate As Date = Today
        '現在の日付と今日の日付が違う場合(日付が変更された) 
        If NowDate <> TodayHistoryList.day Then
            YesterDayHistoryList.WriteFile()
            TodayHistoryList.WriteFile()
            Call Form1_Load(Nothing, Nothing)
        End If

        TodayHistoryList.TreeViewHistoryListColumnAdd(ParentToday, New History With {.Title = WebBrowser1.DocumentTitle,
                                                    .URL = WebBrowser1.Url.AbsoluteUri,
                                                    .ViewDate = Now})
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate(TextBox1.Text)
    End Sub
    Private Sub InitTreeView()
        TreeView1.Nodes.Clear()
        ParentToday = New TreeNode("今日")
        ParentYesterDay = New TreeNode("昨日")
        TreeView1.Nodes.Add(ParentToday)
        TreeView1.Nodes.Add(ParentYesterDay)
    End Sub

    Private Sub TreeView1_DoubleClick(sender As System.Object, e As System.EventArgs) Handles TreeView1.DoubleClick
        WebBrowser1.Navigate(DirectCast(TreeView1.SelectedNode, HistoryTreeViewNode).History.URL)
    End Sub
End Class
Public Class HistoryTreeViewNode
    Inherits TreeNode
    Public Property History As History
End Class