private void upload_to_ftp(QueryPanelInfoEventArgs e_current, QueryPanelInfoEventArgs e_other) { var source_directory = (DirectoryList)e_current.ItemCollection; var destination_ftp = (FtpDirectoryList)e_other.ItemCollection; var source_list = new List <string>(); if (e_current.SelectedIndices.Length == 0) { if (source_directory.GetItemDisplayNameLong(e_current.FocusedIndex) == "..") { return; } source_list.Add (Path.Combine (source_directory.DirectoryPath, source_directory.GetItemDisplayNameLong(e_current.FocusedIndex))); } else { for (var i = 0; i < e_current.SelectedIndices.Length; i++) { source_list.Add (Path.Combine (source_directory.DirectoryPath, source_directory.GetItemDisplayNameLong(e_current.SelectedIndices[i]))); } } var dest_path = destination_ftp.DirectoryPath; var ftp_conn = destination_ftp.Connection; //show upload dialog var ftp_trans_opts = Options.FtpUploadOptions; var dialog = new FtpTransferDialog(); dialog.FtpTransferOptions = ftp_trans_opts; dialog.textBoxDestination.Text = dest_path; dialog.Text = Options.GetLiteral(Options.LANG_UPLOAD); if (source_list.Count == 1) { dialog.labelSourceFile.Text = source_list[0]; } else { dialog.labelSourceFile.Text = string.Format ("{0} " + Options.GetLiteral(Options.LANG_ENTRIES), source_list.Count); } if (dialog.ShowDialog() != DialogResult.OK) { return; } //retrieve user selection ftp_trans_opts = dialog.FtpTransferOptions; dest_path = dialog.textBoxDestination.Text; //save user selection Options.FtpUploadOptions = ftp_trans_opts; //prepare progress window dialog_progress = new CopyFileProgressDialog(); dialog_progress.labelError.Visible = false; dialog_progress.labelSpeed.Text = string.Empty; dialog_progress.labelStatus.Text = string.Empty; dialog_progress.labelStatusTotal.Text = string.Empty; dialog_progress.checkBoxCloseOnFinish.Checked = Options.CopyCloseProgress; dialog_progress.TopLevel = true; var x_center = Program.MainWindow.Left + Program.MainWindow.Width / 2; var y_center = Program.MainWindow.Top + Program.MainWindow.Height / 2; var x_dialog = x_center - dialog_progress.Width / 2; var y_dialog = y_center - dialog_progress.Height / 2; if (x_dialog < 0) { x_dialog = 0; } if (x_dialog < 0) { y_dialog = 0; } dialog_progress.Show(); dialog_progress.Location = new System.Drawing.Point(x_dialog, y_dialog); //prepare upload engine var upload_engine = new FtpUploadEngine (source_list.ToArray(), dest_path, ftp_conn, ftp_trans_opts, dialog_progress); upload_engine.Done += new EventHandler(upload_engine_Done); upload_engine.UploadItemDone += new ItemEventHandler(upload_engine_UploadItemDone); upload_engine.Run(); //ftp_conn.ClearCache(dest_path); }
protected override void internal_command_proc() { var e_current = new QueryPanelInfoEventArgs(); var e_other = new QueryPanelInfoEventArgs(); OnQueryCurrentPanel(e_current); OnQueryOtherPanel(e_other); if (e_current.FocusedIndex == -1) { return; } if (!(e_other.ItemCollection is DirectoryList)) { Messages.ShowMessage(Options.GetLiteral(Options.LANG_WRONG_DESTINATION)); return; } var ftp_list = (FtpDirectoryList)e_current.ItemCollection; var dir_list = (DirectoryList)e_other.ItemCollection; var sel_source = new List <FtpEntryInfo>(); if (e_current.SelectedIndices.Length == 0) { sel_source.Add(ftp_list[e_current.FocusedIndex]); } else { for (var i = 0; i < e_current.SelectedIndices.Length; i++) { sel_source.Add(ftp_list[e_current.SelectedIndices[i]]); } } var destination = dir_list.DirectoryPath; //prepare and show user dialog var ftp_trans_opts = Options.FtpDownloadOptions; var dialog = new FtpTransferDialog(); dialog.FtpTransferOptions = ftp_trans_opts; dialog.textBoxDestination.Text = destination; if (sel_source.Count == 1) { dialog.labelSourceFile.Text = ftp_list.Connection.Options.ServerName + FtpPath.Combine(sel_source[0].DirectoryPath, sel_source[0].EntryName); } else { dialog.labelSourceFile.Text = string.Format ("{0} items from {1}", sel_source.Count, ftp_list.Connection.Options.ServerName); } if (dialog.ShowDialog() != DialogResult.OK) { return; } //retrieve user selection ftp_trans_opts = dialog.FtpTransferOptions; destination = dialog.textBoxDestination.Text; //save user selection Options.FtpDownloadOptions = ftp_trans_opts; //prepare progress window dialog_progress = new CopyFileProgressDialog(); dialog_progress.labelError.Visible = false; dialog_progress.labelSpeed.Text = string.Empty; dialog_progress.labelStatus.Text = string.Empty; dialog_progress.labelStatusTotal.Text = string.Empty; dialog_progress.checkBoxCloseOnFinish.Checked = Options.CopyCloseProgress; dialog_progress.TopLevel = true; var x_center = Program.MainWindow.Left + Program.MainWindow.Width / 2; var y_center = Program.MainWindow.Top + Program.MainWindow.Height / 2; var x_dialog = x_center - dialog_progress.Width / 2; var y_dialog = y_center - dialog_progress.Height / 2; if (x_dialog < 0) { x_dialog = 0; } if (x_dialog < 0) { y_dialog = 0; } dialog_progress.Show(); dialog_progress.Location = new System.Drawing.Point(x_dialog, y_dialog); //prepare doanload engine var engine = new FtpDownloadEngine (sel_source.ToArray(), destination, ftp_list.Connection, ftp_trans_opts, dialog_progress); engine.Done += new EventHandler(engine_Done); engine.DownloadItemDone += new ItemEventHandler(engine_DownloadItemDone); engine.Run(); }