Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Page_PreLoad(sender As Object, e As System.EventArgs) Handles Me.PreLoad
        If Not IsPostBack Then
            If System.IO.File.Exists(Server.MapPath("./img/Color.txt")) Then
                Dim sColor As New System.IO.StreamReader(Server.MapPath("./img/Color.txt"), System.Text.Encoding.GetEncoding("shift_jis"))
                Dim c As String = sColor.ReadToEnd()
                sColor.Close()
                Dim x As String() = c.Split(vbLf)
                For i = 0 To x.Length - 1
                    If Len(x(i)) > 2 Then
                        Dim y As String() = x(i).Split(vbTab)
                        Select Case y(0)
                            'Page1
                            Case "タイトル"
                                Label1.ForeColor = System.Drawing.Color.FromName(y(1))
                                Label1.Text = System.Net.Dns.GetHostName.ToString.ToUpper
                                Label2.ForeColor = System.Drawing.Color.FromName(y(1))
                            Case "スマホメニュー"
                                TreeView1.ForeColor = System.Drawing.Color.FromName(y(1)) '.Style.Add("ForeColor", y(1))
                            Case "タイトル２"
                                Label7.ForeColor = System.Drawing.Color.FromName(y(1))
                                Label7.Text = System.Net.Dns.GetHostName & " の情報ネットです"
                                Label8.ForeColor = System.Drawing.Color.FromName(y(1))
                            Case "スマホメニュー２"
                                TreeView2.ForeColor = System.Drawing.Color.FromName(y(1)) '.Style.Add("ForeColor", y(1))
                        End Select
                    End If
                Next
            Else
                Label1.Style.Add("ForeColor", "White")
                Label2.Style.Add("ForeColor", "White")
                TreeView1.Style.Add("ForeColor", "White")
                Label7.Style.Add("ForeColor", "White")
                Label8.Style.Add("ForeColor", "White")
                TreeView2.Style.Add("ForeColor", "White")
            End If

            'Mobile or PC
            If Request.Browser.IsMobileDevice Then
                'Mobile
                page1.Style.Add("background-image", "url('./img/Top01s.jpg')")
                page2.Style.Add("background-image", "url('./img/Top02s.jpg')")
                PanelPC.Visible = False
                PanelMobile.Visible = True
                PanelPC2.Visible = False
                PanelMobile2.Visible = True
            Else
                'PC
                page1.Style.Add("background-image", "url('./img/Top01.jpg')")
                page2.Style.Add("background-image", "url('./img/Top02.jpg')")
                PanelPC.Visible = True
                PanelMobile.Visible = False
                PanelPC2.Visible = True
                PanelMobile2.Visible = False
            End If

            'Text
            If System.IO.File.Exists(Server.MapPath("./img/text.txt")) Then
                Dim sr As New System.IO.StreamReader(Server.MapPath("./img/text.txt"), System.Text.Encoding.GetEncoding("shift_jis"))
                Dim s As String = sr.ReadToEnd()
                sr.Close()
                LabelBody.Text = s
            End If
            If System.IO.File.Exists(Server.MapPath("./img/text2.txt")) Then
                Dim sr As New System.IO.StreamReader(Server.MapPath("./img/text2.txt"), System.Text.Encoding.GetEncoding("shift_jis"))
                Dim s As String = sr.ReadToEnd()
                sr.Close()
                LabelBody2.Text = s
            End If
        End If
    End Sub

End Class
