Esempio n. 1
0
        public GestureMachine(Config.UserConfig userConfig, IEnumerable <GestureDefinition> gestureDef)
        {
            this.Global            = new StateGlobal(userConfig);
            this.State             = new State0(Global, gestureDef);
            this.GestureDefinition = gestureDef;

            timer.Elapsed  += new ElapsedEventHandler(TryGestureTimeout);
            timer.Interval  = Global.Config.Gesture.Timeout;
            timer.AutoReset = false;
        }
Esempio n. 2
0
        public void grabConfig(Config cfg)
        {
            // 响应用户配置
            for (int i = 0; i < (int)UserConfigIndex.Count; ++i)
            {
                UserLevelConfigPage page    = userLevelConfigPages[i];
                Config.UserConfig   userCfg = cfg.userConfigs[i];

                userCfg.readWelcome     = page.pairWelcome.checkBoxRead.Checked;
                userCfg.templateWelcome = page.pairWelcome.textBoxTemplate.Text;

                userCfg.readText     = page.pairText.checkBoxRead.Checked;
                userCfg.templateText = page.pairText.textBoxTemplate.Text;

                userCfg.readGift     = page.pairGift.checkBoxRead.Checked;
                userCfg.templateGift = page.pairGift.textBoxTemplate.Text;

                userCfg.readTicket     = page.pairTicket.checkBoxRead.Checked;
                userCfg.templateTicket = page.pairTicket.textBoxTemplate.Text;
            }

            // 其它

            cfg.readConnect     = checkBoxReadConnect.Checked;
            cfg.templateConnect = textBoxConnectTemplate.Text;

            cfg.readDisconnect     = checkBoxReadDisconnect.Checked;
            cfg.templateDisconnect = textBoxDisconnectTemplate.Text;

            cfg.readLiveBegin     = checkBoxReadLiveBegin.Checked;
            cfg.templateLiveBegin = textBoxLiveBeginTemplate.Text;

            cfg.readLiveEnd     = checkBoxReadLiveEnd.Checked;
            cfg.templateLiveEnd = textBoxLiveEndTemplate.Text;

            // 音频配置

            // 音频设备列表
            cfg.audioDeviceId = AudioService.allDevices[comboAudioDevices.SelectedIndex];

            // 音量
            cfg.volume = trackBarVolume.Value;
            // 语速
            cfg.speed = (Config.Speed)trackBarSpeed.Value;

            // 声音类型
            cfg.voiceType = (Config.VoiceType)comboBoxVoiceTypes.SelectedIndex;

            // 高级

            cfg.useCustomSecret = checkBoxUseCustomeSecret.Checked;
            cfg.secretId        = textBoxSecretId.Text;
            cfg.secretKey       = textBoxSecretKey.Text;
        }
Esempio n. 3
0
 public StateGlobal(Config.UserConfig userConfig)
 {
     this.StrokeWatcherScheduler   = new Threading.SingleThreadScheduler(ThreadPriority.AboveNormal);
     this.LowPriorityScheduler     = new Threading.SingleThreadScheduler(ThreadPriority.Lowest);
     this.UserActionScheduler      = new Threading.SingleThreadScheduler();
     this.StrokeWatcherTaskFactory = new TaskFactory(StrokeWatcherScheduler);
     this.LowPriorityTaskFactory   = new TaskFactory(LowPriorityScheduler);
     this.UserActionTaskFactory    = new TaskFactory(UserActionScheduler);
     this.Config        = userConfig;
     this.StrokeWatcher = NewStrokeWatcher();
 }
Esempio n. 4
0
        // 显示配置
        public void displayConfig(Config cfg)
        {
            // 响应用户配置
            for (int i = 0; i < (int)UserConfigIndex.Count; ++i)
            {
                UserLevelConfigPage page    = userLevelConfigPages[i];
                Config.UserConfig   userCfg = cfg.userConfigs[i];

                page.pairWelcome.checkBoxRead.Checked    = userCfg.readWelcome;
                page.pairWelcome.textBoxTemplate.Text    = userCfg.templateWelcome;
                page.pairWelcome.textBoxTemplate.Enabled = userCfg.readWelcome;

                page.pairText.checkBoxRead.Checked    = userCfg.readText;
                page.pairText.textBoxTemplate.Text    = userCfg.templateText;
                page.pairText.textBoxTemplate.Enabled = userCfg.readText;

                page.pairGift.checkBoxRead.Checked    = userCfg.readGift;
                page.pairGift.textBoxTemplate.Text    = userCfg.templateGift;
                page.pairGift.textBoxTemplate.Enabled = userCfg.readGift;

                page.pairTicket.checkBoxRead.Checked    = userCfg.readTicket;
                page.pairTicket.textBoxTemplate.Text    = userCfg.templateTicket;
                page.pairTicket.textBoxTemplate.Enabled = userCfg.readTicket;
            }

            // 其它

            checkBoxReadConnect.Checked = cfg.readConnect;
            textBoxConnectTemplate.Text = cfg.templateConnect;

            checkBoxReadDisconnect.Checked = cfg.readDisconnect;
            textBoxDisconnectTemplate.Text = cfg.templateDisconnect;

            checkBoxReadLiveBegin.Checked = cfg.readLiveBegin;
            textBoxLiveBeginTemplate.Text = cfg.templateLiveBegin;

            checkBoxReadLiveEnd.Checked = cfg.readLiveEnd;
            textBoxLiveEndTemplate.Text = cfg.templateLiveEnd;

            // 音频配置

            // 音频设备列表
            comboAudioDevices.Items.Clear();
            int selectedIndex = -1;

            for (int i = 0; i < AudioService.allDevices.Length; ++i)
            {
                var audioDeviceId = AudioService.allDevices[i];
                comboAudioDevices.Items.Add(audioDeviceId);
                if (audioDeviceId == cfg.audioDeviceId)
                {
                    selectedIndex = i;
                }
            }
            if (selectedIndex == -1)
            {
                selectedIndex = 0;
            }
            comboAudioDevices.SelectedIndex = selectedIndex;

            // 音量
            trackBarVolume.Value = cfg.volume;
            // 语速
            trackBarSpeed.Value = (int)cfg.speed;

            // 声音类型
            comboBoxVoiceTypes.Items.Clear();
            for (int i = 0; i < (int)Config.VoiceType.Count; ++i)
            {
                string voiceTypeName = Config.VoiceTypeNames[i];
                comboBoxVoiceTypes.Items.Add(voiceTypeName);
            }
            comboBoxVoiceTypes.SelectedIndex = (int)cfg.voiceType;

            // 高级

            checkBoxUseCustomeSecret.Checked = cfg.useCustomSecret;
            textBoxSecretId.Text             = cfg.secretId;
            textBoxSecretKey.Text            = cfg.secretKey;
            textBoxSecretId.Enabled          = textBoxSecretKey.Enabled = cfg.useCustomSecret;
        }
