Exemplo n.º 1
0
        public SuperChat(BiliLiveJsonParser.SuperChat superChat)
        {
            InitializeComponent();

            SenderBox.Text  = superChat.User.Name;
            PriceBox.Text   = superChat.Price.ToString();
            MessageBox.Text = superChat.Message;

            if (superChat.TransMark)
            {
                MessageTransBox.Text = superChat.MessageTrans;
            }
            else
            {
                MessageTransBorder.Visibility = Visibility.Collapsed;
            }

            InfoGrid.Background          = new SolidColorBrush(superChat.PriceColor);
            MessageStackPanel.Background = new SolidColorBrush(superChat.BottomColor);

            UserId = superChat.User.Id;

            FaceImage.Source = null;
            //FaceImage.Source = FaceLoader.LoadFace(superChat.User.Id, superChat.Face);
            FaceLoader.LoadFaceWithKnownUri(this, superChat.Face);
        }
 private void SpeakSuperChat(BiliLiveJsonParser.SuperChat item)
 {
     if (speechProcessor.IsAvalable)
     {
         string ssmlDoc = SsmlHelper.SuperChat(item.User.Name, item.Message);
         speechProcessor.Speak(ssmlDoc);
     }
 }
        public void AppendSuperChat(BiliLiveJsonParser.SuperChat item)
        {
            Dispatcher.Invoke(() =>
            {
                DanmakuPanel.Children.Add(new SuperChat(item));
                if (!DanmakuScrollViewer.IsMouseOver)
                {
                    DanmakuScrollViewer.ScrollToBottom();
                }
                CleanDanmakuTime = DateTime.UtcNow.AddSeconds(0.2);
            });

            if (CleanDanmakuTask == null || CleanDanmakuTask.IsCompleted)
            {
                CleanDanmakuTask = Task.Factory.StartNew(CleanPanel);
            }
        }
        public void ProcessItem(BiliLiveJsonParser.IItem item)
        {
            switch (item.Cmd)
            {
            case BiliLiveJsonParser.Cmds.DANMU_MSG:
                BiliLiveJsonParser.Danmaku danmaku = (BiliLiveJsonParser.Danmaku)item;
                if (danmaku.Type == 0)
                {
                    if (OptionDict[DanmakuSpeechConfig.SpeechFilterOptions.DanmakuSpeech])
                    {
                        SpeakDanmaku(danmaku);
                    }
                }
                break;

            case BiliLiveJsonParser.Cmds.SUPER_CHAT_MESSAGE:
                BiliLiveJsonParser.SuperChat superChat = (BiliLiveJsonParser.SuperChat)item;
                if (OptionDict[DanmakuSpeechConfig.SpeechFilterOptions.SuperChatSpeech])
                {
                    SpeakSuperChat(superChat);
                }
                break;

            case BiliLiveJsonParser.Cmds.SEND_GIFT:
                BiliLiveJsonParser.Gift gift = (BiliLiveJsonParser.Gift)item;
                if (!giftCacheManager.AppendToExist(gift))
                {
                    giftCacheManager.AppendCache(gift);
                }
                break;

            case BiliLiveJsonParser.Cmds.COMBO_SEND:
                BiliLiveJsonParser.ComboSend comboSend = (BiliLiveJsonParser.ComboSend)item;
                if (OptionDict[DanmakuSpeechConfig.SpeechFilterOptions.ComboSendSpeech])
                {
                    SpeakComboSend(comboSend);
                }
                break;
            }
        }
