private void btnAddLayer_Click(object sender, EventArgs e) { string layerName; int layerWidth; int layerHeight; TileLayer layer; LayerForm Form = new LayerForm(LayerList.Items.Count); Form.ShowDialog(); if (Form.OkPressed) { layerName = Form.txtLayerName.Text; layerWidth = int.Parse(Form.txtLayrWidth.Text); layerHeight = int.Parse(Form.txtLayHeight.Text); layer = new TileLayer(layerWidth, layerHeight); dictLayer.Add(layerName, layer); LayerList.Items.Add(layerName); Map.Addlayer(layer); currentLayer = layer; foreach (string s in TextureList.Items) { currentLayer.AddTexture(dictTextures[s]); } LayerList.SetSelected(LayerList.Items.Count - 1, true); } }
private void btnRemoveLayer_Click(object sender, EventArgs e) { if (LayerList.SelectedItem != null) { //currentLayer = null; Map.RemoveLayer(dictLayer[LayerList.SelectedItem as string]); dictLayer.Remove(LayerList.SelectedItem as string); LayerList.Items.Remove(LayerList.SelectedItem); if (LayerList.Items.Count > 0) { currentLayer = dictLayer[LayerList.Items[0].ToString()]; LayerList.SetSelected(0, true); } } }