Example #1
0
 static private void b_ReceivedDanmaku(object sender, ReceivedDanmakuArgs e)
 {
     switch (e.Danmaku.MsgType)
     {
         case MsgTypeEnum.Comment:
             string s = ("收到彈幕:" + (e.Danmaku.isAdmin ? "[管]" : "") + (e.Danmaku.isVIP ? "[爷]" : "") + e.Danmaku.CommentUser + " 說: " + e.Danmaku.CommentText);
             break;
         case MsgTypeEnum.GiftTop:
             break;
         case MsgTypeEnum.GiftSend:
             {
                 break;
             }
         case MsgTypeEnum.Welcome:
             {
                 break;
             }
     }
 }
Example #2
0
 private void b_ReceivedDanmaku(object sender, ReceivedDanmakuArgs e)
 {
     switch (e.Danmaku.MsgType)
     {
         case MsgTypeEnum.Comment:
             {
                 OnComment(e);
                 break;
             }
         case MsgTypeEnum.GiftTop:
             break;
         case MsgTypeEnum.GiftSend:
             {
                 OnGiftSend(e);
                 break;
             }
         case MsgTypeEnum.Welcome:
             {
                 break;
             }
     }
 }
Example #3
0
 private void OnGiftSend(ReceivedDanmakuArgs e)
 {
     if (textBox1.Dispatcher.CheckAccess())
     {
         _messageQueue.Enqueue(
             e.Danmaku.GiftUser
             + " 赠送:  "
             + e.Danmaku.GiftName
             + " x "
             + e.Danmaku.GiftNum);
         textBox1.Text = string.Join("\n", _messageQueue);
         textBox1.ScrollToEnd();
     }
     else
     {
         textBox1.Dispatcher.BeginInvoke(
             DispatcherPriority.Normal,
             new Action(() => OnGiftSend(e)));
     }
 }
Example #4
0
 private void OnComment(ReceivedDanmakuArgs e)
 {
     if (textBox1.Dispatcher.CheckAccess())
     {
         _messageQueue.Enqueue((e.Danmaku.isAdmin ? "[管]" : "") + (e.Danmaku.isVIP ? "[爷]" : "") + e.Danmaku.CommentUser + " 说:  " + e.Danmaku.CommentText);
         textBox1.Text = string.Join("\n", _messageQueue);
         textBox1.ScrollToEnd();
     }
     else
     {
         textBox1.Dispatcher.BeginInvoke(
             DispatcherPriority.Normal,
             new Action(() => OnComment(e)));
     }
 }
Example #5
0
        private void b_ReceivedDanmaku(object sender, ReceivedDanmakuArgs e)
        {
            switch (e.Danmaku.MsgType)
            {
                case MsgTypeEnum.Comment:
                    logging("收到彈幕:" + (e.Danmaku.isAdmin?"[管]":"")+ (e.Danmaku.isVIP ? "[爷]" : "") +e.Danmaku.CommentUser + " 說: " + e.Danmaku.CommentText);

                    AddDMText((e.Danmaku.isAdmin ? "[管]" : "") + (e.Danmaku.isVIP ? "[爷]" : "") + e.Danmaku.CommentUser, e.Danmaku.CommentText);
                    break;
                case MsgTypeEnum.GiftTop:
                    foreach (var giftRank in e.Danmaku.GiftRanking)
                    {
                        var query = Ranking.Where(p => p.uid == giftRank.uid);
                        if (query.Any())
                        {
                            var f = query.First();
                            this.Dispatcher.BeginInvoke(new Action(() => f.coin = giftRank.coin));

                        }
                        else
                        {
                            this.Dispatcher.BeginInvoke(new Action(() => Ranking.Add(new GiftRank()
                            {
                                uid = giftRank.uid,
                                coin = giftRank.coin,
                                UserName = giftRank.UserName
                            })));

                        }
                    }
                    break;
                case MsgTypeEnum.GiftSend:
                {
                    var query = SessionItems.Where(p => p.UserName == e.Danmaku.GiftUser && p.Item == e.Danmaku.GiftName);
                    if (query.Any())
                    {
                        this.Dispatcher.BeginInvoke(
                            new Action(() => query.First().num += Convert.ToDecimal(e.Danmaku.GiftNum)));

                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(new Action(() => SessionItems.Add(
                            new SessionItem()
                            {
                                Item = e.Danmaku.GiftName,
                                UserName = e.Danmaku.GiftUser,
                                num = Convert.ToDecimal(e.Danmaku.GiftNum)
                            }
                            )));

                    }
                    logging("收到道具:" + e.Danmaku.GiftUser + " 赠送的: " + e.Danmaku.GiftName + " x " + e.Danmaku.GiftNum);
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        if (ShowItem.IsChecked == true)
                        {
                            AddDMText("收到道具",
                                e.Danmaku.GiftUser + " 赠送的: " + e.Danmaku.GiftName + " x " + e.Danmaku.GiftNum, true);
                        }
                    }));
                    break;
                }
                case MsgTypeEnum.Welcome:
                {
                        logging("欢迎老爷"+(e.Danmaku.isAdmin?"和管理":"")+": " + e.Danmaku.CommentUser + " 进入直播间");
                        this.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            if (ShowItem.IsChecked == true)
                            {
                                AddDMText("欢迎老爷" + (e.Danmaku.isAdmin ? "和管理" : ""),
                                    e.Danmaku.CommentUser + " 进入直播间", true);
                            }
                        }));
                        
                        break;
                    }



            }

        }