Пример #1
0
        private static bool TrySetSteamID(string input, out SteamID steamID)
        {
            steamID = new SteamID();

            if (steamID.SetFromString(input, EUniverse.Public) ||
                steamID.SetFromSteam3String(input))
            {
                return(true);
            }

            ulong numericInput;

            if (ulong.TryParse(input, out numericInput))
            {
                steamID.SetFromUInt64(numericInput);

                return(true);
            }

            return(false);
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var    steam = new SteamID();
            string url;

            if (!SteamID.CommunityURLRegex.IsMatch(TxtSteam.Text))
            {
                if (!steam.SetFromString(TxtSteam.Text) && !steam.SetFromSteam3String(TxtSteam.Text))
                {
                    ToastManager.ShowToastAsync("Could not add cheater",
                                                $"Steam ID '{TxtSteam.Text}' is not valid.",
                                                Notifications.Wpf.Core.NotificationType.Warning);
                    return;
                }
                url = $"https://steamcommunity.com/profiles/{steam.ConvertToUInt64()}/?xml=1";
            }
            else
            {
                url = $"{SteamID.CommunityURLRegex.Match(TxtSteam.Text).Value}/?xml=1";
            }

            var data = await Steam.GetProfileDataAsync(url);

            int.TryParse(TxtThreat.Text, out int threat);
            Cheater cheater = new()
            {
                AccountID     = Convert.ToUInt64(data.steamID64),
                CheatList     = TxtCheats.Text,
                LastKnownName = data.steamID,
                Submitter     = TxtSubmitter.Text,
                ThreatLevel   = threat,
                Notes         = TxtNotes.Text
            };

            Cheaters.Add(cheater);
            ToastManager.ShowToastAsync("Successfully added cheater",
                                        $"Hacker '{data.steamID}' has been added to the list.",
                                        Notifications.Wpf.Core.NotificationType.Success);
        }