Beispiel #1
0
        private void SetActiveEditorMode(TilesetEditorMode mode)
        {
            UndoRedoManager.Finish();

            // Reset the layer view selection
            this.layerView.SelectedNode = null;

            if (this.activeMode != null)
            {
                this.activeMode.RaiseOnLeave();
            }

            this.activeMode = mode;

            // Assign the new data model to the layer view
            this.layerView.Model = (this.activeMode != null) ? this.activeMode.LayerModel : null;

            if (this.activeMode != null)
            {
                this.activeMode.RaiseOnEnter();
            }

            // Update tool buttons so the appropriate one is checked
            for (int i = 0; i < this.availableModes.Length; i++)
            {
                EditorModeInfo info = this.availableModes[i];
                info.ToolButton.Checked = (info.Mode == mode);
            }

            // Update Add / Remove layer buttons
            bool canAddRemove = (this.activeMode != null) ?
                                this.activeMode.AllowLayerEditing.HasFlag(LayerEditingCaps.AddRemove) :
                                false;

            this.buttonAddLayer.Visible    = canAddRemove;
            this.buttonRemoveLayer.Visible = canAddRemove;
            this.buttonRemoveLayer.Enabled = (this.layerView.SelectedNode != null);

            // Different editor modes might allow or disallow drawing tile indices
            this.ApplyTileIndexDrawMode();

            // Invalidate TilesetView because editor modes are likely to
            // draw custom overlays using its event handlers. Directly show
            // the effect of having a different editing mode selected.
            this.tilesetView.Invalidate();
        }
Beispiel #2
0
        private void modeToolButton_Click(object sender, EventArgs e)
        {
            EditorModeInfo info = this.availableModes.First(i => i.ToolButton == sender);

            this.SetActiveEditorMode(info.Mode);
        }