Imports System.IO
Imports System.Net
Public Class Form1
    Dim dos As String = ""
    Dim heursa As String = ""
    Dim notifmisaj As Integer = 0
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If Directory.Exists(dospara) = True Then

        Else
            Directory.CreateDirectory(dospara)
        End If

        If Directory.Exists(dosparalang) = True Then
            Dim lines1() As String = File.ReadAllLines(dosparasetting.ToString & "/theme.txt")
            If lines1(0) = 1 Then
                themesombre()
            Else
                themeclaire()
            End If

        Else
                Directory.CreateDirectory(dosparalang)
        End If

        If Directory.Exists(dosparasetting) = True Then

        Else
            Directory.CreateDirectory(dosparasetting)
            Dim sw1 As New StreamWriter(dosparasetting.ToString & "/lang.txt")
            sw1.WriteLine(0)
            sw1.Close()
            Dim sw2 As New StreamWriter(dosparasetting.ToString & "/langselect.txt")
            sw2.WriteLine(0)
            sw2.Close()
            Dim sw3 As New StreamWriter(dosparasetting.ToString & "/theme.txt")
            sw3.WriteLine(0)
            sw3.Close()
            Dim sw4 As New StreamWriter(dosparasetting.ToString & "/stopauto.txt")
            sw4.WriteLine(0)
            sw4.Close()
        End If

        If Directory.Exists(dosparaupdate) = True Then
            Dim lines3() As String = File.ReadAllLines(dosparaupdate & "/autoupdate.txt")
            If lines3(0) = 1 Then
                notifmisaj = 0
                startupdate()
            End If
        Else
            Directory.CreateDirectory(dosparaupdate)
            Dim sw1 As New StreamWriter(dosparaupdate.ToString & "/autoupdate.txt")
            sw1.WriteLine(1)
            sw1.Close()
        End If

        If Directory.Exists(profil) = True Then
            ComboBox1.Items.Clear()
            For Each fichier As String In IO.Directory.GetDirectories(profil)
                Dim info As New IO.FileInfo(fichier)
                ComboBox1.Items.Add(info.Name)
            Next
            If ComboBox1.Items.Count = 0 Then
                Form3.opensetting = 0
                Form3.Show()
                Close()
                Exit Sub
            End If
        Else
            Directory.CreateDirectory(profil)
            Form3.Show()
            Close()
            Exit Sub
        End If
    End Sub

    Private Sub ComboBox1_SelectedValueChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedValueChanged
        Form4.profilselect = ComboBox1.SelectedItem
        Form4.Show()
        Close()
    End Sub

    Private Sub ParamètreToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ParamètreToolStripMenuItem.Click
        Form2.ShowDialog()
    End Sub
    Sub startupdate()
        Try
            If My.Computer.Network.Ping("www.google.com") Then
                Dim maj1 As New WebClient
                Dim vri1 As String = maj1.DownloadString("https://dl.dropbox.com/scl/fi/x05tq6ejtnbzvahxhxrvo/vr.txt?rlkey=eoong4ey8ctwfmol9uv1em764&st=293rp5gn&dl=0")
                If vr = vri1 Then
                    If notifmisaj = 1 Then
                        MsgBox("Vous êtê a jours, version: " & vr, MsgBoxStyle.Information)
                    End If
                Else
                    MsgBox("une mis a jour est dispnible, vôtre version: " & vr & " nouvelle version: " & vri1, MsgBoxStyle.Information)
                    Dim msg = MsgBox("voulez vous télécharger la nouvelle mis a jour ?", MsgBoxStyle.YesNo)
                    If msg = MsgBoxResult.Yes Then
                        Dim maj2 As New WebClient
                        Dim vri2 As String = maj2.DownloadString("https://dl.dropbox.com/scl/fi/ok6wgs1z0z2b0mq14freg/dl.txt?rlkey=lhjk97ojwrcno6u76elhxwx2n&st=wg7pm128&dl=0")
                        Process.Start(vri2)
                    Else

                    End If
                End If
            End If
        Catch ex As Exception
            MsgBox("vous n'est pas connecter a internet", MsgBoxStyle.Exclamation)
        End Try
    End Sub

    Private Sub RechercherUneMisAJourToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RechercherUneMisAJourToolStripMenuItem.Click
        notifmisaj = 1
        startupdate()
    End Sub
    Sub themesombre()
        BackColor = Color.FromArgb(64, 64, 64)
        ForeColor = Color.White
        MenuStrip1.BackColor = BackColor
        MenuStrip1.ForeColor = ForeColor
        ComboBox1.BackColor = BackColor
        ComboBox1.ForeColor = ForeColor
    End Sub
    Sub themeclaire()
        BackColor = SystemColors.Control
        ForeColor = Color.Black
        MenuStrip1.BackColor = BackColor
        MenuStrip1.ForeColor = ForeColor
        ComboBox1.BackColor = BackColor
        ComboBox1.ForeColor = ForeColor
    End Sub

    Private Sub ApproposToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ApproposToolStripMenuItem.Click
        Form13.ShowDialog()
    End Sub
End Class
