Exemplo n.º 1
0
        public UploadFileItem(DC_FileInformation file_info)
        {
            connector = new ServerConnector();

            connector.upload_progress += uploadProgress;
            connector.upload_completed += uploadCompleted;
            connector.upload_canceled += uploadCanceled;

            this.file_info = file_info;
            InitializeComponent();

            file_info.status = DC_FileInformationStatus.PendingUpload;
            _barProgress.Value = 0;
            _lblFileName.Text = file_info.file_name;
            _lblStatus.Text = "[WAITING] File Size: " + file_info.file_size.ToString();
        }
Exemplo n.º 2
0
        public UploadFileItem addUploadItem(DC_FileInformation upload_info)
        {
            UploadFileItem control = new UploadFileItem(upload_info) {
                Dock = DockStyle.Top,
                Location = new Point(0, 50),
                ContextMenu = _uploadItemContext,
                Margin = new Padding(0, 20, 0, 0)
            };

            control.onEnter += delegate(object sender, MouseEventArgs e) {
                if (Control.ModifierKeys == Keys.Control){
                    if(selected_upload_items.Contains(control)){
                        if (e.Button != MouseButtons.Right) {
                            selected_upload_items.Remove(control);
                        }
                    }else{
                        selected_upload_items.Add(control);
                    }
                }else{
                    if (e.Button != MouseButtons.Right ||
                        (e.Button == MouseButtons.Right && !selected_upload_items.Contains(control))) {
                        selected_upload_items.Clear();
                        selected_upload_items.Add(control);

                    } else if (!selected_upload_items.Contains(control)) {
                        selected_upload_items.Add(control);
                    }
                }

                foreach (UploadFileItem loop_control in _panFileItemContainer.Controls) {
                    if (!selected_upload_items.Contains(loop_control)) {
                        loop_control.onLeave();
                    }
                }
            };

            control.onDoubleClick += delegate(object sender, EventArgs e) {
                if(control.file_info.status == DC_FileInformationStatus.Uploaded) {
                    System.Diagnostics.Process.Start(control.file_info.url);
                }
            };

            _panFileItemContainer.Controls.Add(control);
            uploading_itmes.Add(control);

            return control;
        }
Exemplo n.º 3
0
        public void directoryFiles(DC_FileInformation[] files)
        {
            DateTime converted_time;
            _lblStatusText.Text = "Idle";
            _lstFiles.Items.Clear();

            if(files == null)
                return;

            foreach(DC_FileInformation file in files) {
                converted_time = Utilities.unixToDateTime(Convert.ToInt64(file.upload_date));

                ListViewItem item = _lstFiles.Items.Add("file_" + file.url_id, file.file_name, "file");
                item.Tag = file;
                item.SubItems.Add(Utilities.formattedSize(file.file_size));
                item.SubItems.Add("");
                item.SubItems.Add(converted_time.ToShortDateString() + " " + converted_time.ToShortTimeString());
                item.SubItems.Add(file.total_views);
            }

            _lblTotalFiles.Text = files.Length.ToString() + " Items";
            _lblStatusText.Text = "Idle";
        }
Exemplo n.º 4
0
        private void _btnConfirmClipboardUpload_Click(object sender, EventArgs e)
        {
            // Check to see if the user has disabled verification of upload.
            if(show_clipboard_confirmation == true) {
                hideConfirmMenu();
            }

            if(Clipboard.ContainsFileDropList()) {
                foreach(string file in Clipboard.GetFileDropList()) {
                    uploadFile(file);
                }

            } else if(Clipboard.ContainsImage()) {
                uploadImage(Clipboard.GetImage(), "Clipboard_");

            } else if(Clipboard.ContainsText()) {
                string temp_file = Path.GetTempFileName();
                StreamWriter sw = new StreamWriter(temp_file);
                sw.Write(Clipboard.GetText());
                sw.Close();

                int total_text = getAndIncrementConfig("uploads.total_text_files");
                string new_filename = Path.GetTempPath() + "\\Clipboard_Text_" + total_text.ToString() + ".txt";

                File.Move(temp_file, new_filename);
                FileInfo fi = new FileInfo(new_filename);

                DC_FileInformation file_info = new DC_FileInformation() {
                    file_name = Path.GetFileName(new_filename),
                    delete_after_upload = true,
                    file_size = fi.Length,
                    local_file_location = new_filename
                };

                uploadFile(file_info);
            }
        }
Exemplo n.º 5
0
        private void uploadImage(Image image, string upload_prefix)
        {
            int screenshot_type = Client.config.get<int>("frmlogin.screenshot_upload_format");
            DC_ImageInformation file;

            switch(screenshot_type) {
                case 0: // Auto detect best method.
                    file = tmpSaveImageAuto(image, upload_prefix);
                    break;

                case 1: // JPEG
                    file = tmpSaveImageJpeg(image, upload_prefix);
                    break;

                case 2: // PNG
                    file = tmpSaveImagePng(image, upload_prefix);
                    break;

                default: // Just incase somebody inputted a number like -1 for jokes.
                    file = tmpSaveImageAuto(image, upload_prefix);
                    break;
            }

            DC_FileInformation file_info = new DC_FileInformation() {
                file_name = Path.GetFileName(file.full_location),
                delete_after_upload = true,
                file_size = file.size,
                local_file_location = file.full_location
            };

            uploadFile(file_info);
        }
Exemplo n.º 6
0
 private void uploadFile(DC_FileInformation file_info)
 {
     UploadFileItem control = addUploadItem(file_info);
     control.startUpload();
 }
Exemplo n.º 7
0
 private void uploadFile(string location)
 {
     FileInfo fi = new FileInfo(location);
     DC_FileInformation file_info = new DC_FileInformation() {
         status = DC_FileInformationStatus.PendingUpload,
         file_name = fi.Name,
         file_size = fi.Length,
         local_file_location = location,
     };
     uploadFile(file_info);
 }