Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
0
        private void show_ftp_server(mFilePanel target_panel)
        {
            var opts   = Options.FtpOptions;
            var dialog = new FtpConnectionDialog();

            dialog.FtpConnectionOptions = opts;
            dialog.Text = Options.GetLiteral(Options.LANG_CONNECT_TO_FTP_SERVER);

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

            opts = dialog.FtpConnectionOptions;
            Options.FtpOptions = opts;

            if (!opts.Anonymous)
            {
                var user = opts.UserName;
                var pass = opts.Password;
                Messages.AskCredentials
                    (Options.GetLiteral(Options.LANG_LOGIN_TO_FTP_SERVER), opts.ServerName, ref user, ref pass);
                opts.UserName = user;
                opts.Password = pass;
            }

            var conn = new FtpConnection(opts);
            var fl   = new FtpDirectoryList(0, false, conn);

            try
            {
                fl.MainWindow = this;
                fl.Refill();
                target_panel.Source = fl;
                target_panel.Refresh();
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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();
        }
        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;
            }

            FtpDirectoryList ftp_list = (FtpDirectoryList)e_current.ItemCollection;
            DirectoryList    dir_list = (DirectoryList)e_other.ItemCollection;

            List <FtpEntryInfo> sel_source = new List <FtpEntryInfo>();

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

            string destination = dir_list.DirectoryPath;

            //prepare and show user dialog
            FtpTransferOptions ftp_trans_opts = Options.FtpDownloadOptions;
            FtpTransferDialog  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;
            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 doanload engine
            FtpDownloadEngine 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();
        }