Imessenger = {}
function Imessenger:AppliImessengerAppRun()
   MACXT_Repertoire:Reinitialiser_Window()
   Window_Hauteur = 60
   Window_Longueur = 245
   MACXT_Graphic:Init_New_Personnal_Window()
   MACXT_Title = "Imessenger : Login"
   MACXT_Graphic:New_Textes()
   MACXT_Texte_Window[1] = {Caption = "Saisissez votre pseudo :"}
   MACXT_Texte_Window[2] = {Caption = "Pseudo : "..LoginImessenger}
   MACXT_Repertoire:Actualise_Texte_Window()
   Affichage_Button = "Horizontal_Drawing"
   MACXT_Draw_Button[1] = {Caption = "Accepter",Action = "OpenConnection"}
   MACXT_Draw_Button[2] = {Caption = "Fermer",Action = "CloseConnection"}
   MACXT_Repertoire:Actualise_Draw_Button()
   if Action_Button == "OpenConnection" then
      Allmessages = {}
      Imessages = 0
      partImessages = 1
      LancerImessenger = 1
      ActiverImessenger = 0
      Window_Hauteur = 100
      Window_Longueur = 245
      MACXT_Graphic:Init_New_Personnal_Window()
      MACXT_Repertoire:Anti_Bug()
   end
   if Action_Button == "CloseConnection" then
      Afficher_Personnal_Window = 0
      ActiverImessenger = 0
      MACXT_Repertoire:Anti_Bug()
   end
end
function Imessenger:Messages_Repertoire()
   if Imessage and Imessage ~= "" then
      if Imessages >= 7 then
         partImessages = partImessages + 1
      end
      Imessages = Imessages + 1
      Allmessages[Imessages] = {messagesI = LoginImessenger.." : "..Imessage}
      Imessage = nil
   end
end
function Imessenger:AfficherImessages()
   if Imessages > 0 then
      PosYImessages = 80
      for Imessagess = partImessages,Imessages do
         screen:print(100,PosYImessages,Allmessages[Imessagess].messagesI)
         PosYImessages = PosYImessages + 15
      end
   end
end
function Imessenger:OpenConversation()
   MACXT_Repertoire:Reinitialiser_Window()
   Window_Hauteur = 200
   Window_Longueur = 310
   MACXT_Graphic:Init_New_Personnal_Window()
   MACXT_Title = "Imessenger"
   MACXT_Graphic:New_Textes()
   MACXT_Texte_Window[1] = {Caption = "Messages :"}
   MACXT_Texte_Window[2] = {Caption = ""}
   MACXT_Texte_Window[3] = {Caption = ""}
   MACXT_Texte_Window[4] = {Caption = ""}
   MACXT_Texte_Window[5] = {Caption = ""}
   MACXT_Texte_Window[6] = {Caption = ""}
   MACXT_Texte_Window[7] = {Caption = ""}
   MACXT_Texte_Window[8] = {Caption = ""}
   MACXT_Texte_Window[9] = {Caption = ""}
   MACXT_Repertoire:Actualise_Texte_Window()
   Affichage_Button = "Horizontal_Drawing"
   MACXT_Draw_Button[1] = {Caption = "Fermer",Action = "CloseContacts"}
   MACXT_Repertoire:Actualise_Draw_Button()
   MACXT_Graphic:DrawRectangle(100,190,280,30,Color.new(0,0,0))
   Imessage = Adhoc.recv()
   Imessenger:AfficherImessages()
   Imessenger:Messages_Repertoire()
   if MACXTKeyPad:l() and Imessages > 7 and partImessages > 1 then
      partImessages = partImessages - 1
   end
   if MACXTKeyPad:r() and partImessages < Imessages - 6 then
      partImessages = partImessages + 1
   end
   if x >= 100 and x <= 380 and y >= 190 and y <= 220 then
      MACXTAide = "Entrer votre message"
      if MACXTKeyPad:cross() then
         if Imessages > 7 then
            partImessages = Imessages - 6
         end
         Imessage = System.startOSK("","")
         Adhoc.send(Imessage)
         Imessenger:Messages_Repertoire()
      end
   end
   if Afficher_Personnal_Window == 0 then
      LancerImessenger = 0
   end
   if Action_Button == "CloseContacts" then
      LancerImessenger = 0
      Afficher_Personnal_Window = 0
      MACXT_Repertoire:Anti_Bug()
   end
end