Esempio n. 1
0
        private async void UndoExecute()
        {
            _buffer        = new int[MainImage.PixelWidth * MainImage.PixelHeight];
            _maskBuffer    = new byte[MainImage.PixelWidth * MainImage.PixelHeight];
            _filterApplied = false;

            _originalStream.Seek(0, SeekOrigin.Begin);
            _editingSession = await EditingSessionFactory.CreateEditingSessionAsync(_originalStream);

            await _editingSession.RenderToWriteableBitmapAsync(MainImage);

            MainImage.Invalidate();

            CanApply   = false;
            _noChanges = true;
            UndoCommand.RaiseCanExecuteChanged();

            if (PreviewImage != null)
            {
                for (var i = 0; i < PreviewImage.Pixels.Length; ++i)
                {
                    PreviewImage.Pixels[i] = 0;
                }
                PreviewImage.Invalidate();
            }

            BindTool();
        }
Esempio n. 2
0
        private void OnLoadText(TabInfo tabInfo)
        {
            if (tabInfo.Guid != _fileGuid || _textEditor == null)
            {
                return;
            }

            Reset(() =>
            {
                IsReadOnly   = tabInfo.IsReadOnly;
                IsShowEditor = tabInfo.IsShowEditor;

                _fileGuid        = tabInfo.Guid;
                _textEditor.Text = tabInfo.FileContent;
            });

            if (IsSelected)
            {
                CompileCommand.RaiseCanExecuteChanged();
                RedoCommand.RaiseCanExecuteChanged();
                UndoCommand.RaiseCanExecuteChanged();

                _textEditor.Focus();
                CaretPosChanged();

                if (AutoCompile || IsReadOnly)
                {
                    Compile(tabInfo.FileContent);
                }
            }
        }
Esempio n. 3
0
        private void DeleteModelImpl(DeleteModelCommand command)
        {
            List <ModelBase> modelsToDelete = new List <ModelBase>();

            if (command.ModelGuid != Guid.Empty)
            {
                modelsToDelete.Add(CurrentSpace.GetModelInternal(command.ModelGuid));
            }
            else
            {
                // When nothing is specified then it means all selected models.
                foreach (ISelectable selectable in DynamoSelection.Instance.Selection)
                {
                    if (selectable is ModelBase)
                    {
                        modelsToDelete.Add(selectable as ModelBase);
                    }
                }
            }

            model.DeleteModelInternal(modelsToDelete);

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
        }
Esempio n. 4
0
        private void SendModelEventImpl(ModelEventCommand command)
        {
            CurrentSpace.SendModelEvent(command.ModelGuid, command.EventName);

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
        }
Esempio n. 5
0
        private void LeaseBook()
        {
            Action redo = () =>
            {
                SelectedBook.LeasedTo = Session.Current.LoggedInUser;

                LeaseCommand.RaiseCanExecuteChanged();
                OnPropertyChanged("SelectedBook");
                BookList.Refresh();
            };
            Action undo = () =>
            {
                SelectedBook.LeasedTo = string.Empty;

                LeaseCommand.RaiseCanExecuteChanged();
                OnPropertyChanged("SelectedBook");
                BookList.Refresh();
            };

            history.AddAndExecute(new RevertableCommand(redo, undo));
            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();

            ClientLogger.Log($"{Session.Current.LoggedInUser} leased book {selectedBook.BookName}", Common.LogLevel.Info);
        }
Esempio n. 6
0
        private void Undo()
        {
            _textEditor.Undo();

            RedoCommand.RaiseCanExecuteChanged();
            UndoCommand.RaiseCanExecuteChanged();
        }
Esempio n. 7
0
 private void ExecuteRedoCommand(object parameter)
 {
     txt.Text        = "Redo Command executed";
     _canExecuteUndo = true;
     _canExecuteRedo = false;
     UndoCommand.RaiseCanExecuteChanged();
     RedoCommand.RaiseCanExecuteChanged();
 }
Esempio n. 8
0
        private void UpdateModelValueImpl(UpdateModelValueCommand command)
        {
            CurrentSpace.UpdateModelValue(command.ModelGuid,
                                          command.Name, command.Value);

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
        }
