public CancelationToolbar(MapWidget mapWidget) { InitializeComponent(); // Store a reference to the MapWidget that the toolbar has been installed to. _mapWidget = mapWidget; }
public DirectionsResultView(MapWidget mapWidget, FindCloseFacilityResultView fcfResultView, RouteResult routeResult, FindClosestResourceToolbar fcrToolbar) { InitializeComponent(); base.DataContext = this; // Store a reference to the MapWidget that the toolbar has been installed to. _mapWidget = mapWidget; _closestFaculityResult = fcfResultView; _findClosestFacilityToolbar = fcrToolbar; RouteName = routeResult.Directions.RouteName; Summary = string.Format("{0:F1} {1}, {2}", routeResult.Directions.TotalLength, "miles", FormatTime(routeResult.Directions.TotalTime)); List<Graphic> features = new List<Graphic>(routeResult.Directions.Features); features.RemoveAt(0); List<ManeuverViewModel> directionElements = new List<ManeuverViewModel>(); Graphic previous = null; int i = 1; foreach (var next in features) { ManeuverViewModel maneuver = new ManeuverViewModel(previous, next, i++); maneuver.Graphic.MouseLeftButtonDown += Graphic_MouseLeftButtonDown; directionElements.Add(maneuver); previous = next; } Maneuvers = directionElements; }
public AircraftRouteGenLineToolbar(MapWidget mapWidget, string serviceURL) { InitializeComponent(); // Store a reference to the MapWidget that the toolbar has been installed to. _mapWidget = mapWidget; _serviceURL = serviceURL; }
public BombThreatToolbar(MapWidget mapWidget, string serviceURL) { InitializeComponent(); // Store a reference to the MapWidget that the toolbar has been installed to. _mapWidget = mapWidget; _serviceURL = serviceURL; }
private void OKButton_Click(object sender, RoutedEventArgs e) { Caption = CaptionTextBox.Text; // If there is a map widget selected, get the ID. MapWidget = MapWidgetCombo.SelectedItem as MapWidget; ; // Widget should only be added to the view if a map widget was chosen. DialogResult = (MapWidget != null); }
public AircraftCoverageToolbar(MapWidget mapWidget, string serviceURL) { InitializeComponent(); // Store a reference to the MapWidget that the toolbar has been installed to. _mapWidget = mapWidget; _serviceURL = serviceURL; int pos = _serviceURL.IndexOf("GPServer"); _baseURL = _serviceURL.Substring(0, pos); }
public BufferMapToolBar(MapWidget mapWidget, String bufferDataSource, String bufferField) { InitializeComponent(); this.DataContext = this; // Store a reference to the MapWidget that the toolbar has been installed to. _mapWidget = mapWidget; // The following parameters are used when user selecting features from a layer. // DataSource and Field names need to be specified in the tool settings. BufferLayers = new ObservableCollection<BufferLayer>(); var selectLyr = new BufferLayer(); if (bufferDataSource == null) { selectLyr.Name = "Use Settings for buffer layer"; selectLyr.DataSource = null; BufferLayers.Add(selectLyr); } else { _bufferDataSource = bufferDataSource; _bufferField = bufferField; selectLyr.Name = "Select a layer"; selectLyr.DataSource = null; BufferLayers.Add(selectLyr); ESRI.ArcGIS.OperationsDashboard.DataSource layerDataSource = null; IEnumerable<ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources; foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources) { if (d.Id == _bufferDataSource) { layerDataSource = d; break; } } BufferTypes = new ObservableCollection<BufferType>(); var bufferLayer = new BufferLayer(); bufferLayer.Name = layerDataSource.Name; bufferLayer.DataSource = layerDataSource; BufferLayers.Add(bufferLayer); } }
public DrawPolygonMapToolDialog(MapWidget mapWidget) { InitializeComponent(); DataContext = this; if (mapWidget == null) return; //Create a list and store the polygon layers List<client.FeatureLayer> polygonLayers = new List<client.FeatureLayer>(); foreach (client.FeatureLayer layer in MapFeatureLayersFinder.GetMapFeatureLayers(mapWidget.Map)) { if (layer.LayerInfo.GeometryType == client.Tasks.GeometryType.Polygon) polygonLayers.Add(layer); } //Configure the layer comboboxe properties cmbLayers.ItemsSource = polygonLayers; cmbLayers.SelectedItem = polygonLayers[0]; cmbLayers.DisplayMemberPath = "DisplayName"; }
public DrawPolygonToolbar(MapWidget mapWidget, client.FeatureLayer searchAreaFL) { InitializeComponent(); DataContext = this; #region Initialize the map widget and the search area feature layer MapWidget = mapWidget; if (!mapWidget.Map.IsInitialized) return; SearchAreaLayer = searchAreaFL; SearchAreaLayer.DisableClientCaching = true; #endregion #region MapWidget is not null, initialize the editor tool Editor = new client.Editor() { LayerIDs = new string[] { SearchAreaLayer.ID }, Map = mapWidget.Map, GeometryServiceUrl = @"http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" }; Editor.EditCompleted += Editor_EditCompleted; Editor.EditorActivated += Editor_EditorActivated; #endregion }
private void SetMap(MapWidget mapWidget) { if ((mapWidget != null) && (mapWidget.Map != null)) { // From the map widget, get the map. _map = mapWidget.Map; } }
public void SwapLayers(int Index1, int Index2) { MapWidget.SwapLayers(Index1, Index2); }
public FindClosestResourceToolbar(MapWidget mapWidget, ObservableCollection<ESRI.ArcGIS.OperationsDashboard.DataSource> resourceDatasources, String resourceTypeField, ObservableCollection<ESRI.ArcGIS.OperationsDashboard.DataSource> barriersDataSources) { InitializeComponent(); this.DataContext = this; // Store a reference to the MapWidget that the toolbar has been installed to. _mapWidget = mapWidget; //set up the route task with find closest facility option _routeTask = new RouteTask("http://route.arcgis.com/arcgis/rest/services/World/ClosestFacility/NAServer/ClosestFacility_World/solveClosestFacility"); _routeTask.SolveClosestFacilityCompleted += SolveClosestFacility_Completed; _routeTask.Failed += SolveClosestFacility_Failed; //check if the graphicslayers need to be added to the map. setupGraphicsLayer(); //set up the resources/facilities datasource in the combobox setupResourcesDataSource(resourceDatasources); ResourceTypes = new ObservableCollection<ResourceType>(); _resourceTypeField = resourceTypeField; //set up the barriers types combobox //this will have to be read from the config file... BarriersDataSouces = new ObservableCollection<ResourceLayer>(); //set up facilities type dropdown ResourceLayer barrierLayer = new ResourceLayer(); barrierLayer.Name = "Select Barrier"; barrierLayer.DataSource = null; BarriersDataSouces.Add(barrierLayer); //Barriers - passed from the configurar foreach (ESRI.ArcGIS.OperationsDashboard.DataSource datasource in barriersDataSources) { barrierLayer = new ResourceLayer(); barrierLayer.Name = datasource.Name; barrierLayer.DataSource = datasource; BarriersDataSouces.Add(barrierLayer); } cmbBarriers.ItemsSource = BarriersDataSouces; _incidentMarkerSymbol = new SimpleMarkerSymbol { Size = 20, Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle }; //polyline barrier layer symbol _polylineBarrierSymbol = new client.Symbols.SimpleLineSymbol() { Color = new SolidColorBrush(Color.FromRgb(138, 43, 226)), Width = 5 }; }
public void UpdateTilePlacement(int oldx = -1, int oldy = -1, int newx = -1, int newy = -1) { if (!MainContainer.WidgetIM.Hovering) { return; } if (MainContainer.HScrollBar != null && (MainContainer.HScrollBar.SliderDragging || MainContainer.HScrollBar.SliderHovering)) { return; } if (MainContainer.VScrollBar != null && (MainContainer.VScrollBar.SliderDragging || MainContainer.VScrollBar.SliderHovering)) { return; } bool Left = WidgetIM.ClickedLeftInArea == true; bool Right = WidgetIM.ClickedRightInArea == true; if (Left || Right) { if (OriginPoint == null) { OriginPoint = new Point( (int)Math.Floor(oldx / 32d), (int)Math.Floor(oldy / 32d) ); } } // Input handling if (Left) { if (TilesPanel.SelectButton.Selected) // Selection tool { int sx = OriginPoint.X < MapTileX ? OriginPoint.X : MapTileX; int ex = OriginPoint.X < MapTileX ? MapTileX : OriginPoint.X; int sy = OriginPoint.Y < MapTileY ? OriginPoint.Y : MapTileY; int ey = OriginPoint.Y < MapTileY ? MapTileY : OriginPoint.Y; if (sx < 0) { sx = 0; } else if (sx >= Map.Width) { sx = Map.Width - 1; } if (sy < 0) { sy = 0; } else if (sy >= Map.Height) { sy = Map.Height - 1; } if (ex < 0) { ex = 0; } else if (ex >= Map.Width) { ex = Map.Width - 1; } if (ey < 0) { ey = 0; } else if (ey >= Map.Height) { ey = Map.Height - 1; } SelectionX = sx; SelectionY = sy; SelectionWidth = ex - sx + 1; SelectionHeight = ey - sy + 1; UpdateSelection(); } else // Pencil tool { int Layer = LayerPanel.SelectedLayer; if (TileDataList.Count == 0) { if (TilesPanel.EraserButton.Selected) { TileDataList.Add(null); } else { TilesPanel.SelectTile(null); TileDataList.Add(null); throw new Exception($"The tile data list is empty, but the eraser tool is not selected.\nCan't find tiles to draw with."); } } MapWidget.DrawTiles(oldx, oldy, newx, newy, Layer); } } else if (Right) { if (TilesPanel.SelectButton.Selected) // Selection tool { if (SelectionX != -1 || SelectionY != -1 || SelectionWidth != 0 || SelectionHeight != 0) { SelectionX = -1; SelectionY = -1; SelectionWidth = 0; SelectionHeight = 0; UpdateSelection(); } } int Layer = LayerPanel.SelectedLayer; TileDataList.Clear(); int OriginDiffX = MapTileX - OriginPoint.X; int OriginDiffY = MapTileY - OriginPoint.Y; CursorOrigin = Location.BottomRight; if (OriginDiffX < 0) { OriginDiffX = -OriginDiffX; CursorOrigin = Location.BottomLeft; } if (OriginDiffY < 0) { OriginDiffY = -OriginDiffY; if (CursorOrigin == Location.BottomLeft) { CursorOrigin = Location.TopLeft; } else { CursorOrigin = Location.TopRight; } } CursorWidth = OriginDiffX; CursorHeight = OriginDiffY; UpdateCursorPosition(); if (CursorWidth == 0 && CursorHeight == 0) { int MapTileIndex = MapTileY * Map.Width + MapTileX; if (MapTileX < 0 || MapTileX >= Map.Width || MapTileY < 0 || MapTileY >= Map.Height) { TilesPanel.SelectTile(null); } else { TileData tile = Map.Layers[Layer].Tiles[MapTileIndex]; if (tile == null) { TilesPanel.SelectTile(null); } else { TilesPanel.SelectTile(tile); } } } else { SelectionOnMap = true; TilesPanel.EraserButton.SetSelected(false); int sx = OriginPoint.X < MapTileX ? OriginPoint.X : MapTileX; int ex = OriginPoint.X < MapTileX ? MapTileX : OriginPoint.X; int sy = OriginPoint.Y < MapTileY ? OriginPoint.Y : MapTileY; int ey = OriginPoint.Y < MapTileY ? MapTileY : OriginPoint.Y; TileDataList.Clear(); for (int y = sy; y <= ey; y++) { for (int x = sx; x <= ex; x++) { int index = y * Map.Width + x; if (x < 0 || x >= Map.Width || y < 0 || y >= Map.Height) { TileDataList.Add(null); } else { TileData tile = Map.Layers[Layer].Tiles[index]; TileDataList.Add(tile); } } } } } }
public void SetLayerVisible(int layerindex, bool Visible) { MapWidget.SetLayerVisible(layerindex, Visible); }
/// <summary> /// Determines if the feature action can be executed based on the specified data source and feature, before the option to execute /// the feature action is displayed to the user. /// </summary> /// <param name="searchAreaDS">The data source which will be subsequently passed to the Execute method if CanExecute returns true.</param> /// <param name="searchArea">The data which will be subsequently passed to the Execute method if CanExecute returns true.</param> /// <returns>True if the feature action should be enabled, otherwise false.</returns> public bool CanExecute(DataSource searchAreaDS, client.Graphic searchArea) { //Map widget that contains the searchArea data Source MapWidget areaMW; //Map widget that contains the rescueTeam data Source MapWidget teamMW; try { #region Check if the polygon data source is valid //Check if the searchAreaDS has a display name field if (searchAreaDS.DisplayFieldName == null) return false; //Check if the map widget associated with the search area dataSource is valid if ((areaMW = MapWidget.FindMapWidget(searchAreaDS)) == null) return false; //Check if the search area layer is polygon if (areaMW.FindFeatureLayer(searchAreaDS).LayerInfo.GeometryType != client.Tasks.GeometryType.Polygon) return false; #endregion #region Find the rescue team data source and check if it is consumed by the same mapWidget as the polygon data source //Find all the data sources that can possibly be a taem data sources //(i.e. are associated with point layers and hase the field "SearchAreaName") var teamDataSrcs = OperationsDashboard.Instance.DataSources.Where(ds => IsValidTeamDataSource(ds)); if (teamDataSrcs == null || teamDataSrcs.Count() == 0) return false; //For each of the data source retrieved, get its associated mapWidget //Check if the polygon feature source is also consumed by the same map widget (i.e. teamMW) foreach (DataSource teamDataSrc in teamDataSrcs) { if ((teamMW = MapWidget.FindMapWidget(teamDataSrc)) == null) return false; if (teamMW.Id == areaMW.Id) { MapWidget = areaMW; TeamDataSrc = teamDataSrc; TeamFeatureLayer = MapWidget.FindFeatureLayer(TeamDataSrc); return true; } } #endregion return false; } catch (Exception) { return false; } }
public void DeleteLayer(int Index, bool IsUndoAction = false) { MapWidget.DeleteLayer(Index, IsUndoAction); }
public ERGChemicalMapToolbar(MapWidget mapWidget, string ERGChemicalURL, string ERGPlacardURL, string FindNearestWSURL, string WindDirectionLayerDataSource, string windDirectionFieldName, string windWeatherStationFieldName, string windRecordedDateFieldName, string defaultChemicalName, string defaultPlacardName) { try { InitializeComponent(); this.DataContext = this; // Store a reference to the MapWidget that the toolbar has been installed to. _mapWidget = mapWidget; if (string.IsNullOrEmpty(ERGChemicalURL)) { MessageBox.Show("Please configure the tool!", "Error"); return; } //set up erg Chemical GP URL ERGChemicalURL = (ERGChemicalURL ?? ""); _chemicalURL = ERGChemicalURL; chemicalGPParameters = new List<GPParameterInfo>(); var chemicalJSONUrl = _chemicalURL + "?f=pjson"; ChemicalList = getListOfChemicalsOrPlacards("chemical", chemicalJSONUrl); cmbChemicalOrPlacardType.ItemsSource = ChemicalList; if (!String.IsNullOrEmpty(defaultChemicalName)) _defaultChemicalName = defaultChemicalName; else _defaultChemicalName = _defaultERGName; cmbChemicalOrPlacardType.SelectedValue = _defaultChemicalName; //set up erg Placard GP URL ERGPlacardURL = (ERGPlacardURL ?? ""); _placardURL = ERGPlacardURL; placardGPParameters = new List<GPParameterInfo>(); var placardJsonUrl = _placardURL + "?f=pjson"; PlacardList = getListOfChemicalsOrPlacards("placard", placardJsonUrl); if (!String.IsNullOrEmpty(defaultPlacardName)) _defaultPlacardName = defaultPlacardName; else _defaultPlacardName = _defaultERGName; //wind direction _findNearestWSURL = FindNearestWSURL; if (!string.IsNullOrEmpty(WindDirectionLayerDataSource) && !string.IsNullOrEmpty(_findNearestWSURL)) { ESRI.ArcGIS.OperationsDashboard.DataSource dataSource = OperationsDashboard.Instance.DataSources.FirstOrDefault(ds => ds.Name == WindDirectionLayerDataSource); if (dataSource != null) _windDirectionLayer = _mapWidget.FindFeatureLayer(dataSource); //wind direction fields if (!string.IsNullOrEmpty(windDirectionFieldName)) _windDirectionFieldName = windDirectionFieldName; if (!string.IsNullOrEmpty(windWeatherStationFieldName)) _windWeatherStationFieldName = windWeatherStationFieldName; if (!string.IsNullOrEmpty(windRecordedDateFieldName)) _windRecordedDateFieldName = windRecordedDateFieldName; btnLookupWindDirection.IsEnabled = true; } _mydictionary = new ResourceDictionary(); _mydictionary.Source = new Uri("/ERGChemicalAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); MessageBox.Show("There is an error! Check your parameters!", "Error"); return; } }
/// <summary> /// This function determines if the feature action will be enabled or disabled /// </summary> public bool CanExecute(DataSource BufferDS, client.Graphic BufferFeature) { if (BufferDistance == 0) return false; MapWidget bufferDSMapWidget; //map widget containing the buffer dataSource MapWidget targetDSMapWidget; ////map widget containing the target dataSource //The feature used to generate the buffer area must not be null if (BufferFeature == null) return false; //The data source to queried (TargetDataSource) and the data source that contains the BufferFeature (BufferDS) must not be null if (TargetDataSource == null || BufferDS == null) return false; //Get the mapWidget consuming the target datasource if ((targetDSMapWidget = MapWidget.FindMapWidget(TargetDataSource)) == null) return false; //Check if the map widget associated with the buffer dataSource is valid if ((bufferDSMapWidget = MapWidget.FindMapWidget(BufferDS)) == null) return false; //Only if targetDSMapWidget and bufferDSMapWidget referes to the same object can we execute the search if (bufferDSMapWidget.Id != targetDSMapWidget.Id) return false; //Assigning the selected values to the global variables for later use bufferDataSource = BufferDS; mapWidget = bufferDSMapWidget; return true; }
// *********************************************************************************** // * Initialize Find Closest Facility Result View // *********************************************************************************** public FindCloseFacilityResultView(FindClosestResourceToolbar findClosestToolbar, RouteResult[] routeResults, MapWidget mapWidget) { InitializeComponent(); base.DataContext = this; // Store a reference to the MapWidget that the toolbar has been installed to. _mapWidget = mapWidget; _dirSummary = new DirectionSummary(); _dirSummary.From = "From"; _dirSummary.To = "To"; _dirSummary.FieldType = "FieldType"; _dirSummary.Rank = "Rank"; _dirSummary.TotalTime = "Total Time"; _dirSummary.TotalLength = "Total Length"; _directions.Add(_dirSummary); _closestFacilityToolbar = findClosestToolbar; // add each route result to the result dialog. foreach(RouteResult routeResult in routeResults) { DirectionsFeatureSet directionsFS = routeResult.Directions; string routeName = directionsFS.RouteName; int j = routeName.IndexOf("-"); _dirSummary = new DirectionSummary(); _dirSummary.From = routeName.Substring(0, j - 1); _dirSummary.To = routeName.Substring(j + 2); _dirSummary.FieldType = _closestFacilityToolbar.FacilityType; _dirSummary.Rank = directionsFS.RouteID.ToString(); _dirSummary.TotalTime = directionsFS.TotalDriveTime.ToString("0.0") + " minutes"; _dirSummary.TotalLength = directionsFS.TotalLength.ToString("0.0") + " miles"; _dirSummary.SelectedRoute = routeResult; _directions.Add(_dirSummary); } }
private bool SetMapWidget(DataSource dataSource) { try { if (OperationsDashboard.Instance == null) return false; } catch (Exception) { return false; } _mapWidget = (MapWidget)OperationsDashboard.Instance.FindWidget(dataSource); return true; }
public void CreateNewLayer(int Index, Layer LayerData, bool IsUndoAction = false) { MapWidget.CreateNewLayer(Index, LayerData, IsUndoAction); }