protected override void internal_command_proc()
        {
            abort = false;
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

            if (e.FocusedIndex == -1)
            {
                return;
            }

            if (!(e.ItemCollection is DirectoryList))
            {
                return;
            }

            DirectoryList dl = (DirectoryList)e.ItemCollection;

            main_window = dl.MainWindow;
            int[] sel_indices = e.SelectedIndices;
            //we must cache selection
            //becouse indexes will be change while deleting
            List <FileInfoEx> sel_files = new List <FileInfoEx>();

            if (sel_indices.Length > 0)
            {
                for (int i = 0; i < sel_indices.Length; i++)
                {
                    sel_files.Add(dl[sel_indices[i]]);
                }
            }
            else
            {
                if (dl[e.FocusedIndex].FileName == "..")
                {
                    Messages.ShowMessage(Options.GetLiteral(Options.LANG_WRONG_DESTINATION));
                    return;
                }
                sel_files.Add(dl[e.FocusedIndex]);
            }

            //now we have list for delete

            opts = Options.DeleteFileOptions;

            //show user dialog...
            DeleteFileDialog dialog = new DeleteFileDialog();

            dialog.Text = CommandMenu.Text;
            dialog.DeleteFileOptions = opts;
            dialog.textBoxMask.Text  = "*";

            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            opts = dialog.DeleteFileOptions;
            Options.DeleteFileOptions = opts;
            delete_mask = dialog.textBoxMask.Text;

            if (sel_files.Count == 1)
            {
                delete_entry(sel_files[0]);
            }
            else
            {
                foreach (FileInfoEx info in sel_files)
                {
                    if (abort)
                    {
                        break;
                    }
                    delete_entry(info);
                }
            }
            if (main_window != null)
            {
                main_window.NotifyLongOperation(string.Empty, false);
            }
        }
Beispiel #2
0
        protected override void internal_command_proc()
        {
            var e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

            if (!(e.ItemCollection is ZipDirectory))
            {
                return;
            }

            var zd = (ZipDirectory)e.ItemCollection;
            var initial_sources = new List <string>();
            var initial_zip_dir = zd.CurrentZipDirectory;

            if (initial_zip_dir.StartsWith("/"))
            {
                initial_zip_dir = initial_zip_dir.Substring(1);
            }
            if ((!initial_zip_dir.EndsWith("/")) && (initial_zip_dir != string.Empty))
            {
                initial_zip_dir = initial_zip_dir + "/";
            }
            if (e.SelectedIndices.Length == 0)
            {
                if (zd.GetItemDisplayName(e.FocusedIndex) == "..")
                {
                    return;
                }
                initial_sources.Add(initial_zip_dir + zd.GetItemDisplayName(e.FocusedIndex));
            }
            else
            {
                for (var i = 0; i < e.SelectedIndices.Length; i++)
                {
                    initial_sources.Add(initial_zip_dir + zd.GetItemDisplayName(e.SelectedIndices[i]));
                }
            }

            //show dialog
            var dialog = new DeleteFileDialog();

            dialog.Text = Options.GetLiteral(Options.LANG_DELETE);
            dialog.DeleteFileOptions               = DeleteFileOptions.DeleteEmptyDirectories | DeleteFileOptions.DeleteReadonly | DeleteFileOptions.RecursiveDeleteFiles;
            dialog.textBoxMask.Text                = "*";
            dialog.checkBoxForceReadonly.Enabled   = false;
            dialog.checkBoxRecursive.Enabled       = false;
            dialog.checkBoxRemoveEmptyDirs.Enabled = false;
            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var del_list = new List <ZipEntry>();

            create_delete_list(del_list, initial_sources, dialog.textBoxMask.Text, zd.ZipFile);

            var main_win = (mainForm)Program.MainWindow;

            try
            {
                zd.ZipFile.BeginUpdate();
                for (var i = 0; i < del_list.Count; i++)
                {
                    main_win.NotifyLongOperation
                        (string.Format
                            (Options.GetLiteral(Options.LANG_DELETE_NOW_0),
                            del_list[i].Name),
                        true);
                    zd.ZipFile.Delete(del_list[i]);
                }
                main_win.NotifyLongOperation(Options.GetLiteral(Options.LANG_COMMIT_ARCHIVE_UPDATES), true);
                zd.ZipFile.CommitUpdate();

                zd.Refill();
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
            finally
            {
                main_win.NotifyLongOperation("Done", false);
            }
        }
Beispiel #3
0
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

            if (e.FocusedIndex == -1)
            {
                return;
            }

            FtpDirectoryList ftp_list = (FtpDirectoryList)e.ItemCollection;

            connection = ftp_list.Connection;
            List <FtpEntryInfo> sels = new List <FtpEntryInfo>();

            if (e.SelectedIndices.Length == 0)
            {
                sels.Add(ftp_list[e.FocusedIndex]);
            }
            else
            {
                for (int i = 0; i < e.SelectedIndices.Length; i++)
                {
                    sels.Add(ftp_list[e.SelectedIndices[i]]);
                }
            }

            //show delete dialog
            DeleteFileDialog dialog = new DeleteFileDialog();

            dialog.Text = "Delete files";
            if (sels.Count == 1)
            {
                if (sels[0].Directory)
                {
                    //dialog.labelQuestion.Text =
                    //    string.Format
                    //    ("Do you REALLY want to delete '{0}'? This directory and all its contents it will be destroyed for ever.",
                    //    FtpPath.Combine(sels[0].DirectoryPath, sels[0].EntryName));
                }
                else
                {
                    //dialog.labelQuestion.Text =
                    //    string.Format
                    //    ("Do you REALLY want to delete '{0}'? The file will be destroyed for ever.",
                    //    FtpPath.Combine(sels[0].DirectoryPath, sels[0].EntryName));
                }
            }
            else
            {
                //dialog.labelQuestion.Text =
                //    string.Format
                //    ("Do you REALLY want to delete {0} entries? All selected files and directories with the contents will be destroyed for ever.",
                //    sels.Count);
            }
            //dialog.checkBoxForceReadonly.Checked = false;
            //dialog.checkBoxForceReadonly.Enabled = false;
            //dialog.checkBoxSupressExceptions.Checked = false;

            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            //save user selection
            //Options.DeleteSupressExceptions = dialog.checkBoxSupressExceptions.Checked;
            //supress_errors = dialog.checkBoxSupressExceptions.Checked;

            //and kill
            foreach (FtpEntryInfo info in sels)
            {
                delete_recursive(info, ftp_list.MainWindow);
            }
            if (ftp_list.MainWindow != null)
            {
                ftp_list.MainWindow.NotifyLongOperation
                    (string.Empty, false);
            }

            e.ItemCollection.Refill();
        }
