private void setControlsFromDefinition(LayerDefinition definition)
        {
            //Enabled stuff
            removeButton.Enabled = true;
            moveUpButton.Enabled = listBox.SelectedIndex > 0;
            moveDownButton.Enabled = listBox.SelectedIndex < listBox.Items.Count - 1;
            nameTextBox.Enabled = true;
            gridXTextBox.Enabled = true;
            gridYTextBox.Enabled = true;
            scrollXTextBox.Enabled = true;
            scrollYTextBox.Enabled = true;
            typeComboBox.Enabled = true;

            //Load properties
            nameTextBox.Text = definition.Name;
            gridXTextBox.Text = definition.Grid.Width.ToString();
            gridYTextBox.Text = definition.Grid.Height.ToString();
            scrollXTextBox.Text = definition.ScrollFactor.X.ToString();
            scrollYTextBox.Text = definition.ScrollFactor.Y.ToString();
            typeComboBox.SelectedIndex = LayerDefinition.LAYER_TYPES.FindIndex(e => e == definition.GetType());

            //Remove the old layer editor
            if (layerEditor != null)
                Controls.Remove(layerEditor);

            //Add the new one
            layerEditor = definition.GetEditor();
            if (layerEditor != null)
            {
                layerEditor.TabIndex = 6;
                Controls.Add(layerEditor);
            }
        }
Beispiel #2
0
        private void onLayerChanged(LayerDefinition def, int index)
        {
            Controls.Clear();

            if (def != null)
            {
                tools = toolsForLayerTypes[def.GetType()];

                for (int i = 0; i < tools.Length; i++)
                    Controls.Add(new ToolButton(tools[i], (i % 2) * 24, (i / 2) * 24, i));

                if (tools.Length > 0)
                    SetTool(tools[0]);
                else
                    ClearTool();
            }
        }