Esempio n. 9
0
        private void ConvertNodesToCodeImpl(ConvertNodesToCodeCommand command)
        {
            CurrentSpace.ConvertNodesToCodeInternal(command.NodeId);

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
            CurrentSpace.HasUnsavedChanges = true;
        }
 /// <summary>
 /// Updates UI bound to the view model properties.
 /// </summary>
 private void UpdateView()
 {
     SyncModelProperties();
     UpdateBoard();
     UndoCommand.RaiseCanExecuteChanged();
     RedoCommand.RaiseCanExecuteChanged();
     MoveCommand.RaiseCanExecuteChanged();
 }
 private void ExecuteClearFormatCommand(object parameter)
 {
     txt.Text        = Strings.RadialMenuClear;
     _canExecuteUndo = true;
     _canExecuteRedo = false;
     UndoCommand.RaiseCanExecuteChanged();
     RedoCommand.RaiseCanExecuteChanged();
 }
Esempio n. 12
0
        public void SetComposition(Composition composition)
        {
            var lilypondText = LilypondFactory.GetLilypond(composition);

            LilypondTextLoaded(lilypondText);

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
        }
Esempio n. 13
0
        private void CreateNoteImpl(CreateNoteCommand command)
        {
            NoteModel noteModel = Model.AddNoteInternal(command, null);

            CurrentSpace.RecordCreatedModel(noteModel);

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
        }
        private void UpdateCommands()
        {
            RemoveImageCommand.RaiseCanExecuteChanged();
            SaveCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
            UndoCommand.RaiseCanExecuteChanged();

            RemoveBackgroundCommand.RaiseCanExecuteChanged();
            RemoveOverlayCommand.RaiseCanExecuteChanged();
        }
Esempio n. 15
0
 public void LilypondTextLoaded(string text)
 {
     _textChangedByLoad = true;
     _caretaker.reset();
     LilypondText = text;
     _caretaker.change();
     UndoCommand.RaiseCanExecuteChanged();
     RedoCommand.RaiseCanExecuteChanged();
     _textChangedByLoad = false;
 }
Esempio n. 16
0
 public void ManipulationEnded(ManipulationCompletedEventArgs e)
 {
     if (SelectedTool != null && !IsWorking)
     {
         SelectedTool.Ended(e);
         CanApply   = true;
         _noChanges = false;
         UndoCommand.RaiseCanExecuteChanged();
     }
 }
Esempio n. 17
0
 private void OnLevelPropertyChanged(Object sender, PropertyChangedEventArgs e)
 {
     if ("CanUndo".Equals(e.PropertyName))
     {
         UndoCommand.RaiseCanExecuteChanged();
     }
     else if ("CanRedo".Equals(e.PropertyName))
     {
         RedoCommand.RaiseCanExecuteChanged();
     }
 }
        private void UndoRedoManagerOnPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            if (args.IsProperty<UndoRedoManager>(i => i.CanUndo))
            {
                UndoCommand.RaiseCanExecuteChanged();

                SaveDocumentCommand.RaiseCanExecuteChanged();
                SaveDocumentAsCommand.RaiseCanExecuteChanged();
            }

            if (args.IsProperty<UndoRedoManager>(i => i.CanRedo))
                RedoCommand.RaiseCanExecuteChanged();
        }
Esempio n. 19
0
        private void UndoRedoImpl(UndoRedoCommand command)
        {
            if (command.CmdOperation == UndoRedoCommand.Operation.Undo)
            {
                CurrentSpace.Undo();
            }
            else if (command.CmdOperation == UndoRedoCommand.Operation.Redo)
            {
                CurrentSpace.Redo();
            }

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
        }
Esempio n. 20
0
        private void CreateNoteImpl(CreateNoteCommand command)
        {
            NoteModel noteModel = Model.CurrentWorkspace.AddNote(
                command.DefaultPosition,
                command.X,
                command.Y,
                command.NoteText,
                command.NodeId);

            CurrentSpace.RecordCreatedModel(noteModel);

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
        }
        //Summary
        //    Commit changes to data source, after commit, clear undo/redo list
        public void Commit()
        {
            _selectedVertices.Clear();
            _operations.Clear();
            _operationsRedo.Clear();

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
            HasChange = false;

            IsInEditing = false;

            PostStatusMessage("Ready");
        }
