コード例 #1
0
        public override bool SaveEditText(string newName)
        {
            if (Name.Equals(newName))
            {
                return(false);
            }

            NonCancellableOperationProgressView progress        = new NonCancellableOperationProgressView();
            RenameDirectoryViewModel            renameDirectory = new RenameDirectoryViewModel(FullName, newName);

            progress.DataContext = renameDirectory;

            Task <bool> task = Task <bool> .Run(() =>
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    progress.ShowDialog();
                }));

                bool result = renameDirectory.doRename();

                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    progress.Close();
                }));

                return(result);
            });

            WaitWithPumping(task);

            if (task.Result == true)
            {
                Name = newName;
                nodePropertyChanged(this);
            }
            return(task.Result);
        }
コード例 #2
0
        public override bool SaveEditText(string newName)
        {
            if (Name.Equals(newName)) return(false);
           
            NonCancellableOperationProgressView progress = new NonCancellableOperationProgressView();
            RenameDirectoryViewModel renameDirectory = new RenameDirectoryViewModel(FullName, newName);
            progress.DataContext = renameDirectory;

            Task<bool> task = Task<bool>.Run(() =>
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    progress.ShowDialog();
                }));

                bool result = renameDirectory.doRename();
             
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    progress.Close();
                }));

                return (result);
            });

            WaitWithPumping(task);

            if (task.Result == true)
            {
                Name = newName; 
                nodePropertyChanged(this);
            }
            return (task.Result);
           
        }