protected async override void OnDrop(System.Windows.DragEventArgs e) { double currMapX = 0; double currMapY = 0; System.Windows.DataObject d = (System.Windows.DataObject)e.Data; string[] dataFormats = d.GetFormats(); string dataText = d.GetText(); Point position = e.GetPosition(this); GMap.NET.PointLatLng curPosition = FromLocalToLatLng((int)position.X, (int)position.Y); currMapX = curPosition.Lng; currMapY = curPosition.Lat; for (int i = 0; i < dataFormats.Length; i++) { string dragFormat = dataFormats[i]; if (dragFormat.Contains("FormationTree") && dataText == "Actor") { object dragObject = d.GetData(dragFormat); FormationTree formation = dragObject as FormationTree; if (formation == null) { continue; } enOSMhighwayFilter highwayFilter = enOSMhighwayFilter.Undefined; SetHighwayFilter(highwayFilter); shPointId PointId = await clsRoadRoutingWebApi.GetNearestPointIdOnRoad("0", highwayFilter, currMapX, currMapY); if (PointId != null) { shPoint pnt = PointId.point; DeployedFormation deployFormation = new DeployedFormation(); deployFormation.x = pnt.x; deployFormation.y = pnt.y; deployFormation.formation = formation; AtomData atom = await TDSClient.SAGInterface.SAGSignalR.DeployFormationFromTree(VMMainViewModel.Instance.SimulationHubProxy, deployFormation); if (atom != null) { AtomDeployedEventArgs args = new AtomDeployedEventArgs(); args.atom = atom; if (AtomDeployedEvent != null) { AtomDeployedEvent(this, args); } } } return; } } }
protected async override void OnDrop( System.Windows.DragEventArgs e) { double currMapX = 0; double currMapY = 0; System.Windows.DataObject d = (System.Windows.DataObject)e.Data; string[] dataFormats = d.GetFormats(); string dataText = d.GetText(); Point position = e.GetPosition(this); GMap.NET.PointLatLng curPosition = FromLocalToLatLng((int)position.X, (int)position.Y); currMapX = curPosition.Lng; currMapY = curPosition.Lat; for (int i = 0; i < dataFormats.Length; i++) { string dragFormat = dataFormats[i]; if (dragFormat.Contains("FormationTree") && dataText == "Actor") { object dragObject = d.GetData(dragFormat); FormationTree formation = dragObject as FormationTree; if (formation == null) continue; enOSMhighwayFilter highwayFilter = enOSMhighwayFilter.Undefined; SetHighwayFilter(highwayFilter); shPointId PointId = await clsRoadRoutingWebApi.GetNearestPointIdOnRoad("0", highwayFilter, currMapX, currMapY); if (PointId!=null) { shPoint pnt = PointId.point; DeployedFormation deployFormation = new DeployedFormation(); deployFormation.x = pnt.x; deployFormation.y = pnt.y; deployFormation.formation = formation; AtomData atom= await TDSClient.SAGInterface.SAGSignalR.DeployFormationFromTree(VMMainViewModel.Instance.SimulationHubProxy, deployFormation); if(atom!=null) { AtomDeployedEventArgs args = new AtomDeployedEventArgs(); args.atom = atom; if(AtomDeployedEvent!=null) { AtomDeployedEvent(this, args); } } } return; } } }