private async Task RefreshChannelStatus(bool notify = false) { TwitchChecker checker = new TwitchChecker(_cm.GetApiKey()); foreach (string item in _cm.GetChannels()) { int? itemindex = GetCorrespondingListItemIndex(item); TwitchChannel chan = await checker.CheckChannel(item); if (itemindex != null) { ChannelListBox.Items.RemoveAt((int)itemindex); ChannelListBox.Items.Insert((int)itemindex, chan); } else { ChannelListBox.Items.Add(chan); } if (chan.Status != "offline") { //todo: Notify } } RefreshUpdateTimestamp(); }
private async void ButtonAdd_ClickAsync(object sender, RoutedEventArgs e) { AddChannelWindow addwindow = new AddChannelWindow(this); addwindow.ShowDialog(); TwitchChecker tc = new TwitchChecker(_cm.GetApiKey()); if (!string.IsNullOrEmpty(addwindow.ChannelName)) { TwitchChannel chan = await tc.CheckChannel(addwindow.ChannelName); ChannelListBox.Items.Add(chan); _cm.AddChannel(addwindow.ChannelName); } }