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> /// Manager for tracked users /// </summary> /// <param name="searcher">Instance used to Update tracked users</param> public TrackedUsersManager(RlTracker searcher, AppSettings settings) : base() { _settings = settings; _users = new ObservableCollection <TrackedUser>(); _searcher = searcher; _tokenSource = new CancellationTokenSource(); _context = SynchronizationContext.Current; }
public MainWindow(AppSettings settings) { _settings = settings; InitializeComponent(); GithubButton.Content = "v" + Assembly.GetExecutingAssembly().GetName().Version.ToString(); _tracker = new RlTracker(); _trackedUsersManager = new TrackedUsersManager(_tracker, _settings); _trackedUsersManager.Users.CollectionChanged += Users_CollectionChanged; _trackedUsersManager.StartMonitor(); CachedImage.FileCache.AppCacheMode = CachedImage.FileCache.CacheMode.Dedicated; this.DataContext = vm; CheckForUpdates(); }
/// <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(); }
public MainWindow(AppSettings settings) { _settings = settings; InitializeComponent(); GithubButton.Content = "v" + Assembly.GetExecutingAssembly().GetName().Version.ToString(); _tracker = new RlTracker(); _trackedUsersManager = new TrackedUsersManager(_tracker, _settings); _trackedUsersManager.Users.CollectionChanged += Users_CollectionChanged; _trackedUsersManager.SessionUserUpdated += _trackedUsersManager_SessionUserUpdated; _trackedUsersManager.StartMonitor(); CachedImage.FileCache.AppCacheMode = CachedImage.FileCache.CacheMode.Dedicated; this.DataContext = vm; CheckForUpdates(); //Start timer to show next refresh time System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += DispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); }