public FormSortFilesList(SortFilesAction action, SortFilesSettings settings,
                                 string caption, bool allActionsSynchronous)
        {
            InitializeComponent();
            _action            = action;
            _settings          = settings;
            _caption           = caption;
            _synchronous       = allActionsSynchronous;
            _undoFileMoves     = new UndoStack <List <IUndoableFileOp> >();
            _testSelectedItems = new List <FileComparisonResult>();

            listView.SmallImageList              = imageList;
            lblAction.Text                       = "Searching...";
            btnCopyFileLeft.Click               += (o, e) => OnClickCopyFile(true, true);
            btnCopyFileRight.Click              += (o, e) => OnClickCopyFile(false, true);
            btnDeleteLeft.Click                 += (o, e) => OnClickDeleteFile(true, true);
            btnDeleteRight.Click                += (o, e) => OnClickDeleteFile(false, true);
            btnShowLeft.Click                   += (o, e) => OnClickShowFile(true);
            btnShowRight.Click                  += (o, e) => OnClickShowFile(false);
            undoFileMoveToolStripMenuItem.Click += (o, e) => OnUndoClick(true);

            if (action != SortFilesAction.SearchDifferences)
            {
                searchMovedFilesToolStripMenuItem.Visible = false;
                propagateMovesToolStripMenuItem.Visible   = false;
            }
        }
Esempio n. 2
0
        public static SortFilesSettings FillFromUI(SortFilesAction action,
                                                   string skipDirs, string skipFiles,
                                                   string dirLeft, string dirRight,
                                                   bool checkbox1, bool checkbox2,
                                                   bool mirror, bool previewOnly)
        {
            var settings = new SortFilesSettings();

            settings.SkipDirectories.AddRange(TextLineByLineToList(skipDirs));
            settings.SkipFiles.AddRange(TextLineByLineToList(skipFiles));
            settings.LeftDirectory              = dirLeft;
            settings.RightDirectory             = dirRight;
            settings.AllowFiletimesDifferForFAT = checkbox1;
            settings.AllowFiletimesDifferForDST = checkbox2;
            settings.Mirror      = mirror;
            settings.PreviewOnly = previewOnly;
            settings.LogFile     = Path.Combine(TestUtil.GetTestWriteDirectory(),
                                                "log" + Utils.GetRandomDigits() + ".txt");

            // the right directory field isn't shown in UI, we need to set it manually
            if (action == SortFilesAction.SearchDuplicatesInOneDir)
            {
                settings.RightDirectory = settings.LeftDirectory;
            }
            else if (action == SortFilesAction.SearchDuplicates)
            {
                settings.SearchDuplicatesCanUseFiletimes = checkbox1;
            }

            if (!Directory.Exists(settings.LeftDirectory))
            {
                Utils.MessageErr("Directory does not exist " + settings.LeftDirectory, true);
                return(null);
            }
            else if (!Directory.Exists(settings.RightDirectory) &&
                     action != SortFilesAction.SearchDuplicatesInOneDir)
            {
                Utils.MessageErr("Directory does not exist " + settings.RightDirectory, true);
                return(null);
            }

            if (settings.LeftDirectory.EndsWith(Utils.Sep, StringComparison.Ordinal) ||
                settings.RightDirectory.EndsWith(Utils.Sep, StringComparison.Ordinal))
            {
                Utils.MessageErr("directory should not end with slash.", true);
                return(null);
            }

            if (action != SortFilesAction.SearchDuplicatesInOneDir && !Utils.ArePathsDistinct(
                    settings.LeftDirectory, settings.RightDirectory))
            {
                Utils.MessageErr("directories must be distinct.", true);
                return(null);
            }

            return(settings);
        }
Esempio n. 3
0
        public FormSortFiles(SortFilesAction action)
        {
            InitializeComponent();

            _action                = action;
            _mruHistoryLeft        = new PersistMostRecentlyUsedList(InputBoxHistory.SyncDirectoryLeft);
            _mruHistoryRight       = new PersistMostRecentlyUsedList(InputBoxHistory.SyncDirectoryRight);
            cmbLeftDir.DragDrop   += new DragEventHandler(CmbOnDragDrop);
            cmbLeftDir.DragEnter  += new DragEventHandler(CmbOnDragEnter);
            cmbRightDir.DragDrop  += new DragEventHandler(CmbOnDragDrop);
            cmbRightDir.DragEnter += new DragEventHandler(CmbOnDragEnter);

            RefreshComboListItems();
            AcceptButton     = btnStart;
            cmbLeftDir.Text  = cmbLeftDir.Items.Count > 0 ? cmbLeftDir.Items[0].ToString() : "";
            cmbRightDir.Text = cmbRightDir.Items.Count > 0 ? cmbRightDir.Items[0].ToString() : "";

            if (action != SortFilesAction.SyncFiles)
            {
                btnStart.Text                = "Start...";
                btnShowRobo.Visible          = false;
                txtShowRobo.Visible          = false;
                checkMirror.Visible          = false;
                checkPreview.Visible         = false;
                lblSkipDirs.Visible          = false;
                lblSkipFiles.Visible         = false;
                txtSkipDirs.Visible          = false;
                txtSkipFiles.Visible         = false;
                lblLeftDirDesc.Text          = "Directory #1:";
                lblRightDirDesc.Text         = "Directory #2:";
                checkAllowDifferSeconds.Text = checkAllowDifferSeconds.Text.Replace("$",
                                                                                    SortFilesSearchDifferences.AllowDifferSeconds.ToString());
            }
            else
            {
                checkMirror.Checked          = true;
                checkAllowDifferSeconds.Text = checkAllowDifferSeconds.Text.Replace("$",
                                                                                    SyncFilesWithRobocopy.AllowDifferSeconds.ToString());
            }

            if (action == SortFilesAction.SearchDifferences)
            {
                lblAction.Text = @"Search for differences in two similar folders.";
            }
            else if (action == SortFilesAction.SearchDuplicates)
            {
                lblAction.Text = "Search for duplicate files.";
                checkAllowDifferDST.Visible  = false;
                checkAllowDifferSeconds.Text = "Files with same name, size, " +
                                               "and last-modified time treated as equal (faster)";
            }
            else if (action == SortFilesAction.SearchDuplicatesInOneDir)
            {
                lblAction.Text                  = "Search for duplicate files in a folder.";
                lblLeftDirDesc.Text             = "Directory:";
                lblRightDirDesc.Text            = "";
                btnSetRightDir.Visible          = false;
                cmbRightDir.Visible             = false;
                btnSwap.Visible                 = false;
                checkAllowDifferDST.Visible     = false;
                checkAllowDifferSeconds.Visible = false;
            }
            else if (action == SortFilesAction.SyncFiles)
            {
                lblAction.Text = "Sync files. " +
                                 "Copy changes from the source directory to the destination directory.";
            }
        }