using System; using System.IO; using System.Windows.Forms; using Core.Components.DotSpatial.Data; using Core.Components.DotSpatial.Properties; using DotSpatial.Controls; using log4net; namespace Core.Components.DotSpatial { /// /// This class describes a map view /// public sealed class BaseMap : Control { private static readonly ILog Log = LogManager.GetLogger(typeof(BaseMap)); private MapData data; private Map map; /// /// Creates a new instance of /// public BaseMap() { InitializeMapView(); } /// /// Gets and sets the . When is not empty it will load the data on the map. /// /// Thrown when is null. /// Thrown when does not exist. /// Thrown when has an unaccepted extension. public void SetMapData(MapData mapData) { if (IsDisposed) { return; } if(mapData == null) { throw new ArgumentNullException("mapData", "MapData is required when adding shapeFiles"); } if (mapData.IsValid()) { data = mapData; LoadData(); } } /// /// Initialize the for the /// private void InitializeMapView() { map = new Map { Dock = DockStyle.Fill, FunctionMode = FunctionMode.Pan, }; Controls.Add(map); } /// /// Loads the data from the files given in and shows them on the . /// private void LoadData() { foreach (string filePath in data.FilePaths) { map.AddLayer(filePath); Log.InfoFormat(Resources.BaseMap_LoadData_Shape_file_on_path__0__is_added_to_the_map_, filePath); } } } }