private void BiliLiveListener_Connected() { ConfigManager.CurrentStatus.IsConnected = true; uint roomId = 0; Dispatcher.Invoke(new Action(() => { ConnectBtn.IsEnabled = true; ConnectBtn.Content = Application.Current.Resources["Disconnect"].ToString(); RoomIdBox.Visibility = Visibility.Hidden; InfoGrid.Visibility = Visibility.Visible; TitleBox.Text = Application.Current.Resources["BiliLiveHelper"].ToString() + " - " + RoomIdBox.Text; //AppendMessage(Application.Current.Resources["Connected"].ToString(), (Color)ColorConverter.ConvertFromString("#FF19E62C")); roomId = uint.Parse(RoomIdBox.Text); })); biliLiveInfo = new BiliLiveInfo(roomId); BiliLiveInfo.Info info = null; while (info == null) { info = biliLiveInfo.GetInfo(ConfigManager.CurrentConfig.Timeout); } BiliLiveInfo_InfoUpdate(info); biliLiveInfo.InfoUpdate += BiliLiveInfo_InfoUpdate; biliLiveInfo.StartInfoListener(ConfigManager.CurrentConfig.Timeout, 30 * 1000); }
// Info recieved private void BiliLiveInfo_InfoUpdate(BiliLiveInfo.Info info) { Dispatcher.Invoke(new Action(() => { if (info.LiveStatus == 1) { TitleBox.Text = Application.Current.Resources["Living"].ToString() + " - " + info.Title; } else { TitleBox.Text = Application.Current.Resources["Preparing"].ToString() + " - " + info.Title; } AreaBox.Text = string.Format("{0} ยท {1}", info.ParentAreaName, info.AreaName); InfoGrid.ToolTip = Regex.Replace(Regex.Replace(Regex.Unescape(info.Description.Replace(" ", " ")), @"<[^>]+>|</[^>]+>", string.Empty), @"(\r?\n)+", "\r\n").Trim(); })); }