private void SelectLevel(Guid levelUid) { Level prev = _project.Levels.Contains(levelUid) ? _project.Levels[levelUid] : null; LevelPresenter prevLevel = _currentLevelRef; if (_currentLevel == levelUid) { return; } // Unbind previously selected layer if necessary if (_currentLevelRef != null) { _currentLevelRef.Deactivate(); _commandManager.RemoveCommandSubscriber(_currentLevelRef); } _currentLevel = Guid.Empty; _currentLevelRef = null; // Bind new layer if (levelUid != null && _levelContentController.ContentIsValid(levelUid)) { _currentLevel = levelUid; _currentLevelRef = CurrentLevel; _commandManager.AddCommandSubscriber(_currentLevelRef); if (!_project.Levels.Contains(levelUid)) { throw new InvalidOperationException("Selected a LevelPresenter with no corresponding model Level! Selected name: " + levelUid); } ContentInfoArbitrationPresenter info = _presentation.ContentInfo as ContentInfoArbitrationPresenter; info.BindInfoPresenter(CurrentLevel.InfoPresenter); CurrentLevel.InfoPresenter.RefreshContentInfo(); CurrentLevel.Activate(); } else { ContentInfoArbitrationPresenter info = _presentation.ContentInfo as ContentInfoArbitrationPresenter; info.BindInfoPresenter(null); } InvalidateLevelCommands(); CommandManager.Invalidate(CommandKey.ViewGrid); OnSyncCurrentLevel(new SyncLevelEventArgs(prev, prevLevel)); OnSyncContentView(EventArgs.Empty); }
private void InitializeCommandManager() { _commandManager = new ForwardingCommandManager(); _commandManager.AddCommandSubscriber(Manager.Lookup <TilePoolListPresenter>()); _commandManager.AddCommandSubscriber(Manager.Lookup <ObjectPoolCollectionPresenter>()); _commandManager.AddCommandSubscriber(Manager.Lookup <TileBrushManagerPresenter>()); _commandManager.Register(CommandKey.NewProject, CommandCanCreateProject, CommandCreateProject); _commandManager.Register(CommandKey.OpenProject, CommandCanOpenProject, CommandOpenProject); _commandManager.Register(CommandKey.Save, CommandCanSaveProject, CommandSaveProject); _commandManager.Register(CommandKey.SaveAs, CommandCanSaveProjectAs, CommandSaveProjectAs); _commandManager.Register(CommandKey.Exit, CommandCanExit, CommandExit); _commandManager.Register(CommandKey.ProjectAddLevel, CommandCanAddLevel, CommandAddLevel); _commandManager.Register(CommandKey.LevelClose, CommandCanCloseLevel, CommandCloseLevel); _commandManager.Register(CommandKey.LevelCloseAllOther, CommandCanCloseAllOtherLevels, CommandCloseAllOtherLevels); _commandManager.Register(CommandKey.LevelOpen, _levelCommandActions.CanOpenLevel, _levelCommandActions.CommandOpen); _commandManager.Register(CommandKey.LevelClone, _levelCommandActions.LevelExists, _levelCommandActions.CommandClone); _commandManager.Register(CommandKey.LevelDelete, _levelCommandActions.LevelExists, _levelCommandActions.CommandDelete); _commandManager.Register(CommandKey.LevelRename, _levelCommandActions.LevelExists, _levelCommandActions.CommandRename); _commandManager.Register(CommandKey.LevelProperties, _levelCommandActions.LevelExists, _levelCommandActions.CommandProperties); }
private void SetCurrentTool(PointerTool tool) { ObjectSelectTool objTool = _currentTool as ObjectSelectTool; if (objTool != null) { objTool.Cancel(); _selectionManager.ClearSelection(); _commandManager.RemoveCommandSubscriber(objTool); } _currentTool = tool; objTool = _currentTool as ObjectSelectTool; if (objTool != null && objTool.CommandManager != null) { _commandManager.AddCommandSubscriber(objTool); } }
private void InitializeCommandManager() { _commandManager = new ForwardingCommandManager(); _commandManager.AddCommandSubscriber(_presentation.TilePoolList); _commandManager.AddCommandSubscriber(_presentation.ObjectPoolCollection); _commandManager.AddCommandSubscriber(_presentation.TileBrushes); _commandManager.Register(CommandKey.NewProject, CommandCanCreateProject, CommandCreateProject); _commandManager.Register(CommandKey.OpenProject, CommandCanOpenProject, CommandOpenProject); _commandManager.Register(CommandKey.Save, CommandCanSaveProject, CommandSaveProject); _commandManager.Register(CommandKey.SaveAs, CommandCanSaveProjectAs, CommandSaveProjectAs); _commandManager.Register(CommandKey.Exit, CommandCanExit, CommandExit); _commandManager.Register(CommandKey.ProjectAddLevel, CommandCanAddLevel, CommandAddLevel); //_commandManager.RegisterToggle(CommandKey.ViewGrid); //_commandManager.Perform(CommandKey.ViewGrid); }