Inheritance: IDisposable, ILayerContext, IPointerResponderProvider, ICommandSubscriber, ILayerListPresenter
Esempio n. 1
0
        private void BindLevel(LevelPresenter levelPresenter)
        {
            if (_levelPresenter == levelPresenter)
            {
                return;
            }

            if (_levelPresenter != null)
            {
                _levelPresenter.LevelGeometryInvalidated -= LevelGeometryInvalidated;
                ClearLayers();
            }

            _levelPresenter = levelPresenter;

            if (_levelPresenter != null)
            {
                _levelPresenter.LevelGeometryInvalidated += LevelGeometryInvalidated;
            }

            InitializeLayerHierarchy(levelPresenter);
            InitializeLayers();
            UpdateAreaBox();

            OnCurrentLevelChanged(EventArgs.Empty);
        }
Esempio n. 2
0
        public void BindController(LevelPresenter controller)
        {
            if (_controller != null) {
                _controller.LevelGeometry = null;
                _controller.PointerEventResponderChanged -= PointerEventResponderChanged;
                _controller.ContextMenuActivated -= ContextMenuActivatedHandler;
            }

            _controller = controller;
            if (_controller != null) {
                _controller.LevelGeometry = _layerControl.LevelGeometry;
                _controller.PointerEventResponderChanged += PointerEventResponderChanged;
                _controller.ContextMenuActivated += ContextMenuActivatedHandler;

                _pointerController.Responder = _controller.PointerEventResponder;

                _root = new GroupLayer(controller.RootLayer);

                _layerControl.RootLayer = _root;
                _layerControl.TextureCache.SourcePool = _controller.TexturePool;

                _layerControl.ReferenceOriginX = _controller.Level.OriginX;
                _layerControl.ReferenceOriginY = _controller.Level.OriginY;
                _layerControl.ReferenceWidth = _controller.Level.Width;
                _layerControl.ReferenceHeight = _controller.Level.Height;
            }
            else {
                _root = null;
                _layerControl.RootLayer = null;
                _layerControl.TextureCache.SourcePool = null;

                _pointerController.Responder = null;
            }
        }
Esempio n. 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);
        }
Esempio n. 4
0
        private void InitializeLayerHierarchy(LevelPresenter presenter)
        {
            _rootContentLayer = new GroupLayerPresenter();
            _rootLayer        = new GroupLayerPresenter();

            if (presenter != null)
            {
                _rootLayer.Layers.Add(_rootContentLayer);
                _rootLayer.Layers.Add(new AnnotationLayerPresenter()
                {
                    Annotations = _annotations,
                });
            }
        }
Esempio n. 5
0
 public SyncLevelEventArgs(Level level, LevelPresenter controller)
 {
     PreviousLevel = level;
     PreviousLevelPresenter = controller;
 }
Esempio n. 6
0
 public SyncLevelEventArgs(Level level, LevelPresenter controller)
 {
     PreviousLevel          = level;
     PreviousLevelPresenter = controller;
 }
Esempio n. 7
0
        private void CommandAddLevel()
        {
            if (CommandCanAddLevel()) {
                NewLevel form = new NewLevel(_project);
                if (form.ShowDialog() == DialogResult.OK) {
                    LevelPresenter pres = new LevelPresenter(this, form.Level);
                    _levels[form.Level.Uid] = pres;

                    _openContent.Add(form.Level.Uid);
                    SelectLevel(form.Level.Uid);
                    Presentation.PropertyList.Provider = form.Level;

                    Modified = true;
                    RefreshEditor();
                }
            }
        }
Esempio n. 8
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 && _levels.ContainsKey(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);
        }
Esempio n. 9
0
        public void NewDefault()
        {
            Project prevProject = _project;

            if (_project != null) {
                _project.Modified -= ProjectModifiedHandler;
            }

            _project = EmptyProject();
            _project.Modified += ProjectModifiedHandler;
            //_project.Levels.ResourceRemapped += LevelNameChangedHandler;

            _project.ObjectPoolManager.Pools.Add(new ObjectPool("Default"));

            _openContent = new List<Guid>();
            _levels = new Dictionary<Guid, LevelPresenter>();

            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));

            Level level2 = new Level("Level 2", 0, 0, 800, 480);
            level2.Project = _project;
            level2.Layers.Add(new MultiTileGridLayer("Tile Layer 1", 32, 32, 25, 15));

            LevelPresenter pres = new LevelPresenter(this, level);
            _levels[level.Uid] = pres;

            LevelPresenter pres2 = new LevelPresenter(this, level2);
            _levels[level2.Uid] = pres2;

            _openContent.Add(level.Uid);
            _openContent.Add(level2.Uid);

            _project.Levels.Add(level);
            _project.Levels.Add(level2);

            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();

            OnSyncCurrentProject(new SyncProjectEventArgs(prevProject));

            RefreshEditor();
        }
