示例#1
0
        /// <summary>
        /// コメント受信イベントハンドラ
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="comment"></param>
        private void YoutubeChatClient_OnCommentReceiveEach(YoutubeChatClient sender, CommentStruct comment)
        {
            // コメントの追加
            UiCommentData uiCommentData = new UiCommentData();

            uiCommentData.UserThumbUrl = "";
            uiCommentData.UserName     = comment.UserName;
            uiCommentData.CommentStr   = comment.Text;

            System.Diagnostics.Debug.WriteLine("UserThumbUrl " + uiCommentData.UserThumbUrl);
            System.Diagnostics.Debug.WriteLine("UserName " + uiCommentData.UserName);
            System.Diagnostics.Debug.WriteLine("CommentStr " + uiCommentData.CommentStr);

            ViewModel viewModel = this.DataContext as ViewModel;
            ObservableCollection <UiCommentData> uiCommentDataList = viewModel.UiCommentDataCollection;

            uiCommentDataList.Add(uiCommentData);

            // コメントログを記録
            WriteLog(uiCommentData.UserName, uiCommentData.CommentStr);

            // 棒読みちゃんへ送信
            if (comment.IsBouyomiOn)
            {
                string sendText = comment.Text;
                string bcTitle  = YoutubeChatClient.BcTitle;
                if (bcTitle != "")
                {
                    StringBuilder sendTextSb = new StringBuilder(sendText);
                    sendTextSb.Replace("(" + bcTitle + ")", "");
                    sendText = sendTextSb.ToString();
                }
                bouyomiChan.Talk(sendText);
            }
        }
示例#2
0
        /// <summary>
        /// ウィンドウが開かれた
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var window = new SettingWindow();

            window.Owner = this;
            window.ShowDialog();
            string apiKey = window.APIKey;

            YoutubeChatClient = new YoutubeChatClient();
            YoutubeChatClient.OnCommentReceiveEach += YoutubeChatClient_OnCommentReceiveEach;
            YoutubeChatClient.OnCommentReceiveDone += YoutubeChatClient_OnCommentReceiveDone;
            YoutubeChatClient.APIKey = apiKey;
        }
示例#3
0
 /// <summary>
 /// コメント受信完了イベントハンドラ
 /// </summary>
 /// <param name="sender"></param>
 private void YoutubeChatClient_OnCommentReceiveDone(YoutubeChatClient sender)
 {
     // データグリッドを自動スクロール
     DataGridScrollToEnd();
 }