private void UpdateMilitaryMessageControlPoints(MilitaryMessage msg) { var tam = _mission.MilitaryMessages.First(m => m.Id == msg.Id); if (tam != null) { tam.StoreControlPoints(_mission.PhaseList[CurrentPhaseIndex].ID, msg); } }
private void RemoveMessage(Message message) { var msg = new MilitaryMessage(message.Id, MilitaryMessageType.PositionReport, MilitaryMessageAction.Remove); // remove from visible layer _militaryMessageLayer.ProcessMessage(msg); RemoveMessageFromPhase(CurrentPhaseIndex, _mission.MilitaryMessages.First(m => m.Id == message.Id)); }
private async Task FindIntersectingGraphicsAsync(DrawShape drawMode) { var messageSubLayers = _messageLayer.ChildLayers.Cast <MessageSubLayer>(); IEnumerable <Graphic> results = Enumerable.Empty <Graphic>(); int maxHits = 1; if (drawMode == DrawShape.Point) { var mapPoint = await MyMapView.Editor.RequestPointAsync(); var screenPoint = MyMapView.LocationToScreen(mapPoint); foreach (var l in messageSubLayers) { results = results.Concat(await l.HitTestAsync(MyMapView, screenPoint, maxHits)); } } else { maxHits = 100; var geometry = await MyMapView.Editor.RequestShapeAsync(drawMode); var mapEnvelope = (geometry as Envelope).Extent; var upperLeft = MyMapView.LocationToScreen (new MapPoint(mapEnvelope.XMin, mapEnvelope.YMax, geometry.SpatialReference)); var lowerRight = MyMapView.LocationToScreen (new MapPoint(mapEnvelope.XMax, mapEnvelope.YMin, geometry.SpatialReference)); var rect = new Rect(upperLeft, lowerRight); foreach (var l in messageSubLayers) { results = results.Concat(await l.HitTestAsync(MyMapView, rect, maxHits)); } } if (results.Count() == 0) { return; } foreach (var graphic in results) { MilitaryMessage message = _messageLayer.GetMessage(graphic.Attributes["_id"].ToString()) as MilitaryMessage; message.MessageAction = MilitaryMessageAction.Select; if (_messageLayer.ProcessMessage(message)) { selectedMessages.Add(message); } else { MessageBox.Show("Failed"); } } }
public void StoreControlPoints(string phaseID, MilitaryMessage msg) { this[MilitaryMessage.ControlPointsPropertyName] = msg[MilitaryMessage.ControlPointsPropertyName]; if (PhaseControlPointsDictionary.ContainsKey(phaseID)) { PhaseControlPointsDictionary[phaseID] = msg[MilitaryMessage.ControlPointsPropertyName]; } else { PhaseControlPointsDictionary.Add(phaseID, msg[MilitaryMessage.ControlPointsPropertyName]); } }
private void UpdateCurrentMessage(TimeAwareMilitaryMessage tam, Geometry geometry) { var cpts = string.Empty; // TODO find a way to determine if polyline map points need adjustment based on symbol being drawn List <MapPoint> mpList = null; var polyline = geometry as Polyline; if (polyline != null) { if (tam[MilitaryMessage.SicCodePropertyName].Contains("POLA") || tam[MilitaryMessage.SicCodePropertyName].Contains("PPA")) { mpList = AdjustMapPoints(polyline, DrawShape.Arrow); } else { mpList = AdjustMapPoints(polyline, DrawShape.Polyline); } } else { var polygon = geometry as Polygon; if (polygon != null) { mpList = new List <MapPoint>(); foreach (var part in polygon.Parts) { mpList.AddRange(part.GetPoints()); } } } if (mpList != null) { var msg = new MilitaryMessage(tam.Id, MilitaryMessageType.PositionReport, MilitaryMessageAction.Update, mpList); tam[MilitaryMessage.ControlPointsPropertyName] = msg[MilitaryMessage.ControlPointsPropertyName]; if (_militaryMessageLayer.ProcessMessage(msg)) { UpdateMilitaryMessageControlPoints(msg); DoCloneMission(null); } } }
private void SelectMessage(Message message, bool isSelected) { if (_militaryMessageLayer == null || message == null) { return; } _currentMessage = isSelected ? message : null; var msg = new MilitaryMessage(message.Id, MilitaryMessageType.PositionReport, isSelected ? MilitaryMessageAction.Select : MilitaryMessageAction.UnSelect); if (_militaryMessageLayer.ProcessMessage(msg)) { } }
private void UpdateCurrentMessage(MapPoint mapPoint) { if (_currentMessage != null && _militaryMessageLayer != null) { var msg = new MilitaryMessage(_currentMessage.Id, MilitaryMessageType.PositionReport, MilitaryMessageAction.Update, new List <MapPoint>() { mapPoint }); if (_militaryMessageLayer.ProcessMessage(msg)) { UpdateMilitaryMessageControlPoints(msg); } } }
// Performs a HitTest on the rendered Messages and selects the results private async Task FindIntersectingGraphicsAsync(DrawShape drawMode) { // Get sub layers of the MessageLayer var messageSubLayers = _messageLayer.ChildLayers.Cast <MessageSubLayer>(); // Create an empty result set IEnumerable <Graphic> results = Enumerable.Empty <Graphic>(); // Set the max hits to 1 int maxHits = 1; // Handle the individual Message selection mode if (drawMode == DrawShape.Point) { // Ask the user for the point of interest MapPoint mapPoint = null; try { mapPoint = await MyMapView.Editor.RequestPointAsync(); } catch (TaskCanceledException) { } // Check the geometry if (Geometry.IsNullOrEmpty(mapPoint)) { return; } // Get the location in screen coordinates var screenPoint = MyMapView.LocationToScreen(mapPoint); // Iterate the Message sub layers and await the HitTestAsync method on each layer foreach (var l in messageSubLayers) { results = results.Concat(await l.HitTestAsync(MyMapView, screenPoint, maxHits)); } } // Handle the multiple Message selection mode else { // Increase the max hits value maxHits = 100; // Ask the user for the area of interest Envelope envelope = null; try { envelope = await MyMapView.Editor.RequestShapeAsync(drawMode) as Envelope; } catch (TaskCanceledException) { } // Check the geometry if (Geometry.IsNullOrEmpty(envelope)) { return; } // Get the screen location of the upper left var upperLeft = MyMapView.LocationToScreen (new MapPoint(envelope.XMin, envelope.YMax, envelope.SpatialReference)); // Get the screen location of the lower right var lowerRight = MyMapView.LocationToScreen (new MapPoint(envelope.XMax, envelope.YMin, envelope.SpatialReference)); // Create a Rect from the two corners var rect = new Rect(upperLeft, lowerRight); // Iterate the Message sub layers and await the HitTestAsync method on each layer foreach (var l in messageSubLayers) { results = results.Concat(await l.HitTestAsync(MyMapView, rect, maxHits)); } } if (results.Count() == 0) { return; } // Iterate the results and modify the Action value to Select then reprocess each Message foreach (var graphic in results) { // Retrieve the Message representation from the MessageLayer for each Graphic returned MilitaryMessage message = _messageLayer.GetMessage(graphic.Attributes["_id"].ToString()) as MilitaryMessage; // Modify the Action to Select message.MessageAction = MilitaryMessageAction.Select; // Reprocess the Message and add to the list if (_messageLayer.ProcessMessage(message)) { selectedMessages.Add(message); } } }
private void UpdateCurrentMessage(TimeAwareMilitaryMessage tam, Geometry geometry) { var cpts = string.Empty; // TODO find a way to determine if polyline map points need adjustment based on symbol being drawn List<MapPoint> mpList = null; var polyline = geometry as Polyline; if (polyline != null) { if (tam[MilitaryMessage.SicCodePropertyName].Contains("POLA") || tam[MilitaryMessage.SicCodePropertyName].Contains("PPA")) { mpList = AdjustMapPoints(polyline, DrawShape.Arrow); } else { mpList = AdjustMapPoints(polyline, DrawShape.Polyline); } } else { var polygon = geometry as Polygon; if (polygon != null) { mpList = new List<MapPoint>(); foreach (var part in polygon.Parts) { mpList.AddRange(part.GetPoints()); } } } if (mpList != null) { var msg = new MilitaryMessage(tam.Id, MilitaryMessageType.PositionReport, MilitaryMessageAction.Update, mpList); tam[MilitaryMessage.ControlPointsPropertyName] = msg[MilitaryMessage.ControlPointsPropertyName]; if (_militaryMessageLayer.ProcessMessage(msg)) { UpdateMilitaryMessageControlPoints(msg); DoCloneMission(null); } } }
private void UpdateCurrentMessage(MapPoint mapPoint) { if (_currentMessage != null && _militaryMessageLayer != null) { var msg = new MilitaryMessage(_currentMessage.Id, MilitaryMessageType.PositionReport, MilitaryMessageAction.Update, new List<MapPoint>() { mapPoint }); if (_militaryMessageLayer.ProcessMessage(msg)) { UpdateMilitaryMessageControlPoints(msg); DoCloneMission(null); } } }
private void SelectMessage(Message message, bool isSelected) { if (_militaryMessageLayer == null || message == null) return; _currentMessage = isSelected ? message : null; var msg = new MilitaryMessage(message.Id, MilitaryMessageType.PositionReport, isSelected ? MilitaryMessageAction.Select : MilitaryMessageAction.UnSelect); if (_militaryMessageLayer.ProcessMessage(msg)) { } }
private void RemoveMessage(Message message) { var msg = new MilitaryMessage(message.Id, MilitaryMessageType.PositionReport, MilitaryMessageAction.Remove); // remove from visible layer _militaryMessageLayer.ProcessMessage(msg); RemoveMessageFromPhase(CurrentPhaseIndex, _mission.MilitaryMessages.First(m => m.Id == message.Id)); DoCloneMission(null); }