public void OfflineControl_ConnecPressed(OfflineControl sender)
 {
     if (!Program.IsLocalConnected)
     {
         if (ReceiveControl.FolderPath == "")
         {
             MessageBox.Show("Please select a folder path before attempting a connection.", "Drag2Share");
         }
         else if (Main.ConnectionLocal(sender.IPTextBox.Text) != 0)
         {
             MessageBox.Show("Can't find the target computer.", "Drag2Share");
         }
         else
         {
             ClientStatus.Text         = "Connected(l)";
             OfC.ConnectButton.Content = "Disconnect";
             LockTypeButton(true);
             Program.IsLocalConnected = true;
         }
     }
     else
     {
         ClientStatus.Text         = "Disconnected";
         OfC.ConnectButton.Content = "Connect";
         LockTypeButton(false);
         Program.IsLocalConnected = false;
         Main.CloseConnection();
     }
 }
        public MainWindow()
        {
            // On initialise le programme.
            Main = new Program();

            // Initialisation de la fenêtre.
            InitializeComponent();

            // Ini des User Controls
            RC  = new ReceiveControl();
            SC  = new SendControl();
            OfC = new OfflineControl();
            OnC = new OnlineControl();

            // Ajout des user controls par défault
            StackPanelMain.Children.Add(RC);
            StackPanelConnec.Children.Add(OfC);

            // Chargement des events
            OnlineControl.OnConnecPressed   += new OnlineControl.ButtonPressedDelegate(OnlineControl_ConnecPressed);
            OfflineControl.OffConnecPressed += new OfflineControl.ButtonPressedDelegate(OfflineControl_ConnecPressed);
            SendControl.DragDrop            += new SendControl.DragDropDelegate(SendControl_DragDrop);
            Program.FileDownloaded          += new Program.FileDownloadedDelegate(FileDownloadedAlert);
            Program.ConnectionDone          += new Program.ConnectionDoneDelegate(TargetConnected);

            // Envois d'information aux user controls
            OnC.IDBox.Text = Main.Id.ToString();
            OfC.IPBox.Text = Main.IpLocal;

            //Vérification de la connection au réseau local
            try
            {
                Program.GetLocalIP();
            }
            catch
            {
                MessageBox.Show("No network adapters with an IPv4 address in the system!", "Drag2Share");
            }
        }