Beispiel #4
0
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

            if (e.FocusedIndex == -1)
            {
                return;
            }

            DirectoryList dl = (DirectoryList)e.ItemCollection;

            int[] sel_indices = e.SelectedIndices;
            //we must cache selection
            //becouse indexes will be change while deleting
            List <string> sel_names = new List <string>();

            if (sel_indices.Length > 0)
            {
                for (int i = 0; i < sel_indices.Length; i++)
                {
                    sel_names.Add(Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(sel_indices[i])));
                }
            }
            else
            {
                sel_names.Add(Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(e.FocusedIndex)));
            }

            //prepare dialog
            DeleteFileDialog dialog = new DeleteFileDialog();

            dialog.Text = "Delete files";
            if (sel_names.Count == 1)
            {
                if (IOhelper.IsDirectory(sel_names[0]))
                {
                    dialog.labelQuestion.Text = string.Format("Do you REALLY want to delete '{0}'? This directory and all its contents it will be destroyed for ever.", sel_names[0]);
                }
                else
                {
                    dialog.labelQuestion.Text = string.Format("Do you REALLY want to delete '{0}'? The file will be destroyed for ever.", sel_names[0]);
                }
            }
            else
            {
                dialog.labelQuestion.Text = string.Format("Do you REALLY want to delete {0} entries? All selected files and directories with the contents will be destroyed for ever.", sel_names.Count);
            }
            dialog.checkBoxForceReadonly.Checked     = Options.DeleteReadonly;
            dialog.checkBoxSupressExceptions.Checked = Options.DeleteSupressExceptions;

            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            //save user selection
            Options.DeleteReadonly          = dialog.checkBoxForceReadonly.Checked;
            Options.DeleteSupressExceptions = dialog.checkBoxSupressExceptions.Checked;
            force_readonly     = dialog.checkBoxForceReadonly.Checked;
            supress_exceptions = dialog.checkBoxSupressExceptions.Checked;

            //and enum entries in sel_names and recursively delete each
            foreach (string one_name in sel_names)
            {
                delete_file_recurs(one_name);
            }
        }