Esempio n. 22
0
        private void CreateNodeImpl(CreateNodeCommand command)
        {
            NodeModel nodeModel = CurrentSpace.AddNode(
                command.NodeId,
                command.NodeName,
                command.X,
                command.Y,
                command.DefaultPosition,
                command.TransformCoordinates);

            CurrentSpace.RecordCreatedModel(nodeModel);

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
        }
Esempio n. 23
0
        private void OnIsActiveChanged()
        {
            SaveCommand.RaiseCanExecuteChanged();

            CompileCommand.IsActive = IsActive;
            CompileCommand.RaiseCanExecuteChanged();

            RedoCommand.IsActive = IsActive;
            RedoCommand.RaiseCanExecuteChanged();

            UndoCommand.IsActive = IsActive;
            UndoCommand.RaiseCanExecuteChanged();

            IsActiveChanged?.Invoke(this, new EventArgs());
        }
Esempio n. 24
0
        private void RedoUndoModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case "CanRedoOneStep":
                RedoCommand.RaiseCanExecuteChanged();
                break;

            case "CanUndoOneStep":
                UndoCommand.RaiseCanExecuteChanged();
                break;

            default:
                break;
            }
        }
Esempio n. 25
0
        protected void UpdateCanPassAndUndo()
        {
            if (IsTimelineInPast)
            {
                CanUndo = false;
                CanPass = false;
                return;
            }

            CanPass = (this.Game?.Controller?.TurnPlayer?.IsHuman ?? false) ? true : false;
            // TODO (future work)  Petr this allows to undo before the beginning of the game and causes exception
            if (this.Game?.Controller?.GameTree == null)
            {
                // Game not yet initialized.
                CanUndo = false;
            }
            else if (this.Game.Controller.Players.Any(pl => pl.IsHuman))
            {
                if (Game.Controller.GameTree.LastNode.Equals(Game.Controller.GameTree.GameTreeRoot))
                {
                    CanUndo = false;
                }
                else
                {
                    bool undoPossible = this.Game.Controller.GameTree.PrimaryMoveTimeline.Any(
                        move =>
                    {
                        if (move.WhoMoves == StoneColor.None)
                        {
                            return(false);
                        }
                        return(this.Game.Controller.Players[move.WhoMoves].IsHuman);
                    });

                    CanUndo = undoPossible;
                }
            }
            else
            {
                // No player is a local human.
                CanUndo = false;
            }

            PassCommand.RaiseCanExecuteChanged();
            UndoCommand.RaiseCanExecuteChanged();
        }
Esempio n. 26
0
        public LilypondViewModel(MainViewModel mainViewModel, MusicLoader musicLoader)
        {
            // TODO: Can we use some sort of eventing system so the managers layer doesn't have to know the viewmodel layer and viewmodels don't know each other?
            // And viewmodels don't
            _mainViewModel = mainViewModel;
            _musicLoader   = musicLoader;
            _musicLoader.LilypondViewModel = this;

            _text           = new LilypondText();
            _caretaker      = new LilypondTextCaretaker(_text);
            _movedInHistory = false;

            LilypondText = "Your lilypond text will appear here.";
            _caretaker.change();
            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
        }
        //Summary
        //    Execute new operaton and put the operation in to undoable list
        public void Do(IOperation operation)
        {
            operation.Do();
            HasChange = true;
            _operations.Insert(0, operation);

            foreach (var v in _operationsRedo)
            {
                v.Dispose();
            }

            _operationsRedo.Clear();

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();

            if (!string.IsNullOrEmpty(operation.Sammary))
            {
                PostStatusMessage(operation.Sammary);
            }
        }
        void ExecuteRedo()
        {
            var op = OperationsRedo.FirstOrDefault();

            if (op == null || !op.IsUnDoable)
            {
                return;
            }

            op.Do();

            OperationsRedo.Remove(op);
            Operations.Insert(0, op);

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();

            if (!string.IsNullOrEmpty(op.Sammary))
            {
                PostStatusMessage("Redo " + op.Sammary);
            }
        }
 private void UndoEvent()
 {
     _Events.RemoveAt(0);
     UpdateLastEvent();
     UndoCommand.RaiseCanExecuteChanged();
 }
 private void AddEvent(MatchEvent matchEvent)
 {
     _Events.Insert(0, matchEvent);
     UpdateLastEvent();
     UndoCommand.RaiseCanExecuteChanged();
 }