示例#1
0
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

            if (e.FocusedIndex < 0)
            {
                return;
            }

            DirectoryList dl_list = (DirectoryList)e.ItemCollection;

            if (dl_list.GetItemDisplayNameLong(e.FocusedIndex) == "..")
            {
                return;
            }

            //check volume caps
            string     root_path = Path.GetPathRoot(dl_list.DirectoryPath);
            VolumeInfo vi        = new VolumeInfo(root_path);

            if ((vi.FileSystemFlags & VolumeCaps.NamedStreams) != VolumeCaps.NamedStreams)
            {
                Messages.ShowMessage
                    (string.Format
                        ("File system on drive {0} not support named streams",
                        root_path));
                return;
            }

            StreamList new_source = new StreamList
                                        (Path.Combine(dl_list.DirectoryPath, dl_list.GetItemDisplayNameLong(e.FocusedIndex)),
                                        false,
                                        0,
                                        false);

            try
            {
                new_source.Refill();
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
                return;
            }

            SetNewSourceEventArgs e_new_source = new SetNewSourceEventArgs
                                                     (new_source,
                                                     false,
                                                     string.Empty);

            OnSetNewSource(e_new_source);
        }
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);



            DirectoryList dl = (DirectoryList)e.ItemCollection;

            if (dl.GetItemDisplayNameLong(e.FocusedIndex) == "..")
            {
                return;
            }

            string file_name = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(e.FocusedIndex));

            FileInformationDialog dialog = new FileInformationDialog();

            try
            {
                if (dl.MainWindow != null)
                {
                    dl.MainWindow.NotifyLongOperation(Options.GetLiteral(Options.LANG_QUERY_PROPERTIES), true);
                }

                dialog.FillContents(file_name);
            }
            finally
            {
                if (dl.MainWindow != null)
                {
                    dl.MainWindow.NotifyLongOperation(string.Empty, false);
                }
            }
            dialog.ShowDialog();
        }
示例#3
0
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

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

            if (e.ItemCollection == null)
            {
                return;
            }

            DirectoryList dl          = (DirectoryList)e.ItemCollection;
            string        target_file = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(e.FocusedIndex));

            AFSdialog dialog = new AFSdialog(target_file);

            dialog.ShowDialog();
        }