Exemplo n.º 5
0
        public void ProcessItem(BiliLiveJsonParser.IItem item)
        {
            if (Window == null)
            {
                return;
            }

            switch (item.Cmd)
            {
            case BiliLiveJsonParser.Cmds.DANMU_MSG:
                BiliLiveJsonParser.Danmaku danmaku = (BiliLiveJsonParser.Danmaku)item;
                if (danmaku.Type == 0)
                {
                    if (OptionDict[DanmakuShowConfig.DisplayFilterOptions.Danmaku])
                    {
                        Window.AppendDanmaku(danmaku);
                    }
                }
                else
                if (OptionDict[DanmakuShowConfig.DisplayFilterOptions.RythmStorm])
                {
                    Window.AppendRythmStorm(danmaku);
                }
                break;

            case BiliLiveJsonParser.Cmds.SUPER_CHAT_MESSAGE:
                BiliLiveJsonParser.SuperChat superChat = (BiliLiveJsonParser.SuperChat)item;
                if (OptionDict[DanmakuShowConfig.DisplayFilterOptions.SuperChat])
                {
                    Window.AppendSuperChat(superChat);
                }
                break;

            case BiliLiveJsonParser.Cmds.SEND_GIFT:
                BiliLiveJsonParser.Gift gift = (BiliLiveJsonParser.Gift)item;
                if (!giftCacheManager.AppendToExist(gift))
                {
                    GiftCacheManager.GiftCache giftCache = giftCacheManager.AppendCache(gift);
                    if (gift.CoinType == "gold" && OptionDict[DanmakuShowConfig.DisplayFilterOptions.GoldenGift])
                    {
                        Window.AppendGift(giftCache);
                    }
                    else if (gift.CoinType == "silver" && OptionDict[DanmakuShowConfig.DisplayFilterOptions.SilverGift])
                    {
                        Window.AppendGift(giftCache);
                    }
                }
                break;

            case BiliLiveJsonParser.Cmds.COMBO_SEND:
                BiliLiveJsonParser.ComboSend comboSend = (BiliLiveJsonParser.ComboSend)item;
                if (OptionDict[DanmakuShowConfig.DisplayFilterOptions.ComboSend])
                {
                    Window.AppendComboSend(comboSend);
                }
                break;

            case BiliLiveJsonParser.Cmds.WELCOME:
                BiliLiveJsonParser.Welcome welcome = (BiliLiveJsonParser.Welcome)item;
                if (OptionDict[DanmakuShowConfig.DisplayFilterOptions.Welcome])
                {
                    Window.AppendWelcome(welcome);
                }
                break;

            case BiliLiveJsonParser.Cmds.WELCOME_GUARD:
                BiliLiveJsonParser.WelcomeGuard welcomeGuard = (BiliLiveJsonParser.WelcomeGuard)item;
                if (OptionDict[DanmakuShowConfig.DisplayFilterOptions.WelcomeGuard])
                {
                    Window.AppendWelcomeGuard(welcomeGuard);
                }
                break;

            case BiliLiveJsonParser.Cmds.GUARD_BUY:
                BiliLiveJsonParser.GuardBuy guardBuy = (BiliLiveJsonParser.GuardBuy)item;
                if (OptionDict[DanmakuShowConfig.DisplayFilterOptions.GuardBuy])
                {
                    Window.AppendGuardBuy(guardBuy);
                }
                break;

            case BiliLiveJsonParser.Cmds.INTERACT_WORD:
                BiliLiveJsonParser.InteractWord interactWord = (BiliLiveJsonParser.InteractWord)item;
                if (interactWord.MessageType == BiliLiveJsonParser.InteractWord.MessageTypes.Entry && OptionDict[DanmakuShowConfig.DisplayFilterOptions.InteractEntry])
                {
                    Window.AppendInteractWord(interactWord);
                }
                else if (interactWord.MessageType == BiliLiveJsonParser.InteractWord.MessageTypes.Attention && OptionDict[DanmakuShowConfig.DisplayFilterOptions.InteractAttention])
                {
                    Window.AppendInteractWord(interactWord);
                }
                else if (interactWord.MessageType == BiliLiveJsonParser.InteractWord.MessageTypes.Share && OptionDict[DanmakuShowConfig.DisplayFilterOptions.InteractShare])
                {
                    Window.AppendInteractWord(interactWord);
                }
                else if (interactWord.MessageType == BiliLiveJsonParser.InteractWord.MessageTypes.SpecialAttention && OptionDict[DanmakuShowConfig.DisplayFilterOptions.InteractSpecialAttention])
                {
                    Window.AppendInteractWord(interactWord);
                }
                else if (interactWord.MessageType == BiliLiveJsonParser.InteractWord.MessageTypes.MutualAttention && OptionDict[DanmakuShowConfig.DisplayFilterOptions.InteractMutualAttention])
                {
                    Window.AppendInteractWord(interactWord);
                }
                break;

            case BiliLiveJsonParser.Cmds.ROOM_BLOCK_MSG:
                BiliLiveJsonParser.RoomBlock roomBlock = (BiliLiveJsonParser.RoomBlock)item;
                if (OptionDict[DanmakuShowConfig.DisplayFilterOptions.RoomBlock])
                {
                    Window.AppendRoomBlock(roomBlock);
                }
                break;
            }
        }