private async void SearchButton_Click(object sender, RoutedEventArgs e) { SearchButton.IsEnabled = false; Spinner.IsActive = true; var userOrId = UsernameTextBox.Text.Trim(); var selectedText = ((System.Windows.Controls.ComboBoxItem)PlatformDropdown.SelectedValue).Content.ToString(); try { var users = await _tracker.Search(userOrId, RlTracker.GetPlatform(selectedText)); foreach (var user in users) { user.IsTracked = !_trackedUsersManager.IsTracked(user.PlatformUserIdentifier); } SearchResults.ItemsSource = users; } catch (Exception) { } finally { SearchResults.Visibility = Visibility.Visible; TrackedGrid.Visibility = Visibility.Hidden; SearchButton.IsEnabled = true; Spinner.IsActive = false; } }
/// <summary> /// Track a new user /// </summary> /// <param name="userId"></param> /// <param name="platform"></param> public async void Add(string userId, string platform) { var plat = RlTracker.GetPlatform(platform); var trackedUser = new TrackedUser() { PlatForm = plat, UserId = long.Parse(userId) }; await RefreshUser(trackedUser); if (!_users.Any(x => x.UserId == trackedUser.UserId)) { trackedUser.SortOrder = this._users.Count; _users.Add(trackedUser); } Save(); }