示例#4
0
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

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

            bool group_mode = false;

            int[] sel_indices = e.SelectedIndices;
            //we not need cache selection
            //becouse e.ItemsCollection must not change (DirectoryList not sort on attributes)
            group_mode = (sel_indices.Length > 1);
            DirectoryList   dl     = (DirectoryList)e.ItemCollection;
            WIN32_FIND_DATA f_data = new WIN32_FIND_DATA();

            string target_file = string.Empty;

            if (!group_mode)
            {
                if (sel_indices.Length == 0)
                {
                    target_file = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(e.FocusedIndex));
                }
                else
                {
                    target_file = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(sel_indices[0]));
                }
                if (target_file.EndsWith(".."))
                {
                    target_file = dl.DirectoryPath;
                }
                if (!WinAPiFSwrapper.GetFileInfo(target_file, ref f_data))
                {
                    return;
                }
            }



            FileAttributesEditDialog dialog = new FileAttributesEditDialog();

            if (!group_mode)
            {
                dialog.buttonClear.Enabled = false;
                set_attributes_to_dialog(dialog, f_data.dwFileAttributes);
                dialog.Text = String.Format
                                  (Options.GetLiteral(Options.LANG_FILE_ATTRIBUTES) + " [{0}]", target_file);
            }
            else
            {
                dialog.buttonClear.Enabled = true;
                dialog.buttonOK.Text       = Options.GetLiteral(Options.LANG_ADD);
                dialog.Text = string.Format
                                  (Options.GetLiteral(Options.LANG_FILE_ATTRIBUTES) + " [{0} " + Options.GetLiteral(Options.LANG_ENTRIES) + "]", sel_indices.Length);
            }
            set_readonly_attributes(dialog);

            DialogResult d_res = dialog.ShowDialog();

            switch (d_res)
            {
            case DialogResult.OK:
                //group mode = add attributes
                //single mode = set attributes
                if (!group_mode)
                {
                    try
                    {
                        set_attributes_file(target_file, get_attributes_from_dialog(dialog));
                    }
                    catch (Exception ex)
                    {
                        Messages.ShowException(ex);
                    }
                }
                else
                {
                    //group mode
                    FileAttributes add_fa = get_attributes_from_dialog(dialog);
                    foreach (int one_index in sel_indices)
                    {
                        target_file = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(one_index));
                        try
                        {
                            add_attributes_file(target_file, add_fa);
                            OnItemProcessDone(new ItemEventArs(one_index));
                        }
                        catch (Exception ex)
                        {
                            Messages.ShowException(ex);
                        }
                    }
                }
                break;

            case DialogResult.Yes:
                //group mode only = clear attributes
                FileAttributes clear_fa = get_attributes_from_dialog(dialog);
                foreach (int one_index in sel_indices)
                {
                    target_file = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(one_index));
                    try
                    {
                        clear_attributes_file(target_file, clear_fa);
                        OnItemProcessDone(new ItemEventArs(one_index));
                    }
                    catch (Exception ex)
                    {
                        Messages.ShowException(ex);
                    }
                }
                break;
            }
        }
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e_current = new QueryPanelInfoEventArgs();
            QueryPanelInfoEventArgs e_other   = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e_current);
            OnQueryOtherPanel(e_other);
            DirectoryList dl_current = (DirectoryList)e_current.ItemCollection;
            DirectoryList dl_other   = null;

            if (e_other.ItemCollection is DirectoryList)
            {
                dl_other = (DirectoryList)e_other.ItemCollection;
            }

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

            dialog.Text = "Create directory";
            dialog.labelParentDir.Text              = dl_current.DirectoryPath + Path.DirectorySeparatorChar;
            dialog.checkBoxUseTemplate.Checked      = false;
            dialog.textBoxTemplateDirectory.Enabled = false;
            if ((dl_other == null) || (e_other.FocusedIndex <= 0))
            {
                dialog.checkBoxUseTemplate.Checked      = false;
                dialog.textBoxTemplateDirectory.Enabled = false;
            }
            else
            {
                dialog.textBoxTemplateDirectory.Text = Path.Combine(dl_other.DirectoryPath, dl_other.GetItemDisplayNameLong(e_other.FocusedIndex));
            }

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

            if (dialog.textBoxDirectoryName.Text == string.Empty)
            {
                Messages.ShowMessage("Directory exists.");
                return;
            }

            string new_directory_name = Path.Combine(dl_current.DirectoryPath, dialog.textBoxDirectoryName.Text);
            string template_dir       = string.Empty;

            if (dialog.checkBoxUseTemplate.Checked)
            {
                template_dir = dialog.textBoxTemplateDirectory.Text;
            }

            try
            {
                Wrapper.CreateDirectoryTree(new_directory_name, template_dir);
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex, string.Format("Failed to create directory '{0}'.", new_directory_name));
            }
        }
示例#6
0
        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);

            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();
        }
示例#8
0
        private void create_fs_directory(QueryPanelInfoEventArgs e_current, QueryPanelInfoEventArgs e_other)
        {
            var           dl_current = (DirectoryList)e_current.ItemCollection;
            DirectoryList dl_other   = null;

            if (e_other.ItemCollection is DirectoryList)
            {
                dl_other = (DirectoryList)e_other.ItemCollection;
            }

            //prepare dialog
            var dialog = new CreateDirectoryDialog();

            dialog.Text = CommandMenu.Text;
            dialog.labelParentDir.Text              = dl_current.DirectoryPath + Path.DirectorySeparatorChar;
            dialog.checkBoxUseTemplate.Checked      = false;
            dialog.textBoxTemplateDirectory.Enabled = false;
            if ((dl_other == null) || (e_other.FocusedIndex <= 0))
            {
                dialog.checkBoxUseTemplate.Checked      = false;
                dialog.textBoxTemplateDirectory.Enabled = false;
            }
            else
            {
                dialog.textBoxTemplateDirectory.Text = Path.Combine(dl_other.DirectoryPath, dl_other.GetItemDisplayNameLong(e_other.FocusedIndex));
            }

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

            if (dialog.textBoxDirectoryName.Text == string.Empty)
            {
                Messages.ShowMessage(Options.GetLiteral(Options.LANG_DIRECTORY_EXISTS));
                return;
            }

            var new_directory_name = Path.Combine(dl_current.DirectoryPath, dialog.textBoxDirectoryName.Text);
            var template_dir       = string.Empty;

            if (dialog.checkBoxUseTemplate.Checked)
            {
                template_dir = dialog.textBoxTemplateDirectory.Text;
            }

            try
            {
                WinAPiFSwrapper.CreateDirectoryTree(new_directory_name, template_dir);
            }
            catch (Exception ex)
            {
                Messages.ShowException
                    (ex,
                    string.Format
                        (Options.GetLiteral(Options.LANG_CANNOT_CREATE_DIRECTORY_0),
                        new_directory_name));
            }
        }
