/// <summary> /// Binds a particular set of layers to this form /// </summary> /// <param name="gameMap"></param> public void BindLayers(MapForm mapForm) { // Bind the context _mapContext = mapForm; mapForm.UndoManager.UndoPerformed -= UndoPerformed; mapForm.UndoManager.RedoPeformed -= RedoPeformed; mapForm.UndoManager.UndoPerformed += UndoPerformed; mapForm.UndoManager.RedoPeformed += RedoPeformed; listLayers.Items.Clear(); // Begin populating the view for (int index = mapForm.Map.Layers.Count - 1; index >= 0; index--) { var layer = mapForm.Map.Layers[index]; var item = new ListViewItem(new string[] { " " + layer.Name }); item.Tag = index; if (layer.Visible) item.ImageIndex = 0; listLayers.Items.Add(item); } int id = LayerToIndex(mapForm); if (id < 0) id = 0; listLayers.Items[id].Selected = true; _mapContext.Refresh(); }
private int LayerToIndex(MapForm mapForm) { return (mapForm.Map.Layers.Count - 1) - _mapContext.CurrentLayer; }