private void App_Startup(object sender, StartupEventArgs e) { GdbHelper.Initialize(); // Load resources from ResourceDictionary.xaml // ResourceDictionary dict = (ResourceDictionary)Application.LoadComponent( new Uri("/IS3.Config;Component/ResourceDictionary.xaml", System.UriKind.Relative)); this.Resources.MergedDictionaries.Add(dict); // open a background window that start the configuration Window backgroundWnd = new Window(); this.MainWindow = backgroundWnd; bool ok = StartConfig(); if (ok) { // do something } else { } Shutdown(); }
async void LoadGeoDb(EngineeringMap emap) { string file = ProjDef.LocalFilePath + "\\" + emap.LocalGeoDbFileName; if (File.Exists(file)) { Geodatabase gdb = await Geodatabase.OpenAsync(file); IEnumerable <GeodatabaseFeatureTable> featureTables = gdb.FeatureTables; List <GdbLayer> gdbLayers = new List <GdbLayer>(); foreach (var table in featureTables) { GdbLayer layer = new GdbLayer(); layer.Name = table.Name; layer.Visibility = false; layer.FeatureTable = table; gdbLayers.Add(layer); LayerDef lyrDef = emap.LocalGdbLayersDef.Find(x => x.Name == table.Name); if (lyrDef == null) { lyrDef = GdbHelper.GenerateDefaultLayerDef(table); emap.LocalGdbLayersDef.Add(lyrDef); } await GdbHelper.addGeodatabaseLayer(Map, lyrDef, table); } GeoDBLayrList.ItemsSource = gdbLayers; } }
private async void LyrSetting_Click(object sender, RoutedEventArgs e) { EngineeringMap emap = EMapsLB.SelectedItem as EngineeringMap; if (emap == null) { return; } GdbLayer gdbLyr = GeoDBLayrLB.SelectedItem as GdbLayer; if (gdbLyr == null) { return; } LayerDef lyrDef = emap.LocalGdbLayersDef.Find(x => x.Name == gdbLyr.Name); LayerDefWindow lyrDefWnd = new LayerDefWindow(lyrDef); lyrDefWnd.Owner = this; lyrDefWnd.WindowStartupLocation = WindowStartupLocation.CenterOwner; bool?success = lyrDefWnd.ShowDialog(); if (success != null && success.Value == true) { Layer lyr = Map.Layers[gdbLyr.Name]; if (lyr != null) { // Reload the layer Map.Layers.Remove(lyr); await GdbHelper.addGeodatabaseLayer(Map, lyrDef, gdbLyr.FeatureTable); } } }
private async void MapsCB_SelectionChanged(object sender, SelectionChangedEventArgs e) { EngineeringMap emap = MapsCB.SelectedItem as EngineeringMap; if (emap == null) { return; } List <LayerDef> lyrsDef = emap.LocalGdbLayersDef; LayerDef lyrDef = lyrsDef.Find(x => x.Name == _lyrName); if (lyrDef == null) { return; } // load tiled layer // string file = _prjDef.LocalTilePath + "\\" + emap.LocalTileFileName1; if (File.Exists(file)) { ArcGISLocalTiledLayer newLayr = new ArcGISLocalTiledLayer(file); newLayr.ID = "TiledLayer1"; newLayr.DisplayName = "TileLayer1"; Map.Layers.Add(newLayr); //if (newLayr.FullExtent != null) //{ // MyMapView.SetView(newLayr.FullExtent); //} } // load the specified layer // file = _prjDef.LocalFilePath + "\\" + emap.LocalGeoDbFileName; if (File.Exists(file)) { // Open geodatabase Geodatabase gdb = await Geodatabase.OpenAsync(file); IEnumerable <GeodatabaseFeatureTable> featureTables = gdb.FeatureTables; foreach (var table in featureTables) { if (table.Name == _lyrName) { // Add the feature layer to the map await GdbHelper.addGeodatabaseLayer(Map, lyrDef, table); MyMapView.SetView(table.Extent); break; } } } }
// Load the specifiled emap's geodatabase, and add all the features layers to the map. // async Task ReloadGeoDb(EngineeringMap emap) { // Clear existing Local GeoDB layers if (GeoDBLayrLB.ItemsSource != null) { foreach (var item in GeoDBLayrLB.ItemsSource) { GdbLayer lyr = item as GdbLayer; Layer mapLyr = Map.Layers[lyr.Name]; if (mapLyr != null) { Map.Layers.Remove(mapLyr); } } GeoDBLayrLB.ItemsSource = null; } // Load new string file = _projDef.LocalFilePath + "\\" + emap.LocalGeoDbFileName; if (File.Exists(file)) { // Open geodatabase Geodatabase gdb = await Geodatabase.OpenAsync(file); IEnumerable <GeodatabaseFeatureTable> featureTables = gdb.FeatureTables; List <GdbLayer> gdbLayers = new List <GdbLayer>(); foreach (var table in featureTables) { // Search LayerDef, use default if not found. LayerDef lyrDef = emap.LocalGdbLayersDef.Find(x => x.Name == table.Name); if (lyrDef == null) { lyrDef = GdbHelper.GenerateDefaultLayerDef(table); emap.LocalGdbLayersDef.Add(lyrDef); } // GdbLayer is used for UI binding and selection operations. GdbLayer layer = new GdbLayer(); layer.Name = table.Name; layer.Visibility = lyrDef.IsVisible; layer.LayerObject = layer; layer.FeatureTable = table; layer.Extent = table.Extent; gdbLayers.Add(layer); // Add the feature layer to the map await GdbHelper.addGeodatabaseLayer(Map, lyrDef, table); } // Refresh UI GeoDBLayrLB.ItemsSource = gdbLayers; } }
private void App_Startup(object sender, StartupEventArgs e) { GdbHelper.Initialize(); // open a background window that start the configuration Window backgroundWnd = new Window(); this.MainWindow = backgroundWnd; bool ok = StartConfig(); if (ok) { // do something } else { } Shutdown(); }