示例#9
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);
            }
        }
        protected override void internal_command_proc()
        {
            try
            {
                QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();
                OnQueryCurrentPanel(e);
                if (e.FocusedIndex == -1)
                {
                    return;
                }

                string        target_file = string.Empty;
                DirectoryList dl          = (DirectoryList)e.ItemCollection;
                int[]         sel_indices = e.SelectedIndices;
                bool          group_mode  = (sel_indices.Length > 1);
                //we need cache list of selected files
                //becouse e.ItemCollection can change while processing (sort!)
                List <string> sel_names = new List <string>();
                for (int i = 0; i < sel_indices.Length; i++)
                {
                    sel_names.Add(e.ItemCollection.GetItemDisplayNameLong(sel_indices[i]));
                }


                if (!group_mode)
                {
                    if (sel_indices.Length == 1)
                    {
                        target_file = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(sel_indices[0]));
                    }
                    else
                    {
                        target_file = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(e.FocusedIndex));
                    }
                }
                if (target_file.EndsWith(".."))
                {
                    target_file = dl.DirectoryPath + Path.DirectorySeparatorChar;
                }

                FileSystemInfo target_fsi = null;
                if (!group_mode)
                {
                    target_fsi = IOhelper.GetFileSystemInfo(target_file);
                }

                TouchFileDialog dialog = new TouchFileDialog();

                dialog.Text = Options.GetLiteral(Options.LANG_TOUCH);

                if (!group_mode)
                {
                    dialog.textBoxFileName.Text             = target_file;
                    dialog.dateTimePickerAccess.Value       = target_fsi.LastAccessTime;
                    dialog.dateTimePickerCreation.Value     = target_fsi.CreationTime;
                    dialog.dateTimePickerModification.Value = target_fsi.LastWriteTime;
                }
                else
                {
                    dialog.textBoxFileName.Text    = string.Format("{0} " + Options.GetLiteral(Options.LANG_ENTRIES), sel_indices.Length);
                    dialog.textBoxFileName.Enabled = false;
                }

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

                if (!group_mode)
                {
                    if (dialog.textBoxFileName.Text != target_file)
                    {
                        //try create new file
                        netCommander.FileSystemEx.WinAPiFSwrapper.CreateNewEmptyFile(dialog.textBoxFileName.Text);
                        //if success
                        target_fsi = new FileInfo(dialog.textBoxFileName.Text);
                    }
                }

                //set times
                if (group_mode)
                {
                    foreach (string one_name in sel_names)
                    {
                        try
                        {
                            target_file = Path.Combine(dl.DirectoryPath, one_name);
                            target_fsi  = IOhelper.GetFileSystemInfo(target_file);
                            if (dialog.dateTimePickerAccess.Checked)
                            {
                                target_fsi.LastAccessTime = dialog.dateTimePickerAccess.Value;
                            }
                            if (dialog.dateTimePickerCreation.Checked)
                            {
                                target_fsi.CreationTime = dialog.dateTimePickerCreation.Value;
                            }
                            if (dialog.dateTimePickerModification.Checked)
                            {
                                target_fsi.LastWriteTime = dialog.dateTimePickerModification.Value;
                            }
                            OnItemProcessDone(new ItemEventArs(one_name));
                        }
                        catch (Exception ex)
                        {
                            Messages.ShowException(ex);
                        }
                    }
                }
                else
                {
                    try
                    {
                        if (dialog.dateTimePickerAccess.Checked)
                        {
                            target_fsi.LastAccessTime = dialog.dateTimePickerAccess.Value;
                        }
                        if (dialog.dateTimePickerCreation.Checked)
                        {
                            target_fsi.CreationTime = dialog.dateTimePickerCreation.Value;
                        }
                        if (dialog.dateTimePickerModification.Checked)
                        {
                            target_fsi.LastWriteTime = dialog.dateTimePickerModification.Value;
                        }
                    }
                    catch (Exception ex)
                    {
                        Messages.ShowException(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
        } // end of proc
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e);

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

            DirectoryList dl = (DirectoryList)e.ItemCollection;

            if (dl.GetItemDisplayNameLong(e.FocusedIndex) == "..")
            {
                return;
            }

            //show dialog
            ProcessStartInfo psi       = new ProcessStartInfo();
            string           file_name = dl[e.FocusedIndex].FullName;

            psi.FileName = file_name;
            RunExeOptions opts   = Options.RunExeOptions;
            RunexeDialog  dialog = new RunexeDialog();

            dialog.Text                         = Options.GetLiteral(Options.LANG_EXECUTE);
            dialog.RunExeOptions                = opts;
            dialog.textBoxArguments.Text        = string.Empty;
            dialog.textBoxFilename.Text         = dl[e.FocusedIndex].FileName;
            dialog.textBoxWorkingDirectory.Text = dl.DirectoryPath;
            if (psi.Verbs != null)
            {
                foreach (string verb in psi.Verbs)
                {
                    dialog.comboBoxVerb.Items.Add(verb);
                }
            }

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

            opts = dialog.RunExeOptions;
            Options.RunExeOptions = opts;

            psi.LoadUserProfile = (opts & RunExeOptions.LoadEnvironment) == RunExeOptions.LoadEnvironment;
            if ((opts & RunExeOptions.RunInConsole) == RunExeOptions.RunInConsole)
            {
                if (file_name.Contains(" "))
                {
                    file_name = '"' + file_name + '"';
                }
                psi.FileName  = "cmd";
                psi.Arguments = "/K " + file_name;
            }
            else
            {
                psi.FileName = file_name;
            }

            if ((opts & RunExeOptions.UseRunas) == RunExeOptions.UseRunas)
            {
                string user = string.Empty;
                string pass = string.Empty;

                if (Messages.AskCredentials(Options.GetLiteral(Options.LANG_ACCOUNT), Options.GetLiteral(Options.LANG_EXECUTE) + " '" + file_name + "'", ref user, ref pass) == DialogResult.OK)
                {
                    psi.UserName = user;
                    System.Security.SecureString sec = new System.Security.SecureString();
                    foreach (char c in pass)
                    {
                        sec.AppendChar(c);
                    }
                    psi.Password = sec;
                }
            }

            psi.UseShellExecute = (opts & RunExeOptions.UseShellExecute) == RunExeOptions.UseShellExecute;

            psi.WorkingDirectory = dialog.textBoxWorkingDirectory.Text;
            psi.Verb             = dialog.comboBoxVerb.Text;
            psi.Arguments        = psi.Arguments + " " + dialog.textBoxArguments.Text;

            try
            {
                Process.Start(psi);
            }
            catch (Exception ex)
            {
                Messages.ShowException
                    (ex,
                    string.Format(Options.GetLiteral(Options.LANG_CANNOT_EXCUTE_0_1), psi.FileName, psi.Arguments));
            }
        }
