/// <summary> /// Handles the MapSelected event of the <see cref="MapManager"/> class. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MapSelectedEventArgs"/> instance containing the event data.</param> private void MapSelected(object sender, MapSelectedEventArgs e) { if (e.Map == null) { _map = null; Disable(); return; } if (_map == e.Map) return; if (_map != null) { _map.LayerAdded -= LayerAdded; _map.LayerChanged -= LayerChanged; _map.LayerOrderChanged -= LayerOrderChanged; _map.LayerDeleted -= LayerDeleted; _map.LayerSelected -= LayerSelected; _map.UndoRedoArea.CommandDone -= UndoRedoCommandDone; } _map = e.Map; _map.LayerAdded += LayerAdded; _map.LayerChanged += LayerChanged; _map.LayerOrderChanged += LayerOrderChanged; _map.LayerDeleted += LayerDeleted; _map.LayerSelected += LayerSelected; _map.UndoRedoArea.CommandDone += UndoRedoCommandDone; BuildList(); Enable(); }
/// <summary> /// Handles the MapSelected event of the <see cref="MapManager"/> class. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MapSelectedEventArgs"/> instance containing the event data.</param> private void MapSelected(object sender, MapSelectedEventArgs e) { if (e.Map == null) { if (_map != null) { _map.UndoRedoArea.CommandDone -= UndoRedoCommandDone; _map = null; } Disable(); return; } if (_map == e.Map) return; _map = e.Map; _map.UndoRedoArea.CommandDone += UndoRedoCommandDone; lstHistory.Items.Clear(); BuildList(); Enable(); }