Esempio n. 5
0
        // 收到弹幕、礼物等消息
        private void BSVPlugin_ReceivedDanmaku(object sender, BilibiliDM_PluginFramework.ReceivedDanmakuArgs e)
        {
            DanmakuModel dm     = e.Danmaku;
            int          userId = dm.UserID;

            switch (dm.MsgType)
            {
            case MsgTypeEnum.LiveStart:                      // 直播开始
                if (config.readLiveBegin)
                {
                    string str = makeStringFromTemplate(dm, config.templateLiveBegin);
                    addTTSTask(str);
                }
                break;

            case MsgTypeEnum.LiveEnd:                      // 直播结束
                if (config.readLiveEnd)
                {
                    string str = makeStringFromTemplate(dm, config.templateLiveEnd);
                    addTTSTask(str);
                }
                break;

            case MsgTypeEnum.Welcome:                      // 有观众进入直播间
            {
                UserService.UserInfo userInfo = UserService.getOrCreateUserInfo(userId);
                userInfo.isMilord = dm.isVIP;

                int userCfgIndex          = (int)getUserConfigIndex(userInfo);
                Config.UserConfig userCfg = config.userConfigs[userCfgIndex];
                if (userCfg.readWelcome)
                {
                    string str = makeStringFromTemplate(dm, userCfg.templateWelcome);
                    addTTSTask(str);
                }
            }
            break;

            case MsgTypeEnum.WelcomeGuard:                      // 有普通观众或船员进入直播间
            {
                UserService.UserInfo userInfo = UserService.getOrCreateUserInfo(userId);
                userInfo.level = (UserLevel)dm.UserGuardLevel;

                int userCfgIndex          = (int)getUserConfigIndex(userInfo);
                Config.UserConfig userCfg = config.userConfigs[userCfgIndex];
                if (userCfg.readWelcome)
                {
                    string str = makeStringFromTemplate(dm, userCfg.templateWelcome);
                    addTTSTask(str);
                }
            }
            break;

            case MsgTypeEnum.Comment:                      // 弹幕文本
            {
                int userCfgIndex = dm.UserGuardLevel;
                if (userCfgIndex == (int)UserLevel.Common)
                {
                    UserService.UserInfo userInfo = UserService.getUserInfo(userId);
                    userCfgIndex = (int)getUserConfigIndex(userInfo);
                }

                Config.UserConfig userCfg = config.userConfigs[userCfgIndex];
                if (userCfg.readText)
                {
                    string str = makeStringFromTemplate(dm, userCfg.templateText);
                    addTTSTask(str);
                }
            }
            break;

            case MsgTypeEnum.GiftSend:                      // 收到礼物
            {
                UserService.UserInfo userInfo = UserService.getUserInfo(userId);
                int userCfgIndex          = (int)getUserConfigIndex(userInfo);
                Config.UserConfig userCfg = config.userConfigs[userCfgIndex];
                if (userCfg.readGift)
                {
                    string str = makeStringFromTemplate(dm, userCfg.templateGift);
                    addTTSTask(str);
                }
            }
            break;

            case MsgTypeEnum.GuardBuy:                      // 购买船票
            {
                int userCfgIndex = dm.UserGuardLevel;
                if (userCfgIndex == (int)UserLevel.Common)
                {
                    UserService.UserInfo userInfo = UserService.getUserInfo(userId);
                    userCfgIndex = (int)getUserConfigIndex(userInfo);
                }

                Config.UserConfig userCfg = config.userConfigs[userCfgIndex];
                if (userCfg.readTicket)
                {
                    string str = makeStringFromTemplate(dm, userCfg.templateTicket);
                    addTTSTask(str);
                }
            }
            break;
            }
        }