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));
            }
        }
Example #2
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));
            }
        }
Example #3
0
        private void create_zip_directory(QueryPanelInfoEventArgs e_current)
        {
            var zd = (ZipDirectory)e_current.ItemCollection;

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

            dialog.Text = CommandMenu.Text;
            dialog.labelParentDir.Text              = zd.CurrentZipDirectory + "/";
            dialog.checkBoxUseTemplate.Checked      = false;
            dialog.checkBoxUseTemplate.Enabled      = false;
            dialog.textBoxTemplateDirectory.Enabled = false;

            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            if (dialog.textBoxDirectoryName.Text.Length == 0)
            {
                Messages.ShowMessage("directory name cannot be empty");
                return;
            }

            var new_directory_name = string.Empty;

            if (zd.CurrentZipDirectory == string.Empty)
            {
                new_directory_name = dialog.textBoxDirectoryName.Text;
            }
            else
            {
                new_directory_name = zd.CurrentZipDirectory + "/" + dialog.textBoxDirectoryName.Text;
            }
            if (!new_directory_name.EndsWith("/"))
            {
                new_directory_name = new_directory_name + "/";
            }

            try
            {
                var dir_entry = zd.ZipFile.EntryFactory.MakeDirectoryEntry(new_directory_name);
                dir_entry.Size           = 0;
                dir_entry.CompressedSize = 0; //required, else exception throws
                zd.ZipFile.BeginUpdate();
                zd.ZipFile.Add(dir_entry);
                zd.ZipFile.CommitUpdate();
                zd.Refill();
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
        }
Example #4
0
        protected override void internal_command_proc()
        {
            QueryPanelInfoEventArgs e_current = new QueryPanelInfoEventArgs();

            OnQueryCurrentPanel(e_current);
            FtpDirectoryList ftp_list = (FtpDirectoryList)e_current.ItemCollection;

            string current_dir = ftp_list.DirectoryPath;

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

            dialog.Text = Options.GetLiteral(Options.LANG_DIRECTORY_CREATE);
            dialog.labelParentDir.Text              = current_dir;
            dialog.checkBoxUseTemplate.Enabled      = false;
            dialog.textBoxTemplateDirectory.Enabled = false;

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

            string new_dir = FtpPath.Combine(current_dir, dialog.textBoxDirectoryName.Text);

            //create dir tree
            if (ftp_list.MainWindow != null)
            {
                ftp_list.MainWindow.NotifyLongOperation
                    (string.Format
                        (Options.GetLiteral(Options.LANG_DIRECTORY_CREATE_0),
                        new_dir),
                    true);
            }

            try
            {
                ftp_list.Connection.CreateDirectoryTree(new_dir);
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }

            if (ftp_list.MainWindow != null)
            {
                ftp_list.MainWindow.NotifyLongOperation
                    (string.Empty,
                    false);
            }

            ftp_list.Refill();
        }