/// <summary> /// Make sure there is a feature layer selected /// Update the Fields Combobox with the Fields corresponding to the Layer Selected /// </summary> /// <param name="args"></param> private void UpdateFields(MapViewEventArgs args) { if (args.MapView.GetSelectedLayers().Count == 0) { SelectedLayer = @"Select Feature Layer in TOC"; return; } var selectedLayer = args.MapView.GetSelectedLayers()[0]; if (!(selectedLayer is FeatureLayer)) { SelectedLayer = @"Select Feature Layer in TOC"; return; } SelectedLayer = MapView.Active.GetSelectedLayers()[0].Name; _featureLayer = selectedLayer as FeatureLayer; QueuedTask.Run(() => { using (var table = _featureLayer.GetTable()) { var newFields = new ObservableCollection <string>(table.GetDefinition().GetFields().Select(field => field.Name)); lock (_collectionLock) { Fields.Clear(); foreach (var field in newFields) { Fields.Add(field); } } } }); }
private async void OnDrawComplete(MapViewEventArgs args) { if (_api != null) { MapView mapview = MapView.Active; Map map = mapview?.Map; SpatialReference spatRef = map?.SpatialReference; Unit unit = spatRef?.Unit; if (unit != null) { string unitName = unit.Name; string label = _api.GetLengthUnitLabel(); if (label != unitName) { double factor = unit.ConversionFactor; SpatialReference cyclSpatreference = await CoordSystemUtils.CycloramaSpatialReferenceAsync(); bool projected = cyclSpatreference.IsProjected; Unit cyclUnit = cyclSpatreference.Unit; double cyclFactor = cyclUnit.ConversionFactor; var conversion = projected ? factor / cyclFactor : factor * cyclFactor; _api.SetLengthUnitLabel(unitName); _api.SetLengthUnitFactor(conversion); } } } }
/// <summary> /// Handler to subscribe to map view events. /// </summary> /// <param name="obj">MapViewEvent arguments from the ActiveMapViewChangedEvents.</param> private void OnActiveMapViewChangeEvents(MapViewEventArgs obj) { if (obj.MapView != null) { AttachEditEvents(obj.MapView.Map); } }
private async void OnMapViewInitialized(MapViewEventArgs args) { CycloMediaLayer.ResetYears(); LayersRemovedEvent.Subscribe(OnLayerRemoved); DrawCompleteEvent.Subscribe(OnDrawComplete); if (ContainsCycloMediaLayer(args.MapView)) { await AddLayersAsync(args.MapView); } Settings settings = Settings.Instance; Login login = Login.Instance; settings.PropertyChanged += OnSettingsPropertyChanged; login.PropertyChanged += OnLoginPropertyChanged; if (settings.CycloramaViewerCoordinateSystem != null) { await CoordSystemUtils.CheckInAreaCycloramaSpatialReferenceAsync(); } if (!_agreement.Value) { PropertySheet.ShowDialog("streetSmartArcGISPro_optionsPropertySheet", "streetSmartArcGISPro_agreementPage"); } }
private void OnDrawCompleted(MapViewEventArgs e) { IReadOnlyList <Layer> layers = e.MapView.Map.GetLayersAsFlattenedList(); foreach (string name in _registry.GetNames()) { // todo daro: need a more robust layer identifier // check first whether work list layer is in TOC FeatureLayer workListLayer = layers.OfType <FeatureLayer>() .FirstOrDefault( layer => string.Equals(layer.Name, name)); if (workListLayer == null) { continue; } IWorkList workList = _registry.Get(name); Assert.NotNull(workList); // safety check, a new work list is already added if (_layerByWorkList.ContainsKey(workList)) { continue; } _layerByWorkList.Add(workList, workListLayer); WireEvents(workList); // todo daro: maybe we need a dictionary of synchronizers _synchronizer = new EditEventsRowCacheSynchronizer(workList); } }
private void OnActiveMapViewChanged(MapViewEventArgs obj) { if (obj.MapView != null && obj.MapView.Time != null) { SetTimeProperties(obj.MapView.Time); } }
/// <summary> /// Event handler for TOCSelectionChangedEvent event /// </summary> /// <param name="args">The event arguments.</param> private void OnSelectedLayersChanged(MapViewEventArgs args) { // save current changes SaveChanges(); // set up for the next selected mapMember BuildControlProperties(args.MapView); }
private void OnDrawComplete(MapViewEventArgs obj) { if (obj.MapView == null) { return; } CreateReportViewModel vm = FrameworkApplication.DockPaneManager.Find("CreateReport_CreateReport") as CreateReportViewModel; vm.UpdateCollectionsAsync(); }
private async void OnActiveMapViewChanged(MapViewEventArgs obj) { if (obj.MapView == null) { Camera = GetEmptyCamera(); return; } Camera = await obj.MapView.GetCameraAsync(); }
private void OnTOCSelectionChanged(MapViewEventArgs obj) { var selectedGraphicLayers = obj.MapView.GetSelectedLayers().OfType <GraphicsLayer>(); if (selectedGraphicLayers.Count() == 0) { //nothing selected. So clear the selected graphic layer. SelectedGraphicsLayerTOC = null; return; } SelectedGraphicsLayerTOC = selectedGraphicLayers.FirstOrDefault(); }
/// <summary> /// This method makes sure /// 1. The Mapview is Active /// 2. There is at least one layer selected /// 3. That layer is either /// a. A utility network layer /// b. A feature layer whose feature class belongs to a utility network /// c. A subtype group layer whose feature class belongs to a utility network /// /// If all of these hold true, we populate the combo box with the list of categories that are registered with this utility network /// </summary> private async void UpdateCategoryList(MapViewEventArgs mapViewEventArgs) { // Verify that the map view is active and at least one layer is selected if (MapView.Active == null || mapViewEventArgs.MapView.GetSelectedLayers().Count < 1) { Enabled = false; return; } // Verify that we have the correct kind of layer Layer selectedLayer = mapViewEventArgs.MapView.GetSelectedLayers()[0]; if (!(selectedLayer is UtilityNetworkLayer) && !(selectedLayer is FeatureLayer) && !(selectedLayer is SubtypeGroupLayer)) { Enabled = false; return; } // Switch to the MCT to access the geodatabase await QueuedTask.Run(() => { // Get the utility network from the layer. // It's possible that the layer is a FeatureLayer or SubtypeGroupLayer that doesn't refer to a utility network at all. using (UtilityNetwork utilityNetwork = UtilityNetworkUtils.GetUtilityNetworkFromLayer(selectedLayer)) { if (utilityNetwork == null) { Enabled = false; return; } // Enable the combo box and clear out its contents Enabled = true; Clear(); // Fill the combo box with all of the categories in the utility network using (UtilityNetworkDefinition utilityNetworkDefinition = utilityNetwork.GetDefinition()) { IReadOnlyList <string> categories = utilityNetworkDefinition.GetAvailableCategories(); foreach (string category in categories) { Add(new ComboBoxItem(category)); } } } }); // Store the layer if (Enabled) { myLayer = selectedLayer; } }
/// <summary> /// OnClick /// /// This is the implementation of our button. We pass the selected layer to GenerateReport() which does the bulk of the work. /// We then display the results, along with error messages, in a MessageBox. /// /// </summary> protected override async void OnClick() { // Start by checking to make sure we have a single feature layer selected if (MapView.Active == null) { MessageBox.Show("Please select a utility network layer.", "Create Load Report"); return; } MapViewEventArgs mapViewEventArgs = new MapViewEventArgs(MapView.Active); if (mapViewEventArgs.MapView.GetSelectedLayers().Count != 1) { MessageBox.Show("Please select a utility network layer.", "Create Load Report"); return; } Layer selectionLayer = mapViewEventArgs.MapView.GetSelectedLayers()[0]; if (!(selectionLayer is UtilityNetworkLayer) && !(selectionLayer is FeatureLayer) && !(selectionLayer is SubtypeGroupLayer)) { MessageBox.Show("Please select a utility network layer.", "Create Load Report"); return; } // Generate our report. The LoadTraceResults class is used to pass back results from the worker thread to the UI thread that we're currently executing. LoadTraceResults traceResults = await QueuedTask.Run <LoadTraceResults>(() => { return(GenerateReport(selectionLayer)); }); // Assemble a string to show in the message box string traceResultsString; if (traceResults.Success) { traceResultsString = String.Format("Customers per Phase:\n A: {0}\n B: {1}\n C: {2}\n\nLoad per Phase:\n A: {3}\n B: {4}\n C: {5}\n\n{6}", traceResults.NumberServicePointsA.ToString(), traceResults.NumberServicePointsB.ToString(), traceResults.NumberServicePointsC.ToString(), traceResults.TotalLoadA.ToString(), traceResults.TotalLoadB.ToString(), traceResults.TotalLoadC.ToString(), traceResults.Message); } else { traceResultsString = traceResults.Message; } // Show our results MessageBox.Show(traceResultsString, "Create Load Report"); }
private void OnMapViewCaricata(MapViewEventArgs args) { funzioniVariabiliGlobali.VariabiliGlobali.blnMappaAttivaCaricata = true; this.Clear(); this.UpdateCombo(); LayersAddedEvent.Subscribe(EventoLayerInTOC); LayersMovedEvent.Subscribe(EventoLayerInTOC); LayersRemovedEvent.Subscribe(EventoLayerInTOC); MapClosedEvent.Subscribe(AllaChiusuraMappa); MapPropertyChangedEvent.Subscribe(AllaVariazioneProprietaMappa); // Occurs when any property of a map is changed. MapMemberPropertiesChangedEvent.Subscribe(EventoLayerInTOC); // Occurs when any property of layer or standalone table changed. }
// Get the Utility Network from the currently active layer private UtilityNetwork GetUtilityNetwork() { UtilityNetwork utilityNetwork = null; if (MapView.Active != null) { MapViewEventArgs mapViewEventArgs = new MapViewEventArgs(MapView.Active); IReadOnlyList <Layer> selectedLayers = mapViewEventArgs.MapView.GetSelectedLayers(); if (selectedLayers.Count > 0) { utilityNetwork = UtilityNetworkUtils.GetUtilityNetworkFromLayer(selectedLayers[0]); } } return(utilityNetwork); }
private async void OnDrawCompleted(MapViewEventArgs args) { MapView mapView = args.MapView; Geometry sketchGeometry = await mapView.GetCurrentSketchAsync(); if (sketchGeometry == null) { await GenerateGmlAsync(); } if (_updateMeasurements) { _updateMeasurements = false; Measurements = await ReloadSelectionAsync(); } }
/// <summary> /// Make sure there is a feature layer selected /// Update the Fields Combobox with the Fields corresponding to the Layer Selected /// </summary> /// <param name="args"></param> private void UpdateFields(MapViewEventArgs args) { if (args.MapView.GetSelectedLayers().Count == 0) return; var selectedLayer = args.MapView.GetSelectedLayers()[0]; if (selectedLayer is FeatureLayer) { featureLayer = selectedLayer as FeatureLayer; QueuedTask.Run(() => { using (var table = featureLayer.GetTable()) { Fields = new ObservableCollection<string>(table.GetDefinition().GetFields().Select(field => field.Name)); } }); } }
private async void OnActiveViewChanged(MapViewEventArgs args) { MapView mapView = args.MapView; if (mapView != null) { IsCameraEnabled = true; Camera = await mapView.GetCameraAsync(); SetHeading(); } else { IsCameraEnabled = false; } }
// todo daro: move to OnMapViewInitialized? private void OnDrawCompleted(MapViewEventArgs e) { string uri = null; foreach (string name in _registry.GetNames() .Where(name => _uriByWorklistName.TryGetValue( name, out uri))) { // Can be null because it's from module settings and those cannot be deleted but only // set to null. if (string.IsNullOrEmpty(uri)) { continue; } var worklistLayer = e.MapView.Map.FindLayer(uri) as FeatureLayer; // todo daro Read the custom project settings and the URI of the created work list layers. // Don't do layer name comparison. // Stop giving the work list layer the name of the work list. The map (work list uri <> work list name) // is managed with the custom project settings. // For the moment the work list layers data source remains the work list file name. It feels the right way, e.g. // in ArcGIS the data source is broken too if its name changes. //LayerUtils.GetLayer("work list uri"); if (worklistLayer == null) { continue; } IWorkList workList = _registry.Get(name); Assert.NotNull(workList); // safety check, a new work list is already added if (_layersByWorklistName.ContainsKey(workList.Name)) { continue; } _layersByWorklistName.Add(workList.Name, worklistLayer); WireEvents(workList); // todo daro: maybe we need a dictionary of synchronizers _synchronizer = new EditEventsRowCacheSynchronizer(workList); } }
/// <summary> /// Make sure there is a feature layer selected /// Update the Fields Combobox with the Fields corresponding to the Layer Selected /// </summary> /// <param name="args"></param> private void UpdateFields(MapViewEventArgs args) { if (args.MapView.GetSelectedLayers().Count == 0) { return; } var selectedLayer = args.MapView.GetSelectedLayers()[0]; if (selectedLayer is FeatureLayer) { featureLayer = selectedLayer as FeatureLayer; QueuedTask.Run(() => { using (var table = featureLayer.GetTable()) { Fields = new ObservableCollection <string>(table.GetDefinition().GetFields().Select(field => field.Name)); } }); } }
protected async void OnDrawStarted(MapViewEventArgs args) { MapView mapView = args.MapView; Geometry geometry = await mapView.GetCurrentSketchAsync(); if ((geometry?.HasZ ?? false) && (EditTool == EditTools.SketchPointTool)) { await AddHeightToMeasurementAsync(geometry, mapView); } if (geometry != null && EditTool == EditTools.ModifyFeatureImpl) { EditTool = EditTools.Verticles; Measurement measurement = _measurementList.Sketch; measurement?.OpenMeasurement(); } else if (geometry == null && EditTool == EditTools.Verticles) { EditTool = EditTools.ModifyFeatureImpl; } }
protected async override void OnClick() { // Start by checking to make sure we have a single feature layer selected if (MapView.Active == null) { MessageBox.Show("Please select a utility network layer.", "Validate Changes"); return; } MapViewEventArgs mapViewEventArgs = new MapViewEventArgs(MapView.Active); if (mapViewEventArgs.MapView.GetSelectedLayers().Count != 1) { MessageBox.Show("Please select a utility network layer.", "Validate Changes"); return; } Layer selectionLayer = mapViewEventArgs.MapView.GetSelectedLayers()[0]; if (!(selectionLayer is UtilityNetworkLayer) && !(selectionLayer is FeatureLayer) && !(selectionLayer is SubtypeGroupLayer)) { MessageBox.Show("Please select a utility network layer.", "Validate Changes"); return; } string message = ""; // Generate our report. The LoadTraceResults class is used to pass back results from the worker thread to the UI thread that we're currently executing. await QueuedTask.Run(() => { message = ValidateChangedFeatures(selectionLayer); }); MessageBox.Show(message); }
/// <summary> /// This method makes sure /// 1. The Mapview is Active /// 2. There is at least one Layer selected /// 3. The selected Layer is a FeatureLayer /// 4. The selected Layer is backed by an Enterprise Sql Server Geodatabase FeatureClass /// /// If all of these hold good, the DatabaseClient is used to execute a query which creates /// a Database Table containing the gdb_items records corresponding to all domains. The Table is /// then opened using the API and the domains combobox populated. Finally, the Table is deleted /// </summary> /// <param name="mapViewEventArgs"></param> private async void UpdateDomainList(MapViewEventArgs mapViewEventArgs) { if (MapView.Active == null || mapViewEventArgs.MapView.GetSelectedLayers().Count < 1 || !(mapViewEventArgs.MapView.GetSelectedLayers()[0] is FeatureLayer)) { Enabled = false; return; } EnterpriseDatabaseType enterpriseDatabaseType = EnterpriseDatabaseType.Unknown; await QueuedTask.Run(() => { using (Table table = (mapViewEventArgs.MapView.GetSelectedLayers()[0] as FeatureLayer).GetTable()) { if(!(table.GetDatastore() is Geodatabase)) return; try { enterpriseDatabaseType = (table.GetDatastore() as Geodatabase).GetEnterpriseDatabaseType(); } catch (InvalidOperationException e) { } } }); if (enterpriseDatabaseType != EnterpriseDatabaseType.SQLServer) { Enabled = false; return; } Enabled = true; Clear(); QueuedTask.Run(() => { using (Table table = (mapViewEventArgs.MapView.GetSelectedLayers()[0] as FeatureLayer).GetTable()) { var geodatabase = table.GetDatastore() as Geodatabase; Version defaultVersion = geodatabase.GetVersionManager().GetVersions().FirstOrDefault(version => { string name = version.GetName(); return name.ToLowerInvariant().Equals("dbo.default") || name.ToLowerInvariant().Equals("sde.default"); }); if (defaultVersion == null) return; string tableName = String.Format("NewTable{0}{1}{2}{3}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond); gdbItemsOwner = defaultVersion.GetName().Split('.')[0]; string statement = String.Format( @"select {1}.GDB_ITEMTYPES.Name as Type, {1}.GDB_ITEMS.Name into {0} from {1}.GDB_ITEMS JOIN {1}.GDB_ITEMTYPES ON {1}.GDB_ITEMS.Type = {1}.GDB_ITEMTYPES.UUID where {1}.GDB_ITEMTYPES.Name = 'Domain' OR {1}.GDB_ITEMTYPES.Name = 'Coded Value Domain' OR {1}.GDB_ITEMTYPES.Name = 'Range Domain'", tableName, gdbItemsOwner); try { DatabaseClient.ExecuteStatement(geodatabase, statement); } catch (GeodatabaseTableException exception) { MessageBox.Show(exception.Message); return; } var newTable = geodatabase.OpenDataset<Table>(tableName); using (RowCursor rowCursor = newTable.Search(null, false)) { while (rowCursor.MoveNext()) { using (Row row = rowCursor.Current) { Add(new ComboBoxItem(row["Name"].ToString())); } } } statement = String.Format(@"DROP TABLE {0}", tableName); DatabaseClient.ExecuteStatement(geodatabase, statement); } }); }
private void OnDrawComplete(MapViewEventArgs obj) { CheckContext(); }
private void OnActiveViewChanged(MapViewEventArgs args) { RunEnabled = false; }
private void OnMapViewInitialized(MapViewEventArgs args) { CheckContext(); }
private void OnActiveMapViewChanged(MapViewEventArgs obj) { SetMapTimeEnabledState((obj.MapView != null && obj.MapView.Time != null)); LoadBookmarks(); }
/// <summary> /// Called when the active map view changes. /// </summary> private void OnActiveViewChanged(MapViewEventArgs args) { SetHeadingFromMapView(args.MapView); }
protected async void OnDrawCompleted(MapViewEventArgs args) { MapView mapView = args.MapView; Geometry geometry = await mapView.GetCurrentSketchAsync(); EditingTemplate editingFeatureTemplate = EditingTemplate.Current; Layer layer = editingFeatureTemplate?.Layer; VectorLayer thisVectorLayer = GetLayer(layer); if (geometry != null) { switch (EditTool) { case EditTools.ModifyFeatureImpl: if (_measurementList.Count == 1) { KeyValuePair <int, Measurement> firstElement = _measurementList.ElementAt(0); Measurement measurement = firstElement.Value; measurement.SetSketch(); VectorLayer vectorLayer = measurement.VectorLayer; if (geometry.PointCount == 0) { await StartMeasurementSketchAsync(vectorLayer); } else if (geometry.HasZ) { await AddHeightToMeasurementAsync(geometry, mapView); } await _measurementList.SketchModifiedAsync(geometry, thisVectorLayer); } break; case EditTools.SketchLineTool: case EditTools.SketchPolygonTool: case EditTools.Verticles: if (geometry.HasZ) { await AddHeightToMeasurementAsync(geometry, mapView); } await _measurementList.SketchModifiedAsync(geometry, thisVectorLayer); break; case EditTools.SketchPointTool: if (geometry.HasZ) { await AddHeightToMeasurementAsync(geometry, mapView); } break; } } else { SketchFinished(); } }
private void OnDrawComplete(MapViewEventArgs args) { // toDo: is this function necessary? }
private void OnDrawComplete(MapViewEventArgs obj) { //TODO:If no feature layers, show empty dockpanes(DockpaneVisibility) GetMapMembers(MapView.Active); InitializeFilters(); }
private async void OnActiveViewChanged(MapViewEventArgs args) { MapView mapView = args.MapView; if (mapView != null) { IsCameraEnabled = true; Camera = await mapView.GetCameraAsync(); SetHeading(); } else IsCameraEnabled = false; }
private async void OnMapViewInitialized(MapViewEventArgs args) { await DetectVectorLayersAsync(false, args.MapView); AddEvents(); }
private void OnTocSelectionChanged(MapViewEventArgs args) { LayerUpdated?.Invoke(); }
private void OnActiveMapViewChanged(MapViewEventArgs obj) { if (obj.MapView != null && obj.MapView.Time != null) SetTimeProperties(obj.MapView.Time); }
private async void OnActiveMapViewChanged(MapViewEventArgs obj) { if (obj.MapView == null) { Camera = null; return; } Camera = await obj.MapView.GetCameraAsync(); }
/// <summary> /// This method makes sure /// 1. The Mapview is Active /// 2. There is at least one Layer selected /// 3. The selected Layer is a FeatureLayer /// 4. The selected Layer is backed by an Enterprise Sql Server Geodatabase FeatureClass /// /// If all of these hold good, the DatabaseClient is used to execute a query which creates /// a Database Table containing the gdb_items records corresponding to all domains. The Table is /// then opened using the API and the domains combobox populated. Finally, the Table is deleted /// </summary> /// <param name="mapViewEventArgs"></param> private async void UpdateDomainList(MapViewEventArgs mapViewEventArgs) { if (MapView.Active == null || mapViewEventArgs.MapView.GetSelectedLayers().Count < 1 || !(mapViewEventArgs.MapView.GetSelectedLayers()[0] is FeatureLayer)) { Enabled = false; return; } EnterpriseDatabaseType enterpriseDatabaseType = EnterpriseDatabaseType.Unknown; await QueuedTask.Run(() => { using (Table table = (mapViewEventArgs.MapView.GetSelectedLayers()[0] as FeatureLayer).GetTable()) { if (!(table.GetDatastore() is Geodatabase)) { return; } try { enterpriseDatabaseType = (table.GetDatastore() as Geodatabase).GetEnterpriseDatabaseType(); } catch (InvalidOperationException e) { } } }); if (enterpriseDatabaseType != EnterpriseDatabaseType.SQLServer) { Enabled = false; return; } Enabled = true; Clear(); QueuedTask.Run(() => { using (Table table = (mapViewEventArgs.MapView.GetSelectedLayers()[0] as FeatureLayer).GetTable()) { var geodatabase = table.GetDatastore() as Geodatabase; Version defaultVersion = geodatabase.GetVersionManager().GetVersions().FirstOrDefault(version => { string name = version.GetName(); return(name.ToLowerInvariant().Equals("dbo.default") || name.ToLowerInvariant().Equals("sde.default")); }); if (defaultVersion == null) { return; } string tableName = String.Format("NewTable{0}{1}{2}{3}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond); gdbItemsOwner = defaultVersion.GetName().Split('.')[0]; string statement = String.Format( @"select {1}.GDB_ITEMTYPES.Name as Type, {1}.GDB_ITEMS.Name into {0} from {1}.GDB_ITEMS JOIN {1}.GDB_ITEMTYPES ON {1}.GDB_ITEMS.Type = {1}.GDB_ITEMTYPES.UUID where {1}.GDB_ITEMTYPES.Name = 'Domain' OR {1}.GDB_ITEMTYPES.Name = 'Coded Value Domain' OR {1}.GDB_ITEMTYPES.Name = 'Range Domain'", tableName, gdbItemsOwner); try { DatabaseClient.ExecuteStatement(geodatabase, statement); } catch (GeodatabaseTableException exception) { MessageBox.Show(exception.Message); return; } var newTable = geodatabase.OpenDataset <Table>(tableName); using (RowCursor rowCursor = newTable.Search(null, false)) { while (rowCursor.MoveNext()) { using (Row row = rowCursor.Current) { Add(new ComboBoxItem(row["Name"].ToString())); } } } statement = String.Format(@"DROP TABLE {0}", tableName); DatabaseClient.ExecuteStatement(geodatabase, statement); } }); }