public void New() { SelectLevel(Guid.Empty); Project project = EmptyProject(); Program.CurrentProject = project; NewLevel form = new NewLevel(project); if (form.ShowDialog() != DialogResult.OK) { return; } Project prevProject = _project; if (_project != null) { _project.Modified -= ProjectModifiedHandler; } _project = project; _project.Modified += ProjectModifiedHandler; OnSyncCurrentProject(new SyncProjectEventArgs(prevProject)); _project.ObjectPoolManager.Pools.Add(new ObjectPool("Default")); PropertyListPresenter propList = _presentation.PropertyList as PropertyListPresenter; foreach (Level level in _project.Levels) { _content.OpenContent(level.Uid); if (_currentLevel == Guid.Empty) { SelectLevel(level.Uid); propList.Provider = level; // Initial Property Provider } } ContentInfoArbitrationPresenter info = _presentation.ContentInfo as ContentInfoArbitrationPresenter; info.BindInfoPresenter(CurrentLevel.InfoPresenter); Modified = false; Project.ResetModified(); RefreshEditor(); }
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); }
public void Open(Project project) { if (PromptCancelIfModified()) { return; } Program.CurrentProject = project; Project prevProject = _project; if (_project != null) { _project.Modified -= ProjectModifiedHandler; } _project = project; _project.Modified += ProjectModifiedHandler; OnSyncCurrentProject(new SyncProjectEventArgs(prevProject)); _currentLevel = Guid.Empty; PropertyListPresenter propList = _presentation.PropertyList as PropertyListPresenter; foreach (Level level in _project.Levels) { _levelContentController.OpenContent(level.Uid); if (_currentLevel == Guid.Empty) { SelectLevel(level.Uid); propList.Provider = level; // Initial Property Provider } } if (CurrentLevel != null) { ContentInfoArbitrationPresenter info = _presentation.ContentInfo as ContentInfoArbitrationPresenter; info.BindInfoPresenter(CurrentLevel.InfoPresenter); } Modified = false; Project.ResetModified(); RefreshEditor(); }
public void NewDefault() { Project prevProject = _project; if (_project != null) { _project.Modified -= ProjectModifiedHandler; } _project = EmptyProject(); _project.ObjectPoolManager.Pools.Add(new ObjectPool("Default")); _project.Modified += ProjectModifiedHandler; Program.CurrentProject = _project; OnSyncCurrentProject(new SyncProjectEventArgs(prevProject)); Level level = new Level("Level 1", 0, 0, 800, 480); level.Project = _project; level.Layers.Add(new MultiTileGridLayer("Tile Layer 1", 16, 16, 50, 30)); _project.Levels.Add(level); SelectLevel(level.Uid); PropertyListPresenter propList = _presentation.PropertyList as PropertyListPresenter; propList.Provider = level; ContentInfoArbitrationPresenter info = _presentation.ContentInfo as ContentInfoArbitrationPresenter; info.BindInfoPresenter(CurrentLevel.InfoPresenter); Modified = false; Project.ResetModified(); _content.OpenContent(level.Uid); RefreshEditor(); }