示例#12
0
        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 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
            List <FileInfoEx> source_list = new List <FileInfoEx>();
            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(dl_source[e_current.FocusedIndex]);
            }
            else
            {
                //get source from selection
                for (int i = 0; i < sel_indices.Length; i++)
                {
                    source_list.Add(dl_source[sel_indices[i]]);
                }
            }

            string dest_path = dl_target.DirectoryPath;

            //prepare copy dialog
            CopyFileDialog 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
            CopyEngineOptions 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
            bool dest_remote = true;

            try
            {
                FileInfoEx dest_info = new FileInfoEx();
                FileInfoEx.TryGet(dest_path, ref dest_info);
                NT_FS_DEVICE_CHARACTERISTICS 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);
            CopyFileEngine 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();
        }
示例#13
0
        private void upload_to_ftp(QueryPanelInfoEventArgs e_current, QueryPanelInfoEventArgs e_other)
        {
            DirectoryList    source_directory = (DirectoryList)e_current.ItemCollection;
            FtpDirectoryList destination_ftp  = (FtpDirectoryList)e_other.ItemCollection;

            List <string> 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 (int i = 0; i < e_current.SelectedIndices.Length; i++)
                {
                    source_list.Add
                        (Path.Combine
                            (source_directory.DirectoryPath,
                            source_directory.GetItemDisplayNameLong(e_current.SelectedIndices[i])));
                }
            }

            string        dest_path = destination_ftp.DirectoryPath;
            FtpConnection ftp_conn  = destination_ftp.Connection;

            //show upload dialog
            FtpTransferOptions ftp_trans_opts = Options.FtpUploadOptions;
            FtpTransferDialog  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;
            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 upload engine
            FtpUploadEngine 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);
        }