Esempio n. 10
0
        public void Open(Project project)
        {
            Project prevProject = _project;

            if (_project != null) {
                _project.Modified -= ProjectModifiedHandler;
            }

            _project = project;
            _project.Modified += ProjectModifiedHandler;
            //_project.Levels.ResourceRemapped += LevelNameChangedHandler;

            _currentLevel = Guid.Empty;

            _openContent = new List<Guid>();
            _levels = new Dictionary<Guid, LevelPresenter>();

            PropertyListPresenter propList = _presentation.PropertyList as PropertyListPresenter;

            foreach (Level level in _project.Levels) {
                LevelPresenter pres = new LevelPresenter(this, level);
                _levels[level.Uid] = pres;

                _openContent.Add(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();

            OnSyncCurrentProject(new SyncProjectEventArgs(prevProject));

            RefreshEditor();

            if (CurrentLevel != null) {
                //CurrentLevel.RefreshLayerList();
            }
        }
Esempio n. 11
0
        public void New()
        {
            SelectLevel(Guid.Empty);

            Project project = EmptyProject();

            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;
            //_project.Levels.ResourceRemapped += LevelNameChangedHandler;

            _project.ObjectPoolManager.Pools.Add(new ObjectPool("Default"));

            _openContent = new List<Guid>();
            _levels = new Dictionary<Guid, LevelPresenter>();

            PropertyListPresenter propList = _presentation.PropertyList as PropertyListPresenter;

            foreach (Level level in _project.Levels) {
                LevelPresenter pres = new LevelPresenter(this, level);
                _levels[level.Uid] = pres;

                _openContent.Add(level.Uid);

                if (_currentLevel == Guid.Empty) {
                    SelectLevel(level.Uid);
                    propList.Provider = level; // Initial Property Provider
                }
            }

            //_project.ObjectPoolManager.CreatePool("Default");

            ContentInfoArbitrationPresenter info = _presentation.ContentInfo as ContentInfoArbitrationPresenter;
            info.BindInfoPresenter(CurrentLevel.InfoPresenter);

            Modified = false;
            Project.ResetModified();

            OnSyncCurrentProject(new SyncProjectEventArgs(prevProject));

            RefreshEditor();

            if (CurrentLevel != null) {
                //CurrentLevel.RefreshLayerList();
            }
        }
Esempio n. 12
0
 public LevelInfoPresenter(LevelPresenter level)
 {
     _level = level;
     _level.Zoom.ZoomLevelChanged += ZoomStateChanged;
 }
Esempio n. 13
0
        private void InitializeLayerHierarchy(LevelPresenter presenter)
        {
            _rootContentLayer = new GroupLayerPresenter();
            _rootLayer = new GroupLayerPresenter();

            if (presenter != null) {
                _rootLayer.Layers.Add(_rootContentLayer);
                _rootLayer.Layers.Add(new AnnotationLayerPresenter() {
                    Annotations = _annotations,
                });
            }
        }
Esempio n. 14
0
        private void BindLevel(LevelPresenter levelPresenter)
        {
            if (_levelPresenter == levelPresenter)
                return;

            if (_levelPresenter != null) {
                _levelPresenter.LevelGeometryInvalidated -= LevelGeometryInvalidated;
                ClearLayers();
            }

            _levelPresenter = levelPresenter;

            if (_levelPresenter != null) {
                _levelPresenter.LevelGeometryInvalidated += LevelGeometryInvalidated;
            }

            InitializeLayerHierarchy(levelPresenter);
            InitializeLayers();
            UpdateAreaBox();

            OnCurrentLevelChanged(EventArgs.Empty);
        }
Esempio n. 15
0
 public LevelInfoPresenter(LevelPresenter level)
 {
     _level = level;
     _level.Zoom.ZoomLevelChanged += ZoomStateChanged;
 }