protected override void internal_command_proc() { QueryPanelInfoEventArgs e_current = new QueryPanelInfoEventArgs(); QueryPanelInfoEventArgs 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; } //see source DirectoryList dl_source = (DirectoryList)e_current.ItemCollection; DirectoryList dl_target = (DirectoryList)e_other.ItemCollection; List <FileInfoEx> source_list = new List <FileInfoEx>(); int[] sel_indices = e_current.SelectedIndices; if (sel_indices.Length == 0) { if (dl_source.GetItemDisplayNameLong(e_current.FocusedIndex) == "..") { return; } source_list.Add(dl_source[e_current.FocusedIndex]); } else { for (int i = 0; i < sel_indices.Length; i++) { source_list.Add(dl_source[sel_indices[i]]); } } //prepare move dialog MoveFileDialog dialog = new MoveFileDialog(); dialog.MoveEngineOptions = Options.MoveEngineOptions; dialog.Text = Options.GetLiteral(Options.LANG_MOVE_RENAME); dialog.textBoxMask.Text = "*"; dialog.textBoxDestination.Text = string.Empty; //and show if (dialog.ShowDialog() != DialogResult.OK) { return; } MoveEngineOptions move_opts = dialog.MoveEngineOptions; Options.MoveEngineOptions = move_opts; //prepare progress dialog 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; //calc location - it is not modal! dialog_progress.TopLevel = true; int x_center = Program.MainWindow.Left + Program.MainWindow.Width / 2; int y_center = Program.MainWindow.Top + Program.MainWindow.Height / 2; int x_dialog = x_center - dialog_progress.Width / 2; int y_dialog = y_center - dialog_progress.Height / 2; if (x_dialog < 0) { x_dialog = 0; } if (x_dialog < 0) { y_dialog = 0; } //show progress dialog_progress.Show(); dialog_progress.Location = new System.Drawing.Point(x_dialog, y_dialog); //prepare move engine MoveFileEngine move_engine = new MoveFileEngine (source_list, dialog.textBoxDestination.Text == string.Empty ? dl_target.DirectoryPath : Path.Combine(dl_target.DirectoryPath, dialog.textBoxDestination.Text), dialog.textBoxMask.Text, move_opts, dialog_progress); move_engine.Done += new EventHandler(move_engine_Done); //and run move_engine.Do(); }
protected override void internal_command_proc() { QueryPanelInfoEventArgs e_current = new QueryPanelInfoEventArgs(); QueryPanelInfoEventArgs e_other = new QueryPanelInfoEventArgs(); OnQueryCurrentPanel(e_current); OnQueryOtherPanel(e_other); //int buffer_size = 0x8000; if (!(e_other.ItemCollection is DirectoryList)) { Messages.ShowMessage (Options.GetLiteral(Options.LANG_WRONG_DESTINATION)); return; } DirectoryList dl = (DirectoryList)e_other.ItemCollection; string dest_dir = dl.DirectoryPath; ZipDirectory zd = (ZipDirectory)e_current.ItemCollection; ZipFile source_zip_file = zd.ZipFile; string zip_current_dir = zd.CurrentZipDirectory; ArchiveExtractOptions opts = Options.ArchiveExtractOptions; //show user dialog ExtractDialog dialog = new ExtractDialog(); dialog.ArchiveExtractOptions = opts; dialog.textBoxSourceMask.Text = "*"; dialog.Text = Options.GetLiteral(Options.LANG_EXTRACT); if (dialog.ShowDialog() != DialogResult.OK) { return; } //retrieve options opts = dialog.ArchiveExtractOptions; string dest_path = Path.Combine(dest_dir, dialog.textBoxDestination.Text); string source_mask = dialog.textBoxSourceMask.Text; Options.ArchiveExtractOptions = opts; //retrieve source list List <string> source_list = new List <string>(); if ((e_current.SelectedIndices.Length == 0) && (e_current.FocusedIndex != 0)) { //focused index==0 always ref to parent entry, so skip it source_list.Add(zd.GetItemDisplayName(e_current.FocusedIndex)); } else { for (int i = 0; i < e_current.SelectedIndices.Length; i++) { if (e_current.SelectedIndices[i] == 0) { continue; } source_list.Add(zd.GetItemDisplayName(e_current.SelectedIndices[i])); } } //prepare progress dialog 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; int x_center = Program.MainWindow.Left + Program.MainWindow.Width / 2; int y_center = Program.MainWindow.Top + Program.MainWindow.Height / 2; int x_dialog = x_center - dialog_progress.Width / 2; int 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); ZipExtractEngine engine = new ZipExtractEngine (source_list, dest_path, opts, dialog_progress, dialog.textBoxSourceMask.Text, zd.ZipFile, zd.CurrentZipDirectory); engine.Done += new EventHandler(engine_Done); engine.ExtractItemDone += new ItemEventHandler(engine_ExtractItemDone); zip_directory = zd; zd.LockSafe = true; engine.Run(); //ZipEntry source_entry = zd[e_current.FocusedIndex]; //if (source_entry == null) //{ // return; //} //Stream out_stream = source_zip_file.GetInputStream(source_entry); //string target_file_name = Path.Combine(dest_dir, source_entry.Name); //FileStream writer = new FileStream(target_file_name, FileMode.CreateNew, FileAccess.Write, FileShare.Read); //byte[] buffer = new byte[buffer_size]; //int bytes_readed = 0; //while ((bytes_readed = out_stream.Read(buffer, 0, buffer_size)) != 0) //{ // writer.Write(buffer, 0, bytes_readed); //} //writer.Flush(); //writer.Close(); //out_stream.Close(); }
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 FtpDirectoryList) { //do ftp download upload_to_ftp(e_current, e_other); return; } else if (e_other.ItemCollection is ZipDirectory) { add_to_zip(e_current, e_other); return; } else if (!(e_other.ItemCollection is DirectoryList)) { Messages.ShowMessage(Options.GetLiteral(Options.LANG_WRONG_DESTINATION)); return; } //see source var source_list = new List <FileInfoEx>(); var dl_source = (DirectoryList)e_current.ItemCollection; var dl_target = (DirectoryList)e_other.ItemCollection; var sel_indices = e_current.SelectedIndices; if (sel_indices.Length == 0) { if (dl_source.GetItemDisplayNameLong(e_current.FocusedIndex) == "..") { return; } //get focused entry source_list.Add(dl_source[e_current.FocusedIndex]); } else { //get source from selection for (var i = 0; i < sel_indices.Length; i++) { source_list.Add(dl_source[sel_indices[i]]); } } var dest_path = dl_target.DirectoryPath; //prepare copy dialog var dialog = new CopyFileDialog(); dialog.CopyEngineOptions = Options.CopyEngineOptions; dialog.Text = Options.GetLiteral(Options.LANG_COPY); dialog.textBoxSourceMask.Text = "*"; dialog.textBoxDestination.Text = string.Empty; if (dialog.ShowDialog() != DialogResult.OK) { return; } //save user selection var engine_opts = dialog.CopyEngineOptions; Options.CopyEngineOptions = engine_opts; //prepare progress dialog 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 copy engine var dest_remote = true; try { var dest_info = new FileInfoEx(); FileInfoEx.TryGet(dest_path, ref dest_info); var chars = dest_info.GetDeviceInfo().Characteristics; if (((chars & NT_FS_DEVICE_CHARACTERISTICS.Remote) == NT_FS_DEVICE_CHARACTERISTICS.Remote) || ((chars & NT_FS_DEVICE_CHARACTERISTICS.Removable) == NT_FS_DEVICE_CHARACTERISTICS.Removable) || ((chars & NT_FS_DEVICE_CHARACTERISTICS.WebDAV) == NT_FS_DEVICE_CHARACTERISTICS.WebDAV)) { dest_remote = true; } else { dest_remote = false; } } catch (Exception) { } dest_path = dialog.textBoxDestination.Text == string.Empty ? dest_path : Path.Combine(dest_path, dialog.textBoxDestination.Text); var copy_engine = new CopyFileEngine (source_list, dest_path, engine_opts, dialog_progress, dialog.textBoxSourceMask.Text, dest_remote); copy_engine.Done += new EventHandler(copy_engine_Done); copy_engine.CopyItemDone += new ItemEventHandler(copy_engine_CopyItemDone); //and do job copy_engine.Do(); }
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() { QueryPanelInfoEventArgs e_current = new QueryPanelInfoEventArgs(); QueryPanelInfoEventArgs e_other = new QueryPanelInfoEventArgs(); OnQueryCurrentPanel(e_current); OnQueryOtherPanel(e_other); if (e_current.FocusedIndex == -1) { return; } if (!(e_other.ItemCollection is DirectoryList)) { Messages.ShowMessage("Cannot copy to current destination."); return; } //see source source_list = new List <string>(); DirectoryList dl_source = (DirectoryList)e_current.ItemCollection; DirectoryList dl_target = (DirectoryList)e_other.ItemCollection; int[] sel_indices = e_current.SelectedIndices; if (sel_indices.Length == 0) { if (dl_source.GetItemDisplayNameLong(e_current.FocusedIndex) == "..") { return; } //get focused entry source_list.Add(Path.Combine(dl_source.DirectoryPath, dl_source.GetItemDisplayNameLong(e_current.FocusedIndex))); } else { //get source from selection for (int i = 0; i < sel_indices.Length; i++) { source_list.Add(Path.Combine(dl_source.DirectoryPath, dl_source.GetItemDisplayNameLong(sel_indices[i]))); } } string dest_path = dl_target.DirectoryPath; //prepare copy dialog CopyFileDialog dialog = new CopyFileDialog(); dialog.CopyEngineOptions = engine_opts; dialog.Text = "Copy"; if (source_list.Count == 1) { dialog.labelSourceFile.Text = source_list[0]; } else { dialog.labelSourceFile.Text = string.Format("{0} entries", source_list.Count); } dialog.textBoxDestination.Text = dest_path; if (dialog.ShowDialog() != DialogResult.OK) { return; } //save user selection engine_opts = dialog.CopyEngineOptions; Options.CopyEngineOptions = engine_opts; //prepare progress dialog 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; int x_center = Program.MainWindow.Left + Program.MainWindow.Width / 2; int y_center = Program.MainWindow.Top + Program.MainWindow.Height / 2; int x_dialog = x_center - dialog_progress.Width / 2; int 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 copy engine CopyFileEngine copy_engine = new CopyFileEngine (source_list.ToArray(), dialog.textBoxDestination.Text, engine_opts, dialog_progress); copy_engine.Done += new EventHandler(copy_engine_Done); copy_engine.CopyItemDone += new ItemEventHandler(copy_engine_CopyItemDone); //and do job copy_engine.Do(); }
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(); }