Option Strict On
Imports System.Xml
Imports System.Drawing
Public Class plan_Form2
    Inherits System.Windows.Forms.Form
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        ' この呼び出しは Windows フォーム デザイナで必要です。
        InitializeComponent()

        ' InitializeComponent() 呼び出しの後に初期化を追加します。

    End Sub

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        MyBase.Dispose(disposing)
    End Sub

    ' メモ : 以下のプロシージャは、Windows フォーム デザイナで必要です。
    'Windows フォーム デザイナを使って変更してください。  
    ' コード エディタを使って変更しないでください。
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents TreeView1 As System.Windows.Forms.TreeView
    Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Label2 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.TreeView1 = New System.Windows.Forms.TreeView
        Me.PictureBox2 = New System.Windows.Forms.PictureBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.Label2 = New System.Windows.Forms.Label
        '
        'PictureBox1
        '
        Me.PictureBox1.Location = New System.Drawing.Point(8, 32)
        Me.PictureBox1.Size = New System.Drawing.Size(70, 70)
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(0, 112)
        Me.Label1.Size = New System.Drawing.Size(80, 20)
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter
        '
        'TreeView1
        '
        Me.TreeView1.ImageIndex = -1
        Me.TreeView1.Location = New System.Drawing.Point(88, 24)
        Me.TreeView1.SelectedImageIndex = -1
        Me.TreeView1.Size = New System.Drawing.Size(136, 240)
        '
        'PictureBox2
        '
        Me.PictureBox2.Location = New System.Drawing.Point(8, 200)
        Me.PictureBox2.Size = New System.Drawing.Size(70, 70)
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(120, 272)
        Me.Button1.Text = "戻る"
        '
        'Label2
        '
        Me.Label2.Font = New System.Drawing.Font("MS UI Gothic", 11.0!, System.Drawing.FontStyle.Bold)
        Me.Label2.Location = New System.Drawing.Point(0, 8)
        Me.Label2.Size = New System.Drawing.Size(88, 20)
        Me.Label2.Text = "メインの予定"
        '
        'plan_Form2
        '
        Me.ClientSize = New System.Drawing.Size(234, 296)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.PictureBox2)
        Me.Controls.Add(Me.TreeView1)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.PictureBox1)
        Me.Text = "今日の予定"

    End Sub

#End Region
    Dim xmldoc As XmlDocument
    Dim plan_ImageName As String
    Dim openXml As String
    Dim imageNode As XmlNodeList

    Private Sub plan_Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized

        With Button1
            .BackColor = Color.Navy
            .ForeColor = Color.Gold
        End With

        With TreeView1
            .BeginUpdate()
            .Nodes.Clear()
            .Nodes.Add(New TreeNode("よてい"))
        End With
     
        myImage = New Bitmap("\Program Files\Rainman_calendar\calendar_image\image70\" & CType(imageArray(ImageNo), String))
        PictureBox1.Image = myImage
        Label1.Text = CType(titleArray(ImageNo), String)
        openXml = myYear & selectMonth & selectDate & ".xml"
        xmldoc = New XmlDocument

        xmldoc.Load("\Program Files\Rainman_calendar\data\" & openXml)

        imageNode = xmldoc.GetElementsByTagName("画像名2")
        Dim title1Node As XmlNodeList = xmldoc.GetElementsByTagName("タイトル1")
        Dim title2Node As XmlNodeList = xmldoc.GetElementsByTagName("タイトル2")

        If title1Node.Count > 0 Then
            For i As Integer = 0 To title1Node.Count - 1
                TreeView1.Nodes(0).Nodes.Add(title1Node(i).InnerText)
            Next
        End If

        If title2Node.Count > 0 Then
            For i As Integer = 0 To title2Node.Count - 1
                TreeView1.Nodes(0).Nodes(0).Nodes.Add(title2Node(i).InnerText)
            Next
        End If

        TreeView1.EndUpdate()
        'TreeView1.ExpandAll()
    End Sub

    Private Sub TreeView1_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
        Dim myImage2 As Image
        If TreeView1.SelectedNode.Text <> "よてい" Then
            myImage2 = New Bitmap("\Program Files\Rainman_calendar\calendar_image\image70\" & imageNode(TreeView1.SelectedNode.Index).InnerText)
            PictureBox2.Image = myImage2
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim myForm1 As Form1 = New Form1
        myForm1.Show()
    End Sub
End Class
