예제 #1
0
        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);
        }
예제 #2
0
        // 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;
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        // 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);
            }
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        public LivePage()
        {
            liveViewModel = new LiveViewModel();
            defaultGame   = BaseViewModel.propertiesDict_getGame();

            InitializeComponent();
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
        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);
            }
        }
예제 #11
0
        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);
            }
        }
예제 #12
0
        // 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);
            }
        }
예제 #13
0
        // 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;
        }
예제 #14
0
        public MapsPage()
        {
            mapsViewModel = new MapsViewModel();
            defaultGame   = BaseViewModel.propertiesDict_getGame();

            InitializeComponent();
        }
예제 #15
0
        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;
        }
예제 #16
0
        // 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;
        }
예제 #18
0
        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;
        }
예제 #19
0
        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;
        }
예제 #20
0
        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;
        }
예제 #21
0
        public RecordsPage()
        {
            recordsViewModel = new RecordsViewModel();
            InitializeComponent();

            game              = BaseViewModel.propertiesDict_getGame();
            defaultGame       = game;
            mode              = BaseViewModel.propertiesDict_getMode();
            defaultMode       = mode;
            recentRecordsType = EFilter_RRType.map;
        }
예제 #22
0
        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;
        }
예제 #23
0
        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;
        }
예제 #24
0
        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);
        }
예제 #26
0
        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);
        }
예제 #27
0
        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;
        }
예제 #28
0
        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;
        }
예제 #29
0
        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);
        }
예제 #30
0
        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);
        }