Ejemplo n.º 1
0
        private async void btnUpload_Click(object sender, RoutedEventArgs e)
        {
            string fileDesc = "";

            if (txtDescription.Text != "Enter a description...")
            {
                fileDesc = txtDescription.Text;
            }

            // Actually upload the file
            connection = new Connection();

            FileInfo fi = new FileInfo(fullName);
            await connection.Connect(Settings.Default.ServerIP, Settings.Default.ServerPort);

            await connection.SendPacket(new FileUploadRequest(new NetworkFile(fi.Name, fi.Extension, fi.CreationTimeUtc, fi.Length, fileDesc)));

            progressWindow       = new ProgressWindow();
            progressWindow.Owner = this;
            progressWindow.Show();
            await progressWindow.StartUpload(connection, fi);

            DownloadID id = await connection.ReceivePacket() as DownloadID;

            //MessageBox.Show("Upload complete! Your download code is: " + id.ID, "Upload complete!");

            new UploadCompleteWindow(id.ID).ShowDialog();
        }
Ejemplo n.º 2
0
        private async void DownloadClick(object sender, RoutedEventArgs e)
        {
            Directory.CreateDirectory("Downloads");
            connection = new Connection();
            await connection.Connect(Settings.Default.ServerIP, Settings.Default.ServerPort);

            await connection.SendPacket(new FileDownloadRequest(File.ID));

            download_Button.IsEnabled = false;

            progressWindow       = new ProgressWindow();
            progressWindow.Owner = this;
            progressWindow.Show();
            try
            {
                await progressWindow.StartDownload(connection, File);
            }
            catch (Exception)
            {
                MessageBox.Show("Er ging iets fout.");
            }
        }