Пример #1
0
        // Creation d'un thread d'envoi de fichier lorsque l'event drag drop est déclenché
        public void SendControl_DragDrop(SendControl sender)
        {
            Thread SendFile = new Thread(() =>
            {
                Main.SocketSendFilename(sender.fileList.First());
                Main.SocketSendFilesize(sender.fileList.First());
                Main.SocketSendFile(sender.fileList.First());
                FileUploadedAlert(Program.GetFileName(sender.fileList.First()));
            });

            SendFile.IsBackground = true;
            SendFile.Start();
            SC.DragName.Text = "Sending ...";
        }
Пример #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");
            }
        }