internal static EFilter_Game propertiesDict_getGame() { EFilter_Game game = EFilter_Game.css; if (App.Current.Properties.ContainsKey("game")) { string gameString = App.Current.Properties["game"] as string; switch (gameString) { case "css": game = EFilter_Game.css; break; case "css100t": game = EFilter_Game.css100t; break; case "csgo": game = EFilter_Game.csgo; break; default: goto case "css"; } } else { App.Current.Properties.Add("game", EFilter_ToString.toString(game)); App.Current.SavePropertiesAsync(); } return(game); }
// UI --------------------------------------------------------------------------------------------------------- #region UI private async Task ChangeRecentRecords(EFilter_Game game, EFilter_RRType type, EFilter_Mode mode) { if (type == EFilter_RRType.top) { var recentRecords10Datum = await recordsViewModel.GetRecentRecords10(game, mode); recentRecords10Data = recentRecords10Datum?.data; if (recentRecords10Data is null) { return; } LayoutRecentRecords10(); } else { var recentRecordsDatum = await recordsViewModel.GetRecentRecords(game, type, mode); recentRecordsData = recentRecordsDatum?.data; if (recentRecordsData is null) { return; } LayoutRecentRecords(EFilter_ToString.toString2(type)); } lastRefresh = DateTime.Now; }
internal async Task <MapTopRootObject> GetMapTop(EFilter_Game game, string map, EFilter_Mode mode, int zone, int start_index) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); if (gameString == "" || map == "" || zone < 0) { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/top/map/" + map + "/zone/" + zone + "/" + start_index + ",25/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <MapTopRootObject>(response.Content)); } else { return(null); } }
internal async Task <PlayerWRsRootObject> GetPlayerWRs(EFilter_Game game, EFilter_Mode mode, EFilter_PlayerWRsType wrType, EFilter_PlayerType playerType, string playerValue, int startIndex) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); string wrString = EFilter_ToString.toString(wrType); string playerTypeString = EFilter_ToString.toString(playerType); if (gameString == "" || playerValue == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/" + playerTypeString + "/" + playerValue + "/" + wrString + "/" + startIndex + ",10/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <PlayerWRsRootObject>(response.Content)); } else { return(null); } }
// KSF API calls ----------------------------------------------------------------------------------------------------------- #region ksf internal async Task <DetailedMapsRootObject> GetDetailedMapsList(EFilter_Game game, EFilter_Sort sort) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string sortString = EFilter_ToString.toString(sort); if (gameString == "" || sortString == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/maplist/detailedlist/" + sortString + "/1,999"); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <DetailedMapsRootObject>(response.Content)); } else { return(null); } }
internal async Task <MapInfoRootObject> GetMapInfo(EFilter_Game game, string map) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); if (gameString == "" || map == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/map/" + map + "/mapinfo"); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <MapInfoRootObject>(response.Content)); } else { return(null); } }
public LivePage() { liveViewModel = new LiveViewModel(); defaultGame = BaseViewModel.propertiesDict_getGame(); InitializeComponent(); }
internal async Task <MapPRInfoRootObject> GetMapPRInfo(EFilter_Game game, EFilter_Mode mode, string map, EFilter_PlayerType playerType, string playerValue) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); string playerTypeString = EFilter_ToString.toString(playerType); if (gameString == "" || map == "" || playerValue == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/map/" + map + "/zone/0/" + playerTypeString + "/" + playerValue + "/recordinfo/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <MapPRInfoRootObject>(response.Content)); } else { return(null); } }
internal async Task <string> GetTopCountry(EFilter_Game game, EFilter_Mode mode) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); if (gameString == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/top/countries/1,1/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { TopCountriesRootObject tcro = JsonConvert.DeserializeObject <TopCountriesRootObject>(response.Content); return(tcro.data[0]?.country); } else { return(null); } }
internal async Task <RR10RootObject> GetRecentRecords10(EFilter_Game game, EFilter_Mode mode) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string modeString = ((int)mode).ToString(); if (gameString == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/recentrecords/server/top10/1,10/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <RR10RootObject>(response.Content)); } else { return(null); } }
internal async Task <OldestRecordsRootObject> GetOldestRecords(EFilter_Game game, EFilter_ORType type, EFilter_Mode mode, int start_index) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); string typeString = EFilter_ToString.toString(type); string modeString = ((int)mode).ToString(); if (gameString == "" || typeString == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/oldestrecords/server/" + typeString + "/" + start_index + ",10/" + modeString); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <OldestRecordsRootObject>(response.Content)); } else { return(null); } }
// KSF API call ------------------------------------------------------------------------- #region ksf internal async Task <KSFServerRootObject> GetServers(EFilter_Game game) { if (!BaseViewModel.hasConnection()) { return(null); } string gameString = EFilter_ToString.toString(game); if (gameString == "") { return(null); } client.BaseUrl = new Uri("http://surf.ksfclan.com/api2/" + gameString + "/servers/list"); await Task.Run(() => response = client.Execute(request)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <KSFServerRootObject>(response.Content)); } else { if (BaseViewModel.client.UserAgent != "" || BaseViewModel.AGENT != "") { BaseViewModel.AGENT = ""; BaseViewModel.client.UserAgent = ""; return(await GetServers(game)); } return(null); } }
// UI ------------------------------------------------------------------------------------------------------------------------------------- #region UI private void ChangeGameFilter(EFilter_Game newGame) { if (game == newGame) { return; } switch (game) { case EFilter_Game.css: GameCSSLabel.TextColor = untappedTextColor; break; case EFilter_Game.css100t: GameCSS100TLabel.TextColor = untappedTextColor; break; case EFilter_Game.csgo: GameCSGOLabel.TextColor = untappedTextColor; break; default: break; } switch (newGame) { case EFilter_Game.css: GameCSSLabel.TextColor = tappedTextColor; break; case EFilter_Game.css100t: GameCSS100TLabel.TextColor = tappedTextColor; break; case EFilter_Game.csgo: GameCSGOLabel.TextColor = tappedTextColor; break; } BaseViewModel.vibrate(allowVibrate); game = newGame; }
public MapsPage() { mapsViewModel = new MapsViewModel(); defaultGame = BaseViewModel.propertiesDict_getGame(); InitializeComponent(); }
public PlayerFilterPage(Action <EFilter_Game, EFilter_Mode, EFilter_PlayerType, string> FilterApplier, EFilter_Game currentGame, EFilter_Mode currentMode, EFilter_PlayerType currentPlayerType, string currentPlayerSteamId, string currentPlayerRank, EFilter_Game defaultGame, EFilter_Mode defaultMode, string meSteamId) { this.FilterApplier = FilterApplier; this.defaultGame = defaultGame; this.defaultMode = defaultMode; this.meSteamId = meSteamId; InitializeComponent(); ChangeGameFilter(currentGame); ChangeModeFilter(currentMode); ChangePlayerFilter(currentPlayerType); PlayerMeIDLabel.Text = " " + meSteamId; playerRank = currentPlayerRank; RankEntry.Text = playerRank; playerSteamId = currentPlayerSteamId; SteamIdEntry.Text = playerSteamId; allowVibrate = true; }
// Loading KSF map list -------------------------------------------------------------------------------------------------------------------- #region ksf private async Task <List <string> > LoadMaps(EFilter_Game game, EFilter_Sort sort, int minTier, int maxTier, EFilter_MapType mapType) { // minTier options: 1-8 // maxTier options: 1-8 maps_list = new List <string>(); try { if (game != currentGame || sort != currentSort) { DetailedMapsRootObject dmro = await mapsViewModel.GetDetailedMapsList(game, sort); if (dmro == null) { Console.WriteLine("KSF Server Request returned NULL (MapsPage)"); MapsCollectionEmptyViewLabel.Text = "Could not reach KSF servers :("; return(maps_list); } MapsCollectionEmptyViewLabel.Text = "No maps matched your filter"; MapsTab.Title = "Maps [" + EFilter_ToString.toString2(game) + "]"; detailed_mapData = new List <DetailedMapDatum>(dmro.data); currentGame = game; currentSort = sort; } currentMinTier = minTier; currentMaxTier = maxTier; currentMapType = mapType; foreach (DetailedMapDatum datum in detailed_mapData) { int tier = int.Parse(datum.tier); int type = int.Parse(datum.maptype); if (mapType != EFilter_MapType.any && type != (int)mapType) { continue; } else if (tier < minTier) { continue; } else if (tier > maxTier) { continue; } maps_list.Add(datum.name); } } catch (FormatException) { Console.WriteLine("Problem parsing KSFDetailedMapDatum.data field (MapsPage)"); } return(maps_list); }
public RecordsTopCountriesPage(string title, RecordsViewModel recordsViewModel, EFilter_Game game, EFilter_Mode mode) { this.recordsViewModel = recordsViewModel; this.game = game; this.mode = mode; InitializeComponent(); Title = title; }
public RecordsCountryTopPage(string title, RecordsViewModel recordsViewModel, EFilter_Game game, EFilter_Mode mode) { this.recordsViewModel = recordsViewModel; this.game = game; this.mode = mode; InitializeComponent(); Title = title; CountryPicker.ItemsSource = EFilter_ToString.ctopCountries; }
public RecordsOldestPage(string title, RecordsViewModel recordsViewModel, EFilter_Game game, EFilter_Mode mode) { this.recordsViewModel = recordsViewModel; this.game = game; this.mode = mode; this.oldestType = EFilter_ORType.map; InitializeComponent(); Title = title; }
public PlayerRecentRecordsPage(string title, PlayerViewModel playerViewModel, EFilter_Game game, EFilter_Mode mode, EFilter_PlayerType playerType, string playerValue) { this.playerViewModel = playerViewModel; this.game = game; this.mode = mode; this.playerType = playerType; this.playerValue = playerValue; InitializeComponent(); Title = title; }
public RecordsPage() { recordsViewModel = new RecordsViewModel(); InitializeComponent(); game = BaseViewModel.propertiesDict_getGame(); defaultGame = game; mode = BaseViewModel.propertiesDict_getMode(); defaultMode = mode; recentRecordsType = EFilter_RRType.map; }
public MapsMapCPRPage(string title, MapsViewModel mapsViewModel, EFilter_Game game, EFilter_Mode mode, string map, string playerSteamID) { this.mapsViewModel = mapsViewModel; this.game = game; this.mode = mode; this.map = map; this.playerSteamID = playerSteamID; InitializeComponent(); Title = title; }
public RecordsMostPage(string title, RecordsViewModel recordsViewModel, EFilter_Game game, EFilter_Mode mode) { this.recordsViewModel = recordsViewModel; this.game = game; this.mode = mode; mostType = EFilter_MostType.wr; mostTypeString = "Current WRs"; InitializeComponent(); Title = title; MostTypePicker.ItemsSource = EFilter_ToString.mosttype_arr; }
public MapsMapPRDetailsPage(string title, MapsViewModel mapsViewModel, EFilter_Game game, EFilter_Mode mode, EFilter_Mode defaultMode, string map, string playerSteamID) { mapsMapTitle = title; this.mapsViewModel = mapsViewModel; this.game = game; this.mode = (mode == EFilter_Mode.none)? defaultMode : mode; this.map = map; this.playerSteamID = playerSteamID; InitializeComponent(); Title = title; }
public PlayerMapsCompletionPage(string title, PlayerViewModel playerViewModel, EFilter_Game game, EFilter_Mode mode, EFilter_PlayerCompletionType completionType, EFilter_PlayerType playerType, string playerValue) { this.playerViewModel = playerViewModel; this.game = game; this.mode = mode; this.playerType = playerType; this.playerValue = playerValue; this.completionType = completionType; InitializeComponent(); Title = title; HeaderLabel.Text = EFilter_ToString.toString2(completionType); }
internal async void ApplyFilters(EFilter_Game newGame, EFilter_Mode newMode, EFilter_PlayerType newPlayerType, string newPlayerValue) { if (BaseViewModel.hasConnection()) { LoadingAnimation.IsRunning = true; await ChangePlayerInfo(newGame, newMode, newPlayerType, newPlayerValue); LoadingAnimation.IsRunning = false; } else { await DisplayNoConnectionAlert(); } await PlayerPageScrollView.ScrollToAsync(0, 0, true); }
public SettingsPage() { InitializeComponent(); EFilter_Game currentGame = BaseViewModel.propertiesDict_getGame(); EFilter_Mode currentMode = BaseViewModel.propertiesDict_getMode(); playerSteamID = BaseViewModel.propertiesDict_getSteamID(); ChangeGameFilter(currentGame); ChangeModeFilter(currentMode); SteamIdEntry.Text = playerSteamID; allowVibrate = true; }
public RecordsFilterPage(Action <EFilter_Game, EFilter_Mode> FilterApplier, EFilter_Game currentGame, EFilter_Mode currentMode, EFilter_Game defaultGame, EFilter_Mode defaultMode) { this.FilterApplier = FilterApplier; this.defaultGame = defaultGame; this.defaultMode = defaultMode; InitializeComponent(); ChangeGameFilter(currentGame); ChangeModeFilter(currentMode); allowVibrate = true; }
public static string toString2(EFilter_Game game) { string gameString = ""; switch (game) { case EFilter_Game.css: gameString = "CS:S"; break; case EFilter_Game.css100t: gameString = "CS:S 100T"; break; case EFilter_Game.csgo: gameString = "CS:GO"; break; default: break; } return(gameString); }
public static string toString(EFilter_Game game) { string gameString = ""; switch (game) { case EFilter_Game.css: gameString = "css"; break; case EFilter_Game.css100t: gameString = "css100t"; break; case EFilter_Game.csgo: gameString = "csgo"; break; default: break; } return(gameString); }