Ejemplo n.º 1
0
 public void OnlineControl_ConnecPressed(OnlineControl sender)
 {
     if (!Program.IsGlobalConnected)
     {
         if (ReceiveControl.FolderPath == "")
         {
             MessageBox.Show("Please select a folder path before attempting a connection.", "Drag2Share");
         }
         else
         {
             int f = Main.Connection(sender.IDTextBox.Text);
             if (f != 0)
             {
                 MessageBox.Show("Can't find the target computer.", "Drag2Share");
             }
             else
             {
                 ClientStatus.Text         = "Connected(g)";
                 OnC.ConnectButton.Content = "Disconnect";
                 LockTypeButton(true);
                 Program.IsGlobalConnected = true;
             }
         }
     }
     else
     {
         ClientStatus.Text         = "Disconnected";
         OnC.ConnectButton.Content = "Connect";
         LockTypeButton(false);
         Program.IsGlobalConnected = false;
         Main.CloseConnection();
     }
 }
Ejemplo n.º 2
0
        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");
            }
        }