Beispiel #1
0
        public void BindTilePoolController(TilePoolListPresenter controller)
        {
            if (_tilePool != null)
            {
                _tilePool.TileSelectionChanged -= TileSelectionChangedHandler;
            }

            _tilePool = controller;

            if (_tilePool != null)
            {
                _tilePool.TileSelectionChanged += TileSelectionChangedHandler;
            }
        }
Beispiel #2
0
        public void BindController(TilePoolListPresenter controller)
        {
            if (_controller == controller)
            {
                return;
            }

            if (_controller != null)
            {
                _controller.SyncTilePoolManager     -= SyncTilePoolManagerHandler;
                _controller.SyncTilePoolList        -= SyncTilePoolListHandler;
                _controller.SyncTilePoolControl     -= SyncTilePoolControlHandler;
                _controller.SelectedTilePoolChanged -= SelectedTilePoolChangedHandler;
            }

            _controller = controller;

            if (_controller != null)
            {
                _controller.SyncTilePoolManager     += SyncTilePoolManagerHandler;
                _controller.SyncTilePoolList        += SyncTilePoolListHandler;
                _controller.SyncTilePoolControl     += SyncTilePoolControlHandler;
                _controller.SelectedTilePoolChanged += SelectedTilePoolChangedHandler;

                _commandController.BindCommandManager(_controller.CommandManager);

                BindTilePoolManager(_controller.TilePoolManager);
                BindTilePool(_controller.SelectedTilePool);
            }
            else
            {
                _commandController.BindCommandManager(null);

                BindTilePoolManager(null);
                BindTilePool(null);

                ResetComponent();
            }

            RebuildPoolList();
        }
        public void BindTileController(TilePoolListPresenter controller)
        {
            if (_tileController != null)
            {
                _tileController.SyncTilePoolList -= SyncTilePoolListHandler;
            }

            _tileController = controller;
            _tilePanel.BindController(controller);

            if (_tileController != null)
            {
                _tileController.SyncTilePoolList     += SyncTilePoolListHandler;
                _layerControl.TextureCache.SourcePool = _tileController.TilePoolManager.TexturePool;
            }
            else
            {
                _layerControl.TextureCache.SourcePool = null;
            }

            InitializeTileSizeList();
        }
        public void ActionEditBrush(Guid brushId)
        {
            TileBrush brush = TileBrushManager.GetBrush(brushId) as TileBrush;
            if (brush == null)
                return;

            if (brush is DynamicTileBrush) {
                using (DynamicBrushForm form = new DynamicBrushForm(brush as DynamicTileBrush)) {
                    PresenterManager manager = new PresenterManager();
                    manager.Register<EditorPresenter>(_editor);

                    using (TilePoolListPresenter tilePoolList = new TilePoolListPresenter()) {
                        tilePoolList.Initialize(manager);
                        tilePoolList.BindTilePoolManager(_editor.Project.TilePoolManager);
                        form.BindTileController(tilePoolList);

                        foreach (TileBrush item in TileBrushManager.Brushes)
                            if (item.Name != brush.Name)
                                form.ReservedNames.Add(item.Name);

                        if (form.ShowDialog() == DialogResult.OK) {
                            OnSyncTileBrushCollection(EventArgs.Empty);
                            SelectBrush(form.Brush.Uid);
                            OnTileBrushSelected(EventArgs.Empty);
                        }
                    }
                }
            }
            else if (brush is StaticTileBrush) {
                using (StaticBrushForm form = new StaticBrushForm(brush as StaticTileBrush)) {
                    PresenterManager manager = new PresenterManager();
                    manager.Register<EditorPresenter>(_editor);

                    using (TilePoolListPresenter tilePoolList = new TilePoolListPresenter()) {
                        tilePoolList.Initialize(manager);
                        tilePoolList.BindTilePoolManager(_editor.Project.TilePoolManager);
                        form.BindTileController(tilePoolList);

                        foreach (TileBrush item in TileBrushManager.Brushes)
                            if (item.Name != brush.Name)
                                form.ReservedNames.Add(item.Name);

                        if (form.ShowDialog() == DialogResult.OK) {
                            OnSyncTileBrushCollection(EventArgs.Empty);
                            SelectBrush(form.Brush.Uid);
                            OnTileBrushSelected(EventArgs.Empty);
                        }
                    }
                }
            }
        }
        private void CommandCreateStaticBrush()
        {
            if (CommandCanCreateStaticBrush()) {
                using (StaticBrushForm form = new StaticBrushForm()) {
                    PresenterManager manager = new PresenterManager();
                    manager.Register<EditorPresenter>(_editor);

                    using (TilePoolListPresenter tilePoolList = new TilePoolListPresenter()) {
                        tilePoolList.Initialize(manager);
                        tilePoolList.BindTilePoolManager(_editor.Project.TilePoolManager);
                        form.BindTileController(tilePoolList);

                        foreach (TileBrush item in TileBrushManager.Brushes)
                            form.ReservedNames.Add(item.Name);

                        if (form.ShowDialog() == DialogResult.OK) {
                            if (TileBrushManager.StaticBrushCollections.Count(c => c.GetBrush(form.Brush.Uid) != null) == 0)
                                TileBrushManager.DefaultStaticBrushCollection.Brushes.Add(form.Brush);

                            OnSyncTileBrushCollection(EventArgs.Empty);
                            SelectBrush(form.Brush.Uid);
                            OnTileBrushSelected(EventArgs.Empty);
                        }
                    }
                }
            }
        }
Beispiel #6
0
        public void BindTilePoolController(TilePoolListPresenter controller)
        {
            if (_tilePool != null) {
                _tilePool.TileSelectionChanged -= TileSelectionChangedHandler;
            }

            _tilePool = controller;

            if (_tilePool != null) {
                _tilePool.TileSelectionChanged += TileSelectionChangedHandler;
            }
        }
Beispiel #7
0
 public void BindTileController(TilePoolListPresenter controller)
 {
     _tileController = controller;
 }