public UndoRedoValueWrapper(IUndoRedoStack undoRedoStack, T defaultValue = default, string propertyName = null, Action <string> notifyAction = null) { _undoRedoStack = undoRedoStack; _value = defaultValue; _propertyName = propertyName; _notifyAction = notifyAction; }
/// <summary> /// Initializes a new instance of the <see cref="MenuViewModel"/> class. /// </summary> /// <param name="eventAggregator"> /// The event aggregator. /// </param> public MenuViewModel(IEventAggregator eventAggregator) { this.undoRedo = this.Container.Resolve<IUndoRedoStack>(ServiceNames.UndoRedoStackService); // Add event aggregator for undo redo this.undoRedo.addAggregator(eventAggregator); // Listen undo redo changes eventAggregator.GetEvent<UndoRedoChangedEvent>().Subscribe(this.UndoRedoChanged); // About view this.AboutViewRequest = new InteractionRequest<INotification>(); this.CanUndo = this.undoRedo.CanUndo; this.CanRedo = this.undoRedo.CanRedo; this.eventAggregator = eventAggregator; this.CreateAndRegisterCommandBindings(); this.MenuItemCommand = new DelegateCommand<GameActions?>( exeCuteParam => { if (exeCuteParam != null) { if (exeCuteParam == GameActions.About) { // Open about view this.AboutViewRequest.Raise( new Notification { Title = "About", Content = string.Empty }); } // Other menu item command actions broadcast this.eventAggregator.GetEvent<GameActionEvent>().Publish(exeCuteParam.Value); } }, this.CanExecute).ObservesProperty(() => this.CanUndo).ObservesProperty(() => this.CanRedo); }
public CommandHandler( [Import(typeof(IUndoRedoStack <UndoableCommandBase>))] IUndoRedoStack <UndoableCommandBase> undoRedoHandler) { stack = undoRedoHandler; }
public CommandHandler( [Import(typeof(IUndoRedoStack<ICommand>))] IUndoRedoStack<ICommand> undoRedoHandler) { stack = undoRedoHandler; }
protected EditorViewModelBase(IUndoRedoStack undoRedo, params object[] watchedModels) : base(MetaViewModel.Current.ModelChangeNotifier, watchedModels) { undoRedoStack = undoRedo; }
public EditorEnvironment(ITreeNodeFactory nodeFactory, IUndoRedoStack undoRedoStack) { NodeFactory = nodeFactory; UndoRedoStack = undoRedoStack; }
public UndoRedoValueWrapper(IUndoRedoStack undoRedoStack, string propertyName = null, Action <string> notifyAction = null) : this(undoRedoStack, default, propertyName, notifyAction) { }
public UndoRedoListWrapper(IUndoRedoStack undoRedoStack, IList <T> list) { _undoRedoStack = undoRedoStack; List = list; }
public CommandHandler( [Import(typeof(IUndoRedoStack <ICommand>))] IUndoRedoStack <ICommand> undoRedoHandler) { stack = undoRedoHandler; }
public RedoButton(IUndoRedoStack undoRedoStack, string description, string image) : this(undoRedoStack, description, image, true);
public RedoButton(IUndoRedoStack undoRedoStack, string description, string image, bool isEnabled) : base(new Command(() => { undoRedoStack.Redo(); }), description, image, isEnabled);
/// <summary> /// Initializes a new instance of the <see cref="GameAreaViewModel"/> class. /// </summary> /// <param name="eventAggregator"> /// The event Aggregator. /// </param> public GameAreaViewModel(IEventAggregator eventAggregator) { // Players service to use this.players = this.Container.Resolve<IPlayers>(ServiceNames.PlayersService); this.PlayersList = this.players.PlayersList; this.eventAggregator = eventAggregator; // Messaging this.eventAggregator.GetEvent<GameStateEvent>().Subscribe(this.GameStateChange); this.eventAggregator.GetEvent<GameActionEvent>().Subscribe(this.GameActionEvent); // Game service to use this.game = this.Container.Resolve<IGame>(ServiceNames.GameService); // Undo redo stack to use as undo redo turns this.undoRedo = this.Container.Resolve<IUndoRedoStack>(ServiceNames.UndoRedoStackService); // this.BoardTiles = new ObservableCollection<BoardTile>(); this.AddBoardTiles(); // this.StoreState(); // Mousedown means that tile is clicked. This handles what to do // Different game states make it work differently this.MouseDownDelegateCommand = new DelegateCommand<BoardTile>( exeCuteParam => { var piece = this.selectedPiece; if (piece != null) piece.IsSelected = false; this.selectedPiece = null; if (exeCuteParam == null) { return; } if ((this.game.GameState != GameStates.MovePiece && this.game.GameState != GameStates.SpecialState) || this.game.CurrentPlayer != exeCuteParam.Owner) return; this.HighLightPossibleMoves(exeCuteParam); foreach (var boardTile in this.BoardTiles.Where(boardTile => boardTile.DropAllowed)) { this.selectedPiece = exeCuteParam; this.selectedPiece.IsSelected = true; } }); // Mouse button is up. If eat state do eat. this.MouseUpDelegateCommand = new DelegateCommand<BoardTile>( exeCuteParam => { if (exeCuteParam == null) { return; } if (this.game.GameState == GameStates.EatPiece) { this.EatPieceIfAllowed(exeCuteParam); } foreach (var tile in this.BoardTiles) { // Remove allowed moves tile.Thickness = 0; tile.DropAllowed = false; } }); this.BoardTileClickDelegateCommand = new DelegateCommand<BoardTile>(this.MakeMove); }
public static void ExecuteAndPush(this IUndoRedoStack stack, IUndoRedoCommand command) { command.Redo(); stack.Push(command); }