示例#1
0
        public Presentation(PresenterManager pm, EditorPresenter editor)
        {
            _pm     = pm;
            _editor = editor;

            _contentInfo = new ContentInfoArbitrationPresenter(_editor);
        }
示例#2
0
        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();
        }
示例#3
0
        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);
        }
示例#4
0
        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();
        }
示例#5
0
        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();
        }
示例#6
0
        public Presentation(EditorPresenter editor)
        {
            _editor = editor;

            _stdTools = new StandardToolsPresenter(_editor);
            _docTools = new DocumentToolsPresenter(_editor);
            _contentInfo = new ContentInfoArbitrationPresenter(_editor);

            _tilePoolList = new TilePoolListPresenter(_editor);
            _objectPoolCollection = new ObjectPoolCollectionPresenter(_editor);
            _tileBrushManager = new TileBrushManagerPresenter(_editor);
            _propertyList = new PropertyListPresenter();
            _projectExplorer = new ProjectExplorerPresenter(_editor);
        }