private async void LoadData() { List <AtomDTOData> DataList = new List <AtomDTOData>(); try { IEnumerable <FormationTree> Atoms = await SAGSignalR.GetAllAtomsFromTree(VMMainViewModel.Instance.SimulationHubProxy); if (Atoms != null) { foreach (FormationTree atom in Atoms) { AtomDTOData Rdata = new AtomDTOData(); Rdata.atom = atom; DataList.Add(Rdata); } } dtGridActors.ItemsSource = null; dtGridActors.ItemsSource = DataList; if (dtGridActors.ItemsSource == null) { dtGridActors.ItemsSource = new List <AtomDTOData>(); } } catch (Exception ex) { } }
private async void LoadData() { List <ActivityDTONotify> DataList = new List <ActivityDTONotify>(); try { IEnumerable <GeneralActivityDTO> activities = await SAGSignalR.GetActivitesByAtomName(VMMainViewModel.Instance.SimulationHubProxy, AtomCommonProperty.AtomName); if (activities != null) { foreach (GeneralActivityDTO activity in activities) { ActivityDTONotify Rdata = new ActivityDTONotify(); Rdata.ActivityDTO = activity; DataList.Add(Rdata); } } dtGridActivities.ItemsSource = null; dtGridActivities.ItemsSource = DataList; if (dtGridActivities.ItemsSource == null) { dtGridActivities.ItemsSource = new List <ActivityDTONotify>(); } } catch (Exception ex) { } }
private async void Window_Loaded(object sender, RoutedEventArgs e) { startActivity.Value = TimeSpan.Parse("00:00:01"); speedUpDown.Value = 5; if (refActivityDTO != null) { speedUpDown.Value = refActivityDTO.Speed; txtRoute.Text = refActivityDTO.RouteActivity.RouteName; ActivityRoute = await SAGSignalR.GetRouteByName(VMMainViewModel.Instance.SimulationHubProxy, txtRoute.Text); double aXOut = 0; double aYOut = 0; aXOut = Math.Round(refActivityDTO.ReferencePoint.X, 3); aYOut = Math.Round(refActivityDTO.ReferencePoint.Y, 3); txtReferenceX.Content = aXOut.ToString(); txtReferenceY.Content = aYOut.ToString(); txtReferenceX.Tag = refActivityDTO.ReferencePoint.X; txtReferenceY.Tag = refActivityDTO.ReferencePoint.Y; startActivity.Value = refActivityDTO.StartActivityOffset; referencePoint = new DPoint(refActivityDTO.ReferencePoint.X, refActivityDTO.ReferencePoint.Y); //shPath Path = await clsRoadRoutingWebApi.FindShortPath("0", AtomCommonProperty.X, AtomCommonProperty.Y, referencePoint.X, referencePoint.Y, false); //if (Path != null) //{ // ReferenceRoute = new Route(); // ReferenceRoute.Points = Utilites.Convert2DPoint(Path.Points); //} VMMainViewModel.Instance.InvalidateVisual(); } VMMainViewModel.Instance.dlgUserDrawWPF += UserDrawWPF; VMMainViewModel.Instance.dlgMouseLeftClickOnMapEvent += MapOnClick; VMMainViewModel.Instance.InvalidateVisual(); }
public async Task <bool> CheckOk() { if (txtRouteName.Text == String.Empty) { System.Windows.MessageBox.Show(TDSClient.Properties.Resources.strRouteNameisEmpty, String.Empty, MessageBoxButton.OK, MessageBoxImage.Warning); return(false); } txtRouteName.Text = Utilites.TreatApostrophe(txtRouteName.Text); if (m_PolygonPnts == null || m_PolygonPnts.Count < 2) { System.Windows.MessageBox.Show(TDSClient.Properties.Resources.strRoutePoinsmustbeadded, String.Empty, MessageBoxButton.OK, MessageBoxImage.Warning); return(false); } bool isExist = await SAGSignalR.isRouteNameExist(VMMainViewModel.Instance.SimulationHubProxy, txtRouteName.Text); if (isExist) { System.Windows.MessageBox.Show(TDSClient.Properties.Resources.strRouteNameAlreadyExist, String.Empty, MessageBoxButton.OK, MessageBoxImage.Warning); return(false); } //// if (isNew) // { // typRoute[] Routes = UserSession.ClientSideObject.m_GameManagerProxy.GetRoutes(); // if (Routes != null) // { // for (int i = 0; i < Routes.Length; i++) // { // if (Routes[i].RouteName == txtRouteName.Text) // { // ComponentsUtility.KGMsgBox.ShowCustomMsgOk(UserSession.GetParentWindow(this), // KingsGameClientModel.Properties.Resources.strRouteNameAlreadyExist); // // System.Windows.MessageBox.Show("Route Name is Exist", String.Empty, MessageBoxButton.OK, MessageBoxImage.Warning); // return false; // } // } // } // } return(true); }
private async void LoadData() { List <RouteData> RouteDataList = new List <RouteData>(); try { IEnumerable <GeneralActivityDTO> Activities = await SAGSignalR.GetAllActivites(VMMainViewModel.Instance.SimulationHubProxy); IEnumerable <Route> Routes = await SAGSignalR.getRoutes(VMMainViewModel.Instance.SimulationHubProxy); if (Routes != null) { foreach (Route route in Routes) { RouteData Rdata = new RouteData(); Rdata.route = route; if (Activities != null) { foreach (GeneralActivityDTO activity in Activities) { if (activity.RouteActivity.RouteGuid == route.RouteGuid) { Rdata.IsInUse = true; break; } } } RouteDataList.Add(Rdata); } } dtGridRoute.ItemsSource = null; dtGridRoute.ItemsSource = RouteDataList; if (dtGridRoute.ItemsSource == null) { dtGridRoute.ItemsSource = new List <RouteData>(); } } catch (Exception ex) { } }
private async void MapHomeZoom_Click() { try { UserParameters userParameters = await SAGSignalR.GetUserParameters(VMMainViewModel.Instance.SimulationHubProxy, UserName); if (userParameters != null) { p_objMap.Position = new PointLatLng(userParameters.MapHomeCenterY, userParameters.MapHomeCenterX); p_objMap.Zoom = userParameters.MapHomeZoom; p_objMap.InvalidateVisual(true); } } catch (Exception ex) { } }
public async void frm_EndAtomObjectsEditEvent(object sender, AtomObjectsEditEventArgs args) { FormationTree atomDTO = await SAGSignalR.SaveTreeObject(VMMainViewModel.Instance.SimulationHubProxy, args.atomDTO); if (args.isNew) { AtomDTOData Rdata = new AtomDTOData(); Rdata.atom = atomDTO; ((List <AtomDTOData>)(dtGridActors.ItemsSource)).Add(Rdata); dtGridActors.Items.Refresh(); dtGridActors.SelectedItem = Rdata; dtGridActors.CurrentItem = Rdata; DataGridWPFUtility.DataGridGotoLast(dtGridActors); } }
public async void frmRouteList_EndDrawPolygonEvent(object sender, DrawPolygonEventArgs args) { if (txtRoute.Text != args.PolygonName) { txtReferenceX.Tag = null; txtReferenceX.Content = string.Empty; txtReferenceY.Content = string.Empty; referencePoint.X = 0; referencePoint.Y = 0; } txtRoute.Text = args.PolygonName; Route route = await SAGSignalR.GetRouteByName(VMMainViewModel.Instance.SimulationHubProxy, txtRoute.Text); ActivityRoute = route; VMMainViewModel.Instance.InvalidateVisual(); }
private async void cmdSaveUser_Click(object sender, RoutedEventArgs e) { ApplyNewLayout(); List <WMSProviderSelectedMaps> Maps = (List <WMSProviderSelectedMaps>)dataGridLayerName.ItemsSource; UserMaps usermaps = new UserMaps(); List <UserMapPreference> MapPreferenceList = new List <UserMapPreference>(); foreach (WMSProviderSelectedMaps SelectedMap in Maps) { if (SelectedMap.isSelected) { UserMapPreference userMapInfo = new UserMapPreference(); userMapInfo.MapName = SelectedMap.MapName; userMapInfo.MaxZoom = SelectedMap.UserMaxZoom; userMapInfo.MinZoom = SelectedMap.UserMinZoom; MapPreferenceList.Add(userMapInfo); } } usermaps.maps = MapPreferenceList.ToArray <UserMapPreference>(); usermaps.User = VMMainViewModel.Instance.UserName; // usermaps = await SAGSignalR.GetUserMaps(VMMainViewModel.Instance.SimulationHubProxy, UserName); try { if (VMMainViewModel.Instance.SimulationHubProxy != null) { await SAGSignalR.SaveUserMaps(VMMainViewModel.Instance.SimulationHubProxy, usermaps); } } catch (Exception ex) { } //MapInfo.UserMapList = usermapDictionary.Values.ToArray<UserMapLayerInfo>(); //MapList.Add(MapInfo); //if (UserSession.ClientSideObject.m_GameManagerProxy != null) //{ // UserSession.ClientSideObject.m_GameManagerProxy.SetUserMapInfoCustomProvider(MapList.ToArray<UserMapInfo>()); //} }
private async void btnSaveZoom_Click(object sender, RoutedEventArgs e) { UserParameters usrParameters = new UserParameters(); usrParameters.User = VMMainViewModel.Instance.UserName; usrParameters.MapHomeZoom = (int)VMMainViewModel.Instance.MyMainMap.Zoom; usrParameters.MapHomeCenterX = VMMainViewModel.Instance.MyMainMap.Position.Lng; usrParameters.MapHomeCenterY = VMMainViewModel.Instance.MyMainMap.Position.Lat; try { if (VMMainViewModel.Instance.SimulationHubProxy != null) { await SAGSignalR.SaveUserParameters(VMMainViewModel.Instance.SimulationHubProxy, usrParameters); } } catch (Exception ex) { } }
async void frm_ActivityDTOEditEvent(object sender, ActivityDTOEditEventArgs args) { if (args.isNew) { int n = ((List <ActivityDTONotify>)(dtGridActivities.ItemsSource)).Count + 1; args.ActivityDTO.Activity_SeqNumber = n; GeneralActivityDTO activity = await SAGSignalR.SaveActivity(VMMainViewModel.Instance.SimulationHubProxy, args.ActivityDTO); ActivityDTONotify Rdata = new ActivityDTONotify(); Rdata.ActivityDTO = activity; ((List <ActivityDTONotify>)(dtGridActivities.ItemsSource)).Add(Rdata); dtGridActivities.Items.Refresh(); dtGridActivities.SelectedItem = Rdata; dtGridActivities.CurrentItem = Rdata; DataGridWPFUtility.DataGridGotoLast(dtGridActivities); } else { GeneralActivityDTO activity = await SAGSignalR.SaveActivity(VMMainViewModel.Instance.SimulationHubProxy, args.ActivityDTO); if (dtGridActivities.ItemsSource == null) { return; } List <ActivityDTONotify> listData = (List <ActivityDTONotify>)(dtGridActivities.ItemsSource); // RouteData currRouteData = null; for (int j = 0; j < listData.Count; j++) { if (listData[j].ActivityId == activity.ActivityId) { // currRouteData = listData[j]; listData[j].ActivityDTO = activity; dtGridActivities.Items.Refresh(); break; } } } }
public async Task <bool> CheckOk() { if (txtName.Text == String.Empty) { System.Windows.MessageBox.Show(TDSClient.Properties.Resources.strPlatformNameisEmpty, String.Empty, MessageBoxButton.OK, MessageBoxImage.Warning); return(false); } txtName.Text = Utilites.TreatApostrophe(txtName.Text); if (isNew) { bool isExist = await SAGSignalR.isAtomNameFromTreeExist(VMMainViewModel.Instance.SimulationHubProxy, txtName.Text); if (isExist) { System.Windows.MessageBox.Show(TDSClient.Properties.Resources.strPlatformWithTheSamenameAlreadyExists, String.Empty, MessageBoxButton.OK, MessageBoxImage.Warning); return(false); } } return(true); }
private async void cmdExit_Click(object sender, RoutedEventArgs e) { bool isCheckOk = await CheckOk(); if (isCheckOk == false) { return; } DrawPolygonEventArgs arg = new DrawPolygonEventArgs(); arg.isCancel = false; arg.isNew = true; arg.PolygonName = txtRouteName.Text.Trim(); arg.PolygonPnts = m_PolygonPnts.ToArray <DPoint>(); // isOK = true; if (EndDrawPolygonEvent != null) { EndDrawPolygonEvent(this, arg); } GeneralActivityDTO ActivityDTO = new GeneralActivityDTO(); ActivityDTO.ActivityType = enumActivity.MovementActivity; AtomData atomdata = new AtomData(); atomdata.UnitName = txPlatformName.Text; atomdata.Location = m_PolygonPnts[0]; ActivityDTO.StartActivityOffset = (TimeSpan)startActivity.Value; ActivityDTO.DurationActivity = (TimeSpan)durationActivity.Value; ActivityDTO.Speed = (int)speedUpDown.Value; Route route = new Route(); route.RouteName = txtRouteName.Text; route.Points = m_PolygonPnts; ActivityDTO.RouteActivity = route; if (refActivityDTO != null) { atomdata.UnitGuid = refActivityDTO.Atom.UnitGuid; ActivityDTO.ActivityId = refActivityDTO.ActivityId; if (ActivityDTO.RouteActivity != null) { ActivityDTO.RouteActivity.RouteGuid = refActivityDTO.RouteActivity.RouteGuid; } } ActivityDTO.Atom = atomdata; await SAGSignalR.SaveActivity(VMMainViewModel.Instance.SimulationHubProxy, ActivityDTO); this.Close(); }
public async void SetData() { string strWMSGeoserverUrl = ConfigurationManager.AppSettings["WMSGeoserver"]; if (string.IsNullOrEmpty(strWMSGeoserverUrl)) { return; } WMSCapabilities Capabilities = await WMSProviderBase.WMSCapabilitiesRetrieve(strWMSGeoserverUrl); List <WMSProviderSelectedMaps> HelperList = new List <WMSProviderSelectedMaps>(); if (Capabilities != null) { //List<GMap.NET.MapProviders.GMapProvider> Layers = null; // Layers = UserSession.ClientSideObject.GetGMapLayers(); UserMaps Layers = await SAGSignalR.GetUserMaps(VMMainViewModel.Instance.SimulationHubProxy, VMMainViewModel.Instance.UserName); int n = 1000; foreach (CustomImageInfo Info in Capabilities.Layers) { n++; WMSProviderSelectedMaps map = new WMSProviderSelectedMaps(); map.MapName = Info.MapName; map.isSelected = false; map.SeqNumber = n; map.UserMinZoom = 0; map.UserMaxZoom = 24; HelperList.Add(map); } if (Layers != null) { for (int i = 0; i < Layers.maps.Length; i++) { UserMapPreference layer = Layers.maps[i]; WMSProviderSelectedMaps map = HelperList.Where(l => l.MapName == layer.MapName).SingleOrDefault(); if (map != null) { map.SeqNumber = i; map.isSelected = true; map.UserMinZoom = layer.MinZoom; map.UserMaxZoom = (int)layer.MaxZoom; } } } HelperList.Sort(delegate(WMSProviderSelectedMaps Struct1, WMSProviderSelectedMaps Struct2) { int Compare = 0; if (Struct2.SeqNumber < Struct1.SeqNumber) { Compare = 1; } else if (Struct2.SeqNumber == Struct1.SeqNumber) { Compare = 0; } else { Compare = -1; } return(Compare); }); } dataGridLayerName.ItemsSource = null; dataGridLayerName.ItemsSource = HelperList; }
public async Task <Exception> InitMapsAsync() { try { UserMaps usermaps = null; this.strWMSGeoserverUrl = ConfigurationManager.AppSettings["WMSGeoserver"]; string strMapCache_Path = ConfigurationManager.AppSettings["MapCache_Path"]; string strMapCacheEnable = ConfigurationManager.AppSettings["MapCacheEnable"]; bool MapCacheEnable = false; if (string.IsNullOrEmpty(strMapCacheEnable) == false) { if (strMapCacheEnable.ToLower() == "false") { MapCacheEnable = false; } else { MapCacheEnable = true; } } // string strWMSGeoserverUrl = ConfigurationManager.AppSettings["WMSGeoserver"]; if (string.IsNullOrEmpty(strWMSGeoserverUrl)) { return(null); } WMSCapabilities Capabilities = await WMSProviderBase.WMSCapabilitiesRetrieve(strWMSGeoserverUrl); if (Capabilities != null && Capabilities.Error == null) { List <WMSProviderBase> overlays = new List <WMSProviderBase>(); WMSProviderBase MapProvider = null; if (VMMainViewModel.Instance.SimulationHubProxy != null) { usermaps = await SAGSignalR.GetUserMaps(VMMainViewModel.Instance.SimulationHubProxy, UserName); UserParameters userParameters = await SAGSignalR.GetUserParameters(VMMainViewModel.Instance.SimulationHubProxy, UserName); if (usermaps != null) { foreach (UserMapPreference info in usermaps.maps) { if (overlays.Exists(t => t.Name == info.MapName)) { continue; } bool isExist = Capabilities.Layers.Exists(t => t.MapName == info.MapName); if (isExist) { WMSProviderBase provider = new WMSProviderBase(info.MapName); provider.Init(strWMSGeoserverUrl, info.MapName, "png"); provider.MinZoom = info.MinZoom; provider.MaxZoom = info.MaxZoom; overlays.Add(provider); if (MapProvider == null) { MapProvider = provider; } } } } if (MapProvider != null) { MapProvider.overlays = overlays.ToArray(); p_objMap.MapProvider = MapProvider; if (MapCacheEnable && string.IsNullOrEmpty(strMapCache_Path) == false) { p_objMap.Manager.Mode = AccessMode.ServerAndCache; p_objMap.CacheLocation = strMapCache_Path; } // p_objMap.Manager.Mode = AccessMode.ServerOnly; //TEMP // p_objMap.Manager.Mode = AccessMode.ServerAndCache; p_objMap.Manager.MemoryCache.Capacity = 44; p_objMap.Zoom = 10; if (userParameters != null) { p_objMap.Position = new PointLatLng(userParameters.MapHomeCenterY, userParameters.MapHomeCenterX); p_objMap.Zoom = userParameters.MapHomeZoom; } p_objMap.ShowTileGridLines = false; p_objMap.InvalidateVisual(true); } // p_objMap.enGMapProvider = enGMapProviders.WMSCustomProvider; } } return(Capabilities.Error); } catch (Exception ex) { return(ex); } return(null); }
public async void SetExClockRatioSpeed(int ExClockRatioSpeed) { await SAGSignalR.SetExClockRatioSpeed(VMMainViewModel.Instance.SimulationHubProxy, ExClockRatioSpeed); }
public async void MapOnClick(object sender, MapMouseEventArgsWPF e) { if (checkBoxMapReferencePoint.IsChecked == true && string.IsNullOrEmpty(txtRoute.Text) == false) { txtReferenceX.Tag = null; referencePoint = new DPoint(); DPoint Dpnt = new DPoint(); Dpnt.X = e.MapXLongLatWGS84; Dpnt.Y = e.MapYLongLatWGS84; Route route = await SAGSignalR.GetRouteByName(VMMainViewModel.Instance.SimulationHubProxy, txtRoute.Text); ActivityRoute = route; if (route != null) { double minDist = double.MaxValue; DPoint minDpoint = new DPoint(); int leg = 0; int i = -1; foreach (DPoint dpoint in route.Points) { i++; double dist = Utilites.GreatCircleDistance(Dpnt.X, Dpnt.Y, dpoint.X, dpoint.Y); if (dist < minDist) { minDist = dist; minDpoint = dpoint; leg = i; } } float NearestIndex = 0; // shPoint[] shPoints = Utilites.Convert2shPoint(route.Points); shPoint pnt = new shPoint(minDpoint.X, minDpoint.Y); //shPoint pnt = TerrainService.MathEngine.ReturnNearestPointOnPolygonBorder(Dpnt.X, Dpnt.Y, shPoints, out NearestIndex); if (pnt.x != 0.0 && pnt.y != 0.0) { referencePoint = new DPoint(pnt.x, pnt.y); } double aXOut = 0; double aYOut = 0; aXOut = Math.Round(pnt.x, 3); aYOut = Math.Round(pnt.y, 3); txtReferenceX.Content = aXOut.ToString(); txtReferenceY.Content = aYOut.ToString(); txtReferenceX.Tag = pnt.x; txtReferenceY.Tag = pnt.y; shPath Path = await clsRoadRoutingWebApi.FindShortPath("0", AtomCommonProperty.X, AtomCommonProperty.Y, pnt.x, pnt.y, false); { ReferenceRoute = new Route(); ReferenceRoute.Points = Utilites.Convert2DPoint(Path.Points); VMMainViewModel.Instance.InvalidateVisual(); } } checkBoxMapReferencePoint.IsChecked = false; } }
public async void RouteEdit_EndDrawPolygonEvent(object sender, DrawPolygonEventArgs args) { dtGridRoute.Focus(); if (args.isCancel) { int i = dtGridRoute.SelectedIndex; if (i > 0) { RouteData currRouteData = (RouteData)dtGridRoute.Items[i]; if (!RouteShowList.ContainsKey(currRouteData.RouteName)) { RouteShowList.Add(currRouteData.RouteName, currRouteData.route); } } } else { Route route = null;// if (!args.isNew) { if (dtGridRoute.ItemsSource == null) { return; } List <RouteData> listData = (List <RouteData>)(dtGridRoute.ItemsSource); RouteData currRouteData = null; for (int j = 0; j < listData.Count; j++) { if (listData[j].RouteName == args.PolygonName) { currRouteData = listData[j]; break; } } if (currRouteData == null) { return; } //Victor currRouteData.route.arr_legs = LegSector; route = currRouteData.route; if (!RouteShowList.ContainsKey(currRouteData.RouteName)) { RouteShowList.Add(currRouteData.RouteName, currRouteData.route); } } else { route = new Route(); // LegSector = CreateLegSector(args.PolygonPnts); route.Points = new List <DPoint>(args.PolygonPnts); route.RouteName = args.PolygonName; RouteData Rdata = new RouteData(); Rdata.route = route; ((List <RouteData>)(dtGridRoute.ItemsSource)).Add(Rdata); dtGridRoute.Items.Refresh(); dtGridRoute.SelectedItem = Rdata; dtGridRoute.CurrentItem = Rdata; DataGridWPFUtility.DataGridGotoLast(dtGridRoute); } await SAGSignalR.SaveRoute(VMMainViewModel.Instance.SimulationHubProxy, route); } }