Fond_ = Image.load(MACXT_Path.."/Programs/Adhoc/Images/Fond.png")
Color_Texte = Color.new(0,0,0)
Posx_Personnal_Texte = 150
Posy_Personnal_Texte = 90
MACXT_Programmes:NewAppli_MACXT()
Adhoc_statut = 0
message = ""
while true do
   Adhoc_statut = Adhoc.getState()
   screen:blit(0,0,Fond_)
   MACXT_Objets_Barre[1] = {Caption = "Adhoc",Fonction = "Options"}
   MACXT_Objets_Barre[2] = {Caption = "Fichier",Fonction = "Fichier_Adibou"}
   MACXT_Repertoire:Actualise_Systeme_Barre()
   MACXT_Personnal_Texte[1] = {Caption = "Envoyer",Action = "Send"}
   MACXT_Personnal_Texte[2] = {Caption = "Recevoir",Action = "Receive"}
   MACXT_Personnal_Texte[3] = {Caption = "Partage de fichiers",Action = "Partage_Files"}
   MACXT_Repertoire:Actualise_Personnal_Texte()
   screen:print(5,250,message)
   screen:print(5,230,(System.getFreeMemory()/1024).."Ko")
   if Fonction_Barre == "Options" then
      MACXT_Objets_Barre_Fonction[1] = {Caption = "A propos de Adhoc",Action = "Propos"}
      MACXT_Objets_Barre_Fonction[2] = {Caption = "Quitter",Action = "Quitter"}
      MACXT_Repertoire:Actualise_Fonction()
   end
   if Fonction_Barre == "Fichier_Adibou" then
      MACXT_Objets_Barre_Fonction[1] = {Caption = "Initialiser Adhoc",Action = "Load_Adhoc"}
      MACXT_Objets_Barre_Fonction[2] = {Caption = "Stopper Adhoc",Action = "Stop_Adhoc"}
      MACXT_Repertoire:Actualise_Fonction()
   end
   if Action_Barre == "Quitter" then
      Fond_ = nil
      Envoyer = 0
      Recevoir = 0
      Adhoc.term()
      break
   end
   if Action_Barre == "Load_Adhoc" then
      Adhoc.init()
      Adhoc.connect() 
      MACXT_Repertoire:Anti_Bug()
   end
   if Action_Barre == "Stop_Adhoc" then
      Adhoc.term()
      MACXT_Repertoire:Anti_Bug()
   end
   if Action_Barre == "Propos" then
      MACXT_Repertoire:Reinitialiser_Window()
      Window_Hauteur = 85
      Window_Longueur = 225
      MACXT_Title = "A propos de Adhoc"
      MACXT_Graphic:Init_New_Personnal_Window()
      MACXT_Graphic:New_Textes()
      MACXT_Texte_Window[1] = {Caption = "Auteurs : Luaacro"}
      MACXT_Texte_Window[2] = {Caption = "Permet d'envoyer,"}
      MACXT_Texte_Window[3] = {Caption = "de recevoir et le"}
      MACXT_Texte_Window[4] = {Caption = "le partage de fichiers"}
      MACXT_Repertoire:Actualise_Texte_Window()
      MACXT_Repertoire:Anti_Bug()
   end
   if Action_Personnal_Texte == "Partage_Files" then
            MACXT_Repertoire:Reinitialiser_Window()
            Window_Hauteur = 30
            Window_Longueur = 340
            MACXT_Title = "Erreur"
            MACXT_Graphic:Init_New_Personnal_Window()
            MACXT_Graphic:New_Textes()
            MACXT_Texte_Window[1] = {Caption = "Indisponible pour le moment"}
            MACXT_Repertoire:Actualise_Texte_Window()
      MACXT_Repertoire:Anti_Bug()
   end
   if Action_Personnal_Texte == "Receive" then
      if Adhoc_statut then
         if Adhoc_statut == 1 then
            Recevoir = 1
          else
            MACXT_Repertoire:Reinitialiser_Window()
            Window_Hauteur = 30
            Window_Longueur = 300
            MACXT_Title = "Erreur"
            MACXT_Graphic:Init_New_Personnal_Window()
            MACXT_Graphic:New_Textes()
            MACXT_Texte_Window[1] = {Caption = "Veuillez Activer le Adhoc"}
            MACXT_Repertoire:Actualise_Texte_Window()
         end
      end
      MACXT_Repertoire:Anti_Bug()
   end
   if Action_Personnal_Texte == "Send" then
      if Adhoc_statut then
         if Adhoc_statut == 1 then
            Envoyer = 1
            boot = "Just_Selectionne"
            Module_Finder:Init_Finder_Module()
          else
            MACXT_Repertoire:Reinitialiser_Window()
            Window_Hauteur = 30
            Window_Longueur = 300
            MACXT_Title = "Erreur"
            MACXT_Graphic:Init_New_Personnal_Window()
            MACXT_Graphic:New_Textes()
            MACXT_Texte_Window[1] = {Caption = "Veuillez Activer le Adhoc"}
            MACXT_Repertoire:Actualise_Texte_Window()
         end
      end
      MACXT_Repertoire:Anti_Bug()
   end
   if Recevoir == 1 then
      Adhoc.recv()
      if File_Selected_ then
         Adhoc.send("StopAdhoc")
         Adhoc.term()
      end
   end
   if Envoyer == 1 and File_Selected_ then
      Adhoc.send(File_Selected_)
      if "StopAdhoc" then
         Adhoc.term()
      end
      Adhoc.init()
   end
   if Adhoc_statut == 1 then
      message = "Adhoc active"
    else
      message = "Adhoc desactive"
   end
   if MACXTKeyPad:start() then
      break
   end
MACXT_Kernel:Load_Kernel_Application()
screen.waitVblankStart()
screen:flip()
end
