Beispiel #1
0
        private void DoStart()
        {
            SetUpRenamingProcess();
            ListItems.Clear();
            renamer.StartRenaming();

            while (LastExecutedStartFolders.Contains(StartDirectory))
            {
                LastExecutedStartFolders.Remove(StartDirectory);
            }

            LastExecutedStartFolders.Add(StartDirectory);

            IsProcessStartable = false;
            IsProcessAbortable = true;
            IsProcessRunning   = true;
        }
        public RenamerViewModel(IEnumerable <string> lastExecutedStartFolders)
        {
            startCommand = new Command(
                () =>
            {
                SetUpRenamingProcess();
                renamer.StartRenaming();

                LastExecutedStartFolders.Add(StartDirectory);

                IsProcessStartable = false;
                IsProcessAbortable = true;
                IsProcessRunning   = true;
            },

                () =>
            {
                if (!IsProcessStartable)
                {
                    return(false);
                }
                if (string.IsNullOrEmpty(StartDirectory))
                {
                    return(false);
                }

                return(true);
            },
                new PropertyChangedCommandUpdater(this, nameof(IsProcessStartable),
                                                  nameof(StartDirectory))

                );

            abortCommand = new Command(
                () => renamer.AbortRenaming(),
                () => IsProcessAbortable,
                new PropertyChangedCommandUpdater(this, nameof(IsProcessAbortable))
                );

            selectFolderCommand = new Command(
                ShowDirectoryDialog,
                () => !IsProcessRunning,
                new PropertyChangedCommandUpdater(this, nameof(IsProcessRunning))
                );

            undoLastRenamingCommand = new Command(
                () => {
                renamer.UndoRenaming();
                IsProcessStartable = false;
                IsProcessAbortable = false;
                IsProcessRunning   = true;
            },
                () => IsProcessUndoable,
                new PropertyChangedCommandUpdater(this, nameof(IsProcessUndoable))
                );

            LastExecutedStartFolders = new ObservableCollection <string>(lastExecutedStartFolders);

            IsProcessAbortable = false;
            IsProcessStartable = true;
            IsProcessRunning   = false;
            IsProcessUndoable  = false;
        }