private void MenuItemLoadDefaultData_Click(object sender, EventArgs e) { var result = MessageBox.Show(this, @"Loading default data may take a long time, do you want to continue?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { try { MapDataAdapter.Reset(); var importForm = new ImportProgressForm(new StateDataImporter(@"Data\US_States.txt"), MapDataAdapter.FeatureTypeStates); var toContinue = importForm.ShowDialog(this) == DialogResult.OK; if (toContinue) { importForm = new ImportProgressForm(new CountyDataImporter(@"Data\US_Counties.txt"), MapDataAdapter.FeatureTypeCounties); toContinue = importForm.ShowDialog(this) == DialogResult.OK; } if (toContinue) { importForm = new ImportProgressForm(new CityDataImporter(@"Data\US_Cities.txt"), MapDataAdapter.FeatureTypeCities); importForm.ShowDialog(this); } } catch { MessageBox.Show(this, @"Failed to import the default data, please try again.", @"Importation Failure", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } _searchCtrl.RefreshData(); } }
private void AddLayerHandler(object sender, EventArgs e) { var addLayerForm = new AddLayerForm(); if (addLayerForm.ShowDialog(this) == DialogResult.OK) { var featureSet = new FeatureSet(addLayerForm.FeatureType) { Name = addLayerForm.LayerName }; var dataPath = addLayerForm.DataPath; var displayLayer = addLayerForm.DisplayAfterImportation; var importForm = new ImportProgressForm(new SpatialLayerDataImporter(featureSet.Name, dataPath)); if (importForm.ShowDialog(this) == DialogResult.OK) { if (displayLayer) { var geometries = importForm.GetImportedObjects <JoobGeometry>(); MapDataAdapter.PopulateFeatureSet(geometries, featureSet); var layer = map.Layers.Add(featureSet); if (layer != null) { layer.LegendText = featureSet.Name; } map.ViewExtents.ExpandToInclude(featureSet.Extent); } _searchCtrl.RefreshLayers(); } } }