Beispiel #1
0
        private void OnInputStateChanged(CommandStateChangedEventArgs e)
        {
            EventHandler <CommandStateChangedEventArgs> handler = CommandStateChanged;

            if (handler != null)
            {
                handler(this, e);
            }
        }
 private void OnInputStateChanged(CommandStateChangedEventArgs e)
 {
     EventHandler<CommandStateChangedEventArgs> handler = CommandStateChanged;
     if (handler != null) {
         handler(this, e);
     }
 }
Beispiel #3
0
        private void OnCommandStateChanged(object sender, CommandStateChangedEventArgs e)
        {
            switch (e.Command)
            {
            case Command.ActivateRecognition:
                if (!Settings.UsePushToTalk)
                {
                    if ((bool)e.State)
                    {
                        this.gablarski.Audio.MuteCapture();
                    }
                    else
                    {
                        this.gablarski.Audio.UnmuteCapture();
                    }
                }

                if (this.speech != null)
                {
                    if ((bool)e.State)
                    {
                        this.speech.StartRecognizing();
                    }
                    else
                    {
                        this.speech.StopRecognizing();
                    }
                }

                break;

            case Command.Talk:
                if (!Settings.UsePushToTalk || this.voiceSource == null || this.voiceCapture == null)
                {
                    return;
                }

                if ((bool)e.State)
                {
                    this.gablarski.Audio.BeginCapture(voiceSource, this.gablarski.CurrentChannel);
                }
                else
                {
                    this.gablarski.Audio.EndCapture(voiceSource);
                }

                break;

            case Command.SwitchChannel:
                IChannelInfo channel = e.State as IChannelInfo;
                if (channel == null)
                {
                    if (e.State is int)
                    {
                        channel = this.gablarski.Channels[(int)e.State];
                    }
                }

                if (channel == null)
                {
                    return;
                }

                this.gablarski.Users.Move(this.gablarski.CurrentUser, channel);

                break;

            case Command.MuteMic:
                if ((bool)e.State)
                {
                    BeginInvoke((Action)(() => this.btnMuteMic.Checked = !this.btnMuteMic.Checked));
                }

                break;

            case Command.MuteAll:
                if ((bool)e.State)
                {
                    BeginInvoke((Action)(() => this.btnMute.Checked = !this.btnMute.Checked));
                }

                break;

            case Command.SayCurrentSong:
                if (!(bool)e.State)
                {
                    return;
                }

                if (this.notifications != null && this.mediaPlayerIntegration != null)
                {
                    var attached = this.mediaPlayerIntegration.AttachedMediaPlayers;
                    if (attached.Count() == 0)
                    {
                        return;
                    }
                    else if (attached.Count() == 1)
                    {
                        this.notifications.Notify(NotificationType.Song, attached.First().SongName + " by " + attached.First().ArtistName);
                    }
                    else
                    {
                        foreach (var media in attached)
                        {
                            this.notifications.Notify(NotificationType.Song, String.Format("{0} is playing {1} by {2}", media.Name, media.SongName, media.ArtistName));
                        }
                    }
                }

                break;
            }
        }
Beispiel #4
0
 protected virtual void OnCommandStateChanged(object sender, CommandStateChangedEventArgs eventArgs)
 {
     StateChangedEventHandler?.Invoke(sender, eventArgs);
 }
Beispiel #5
0
 public void command_OnCommandStateChanged(object sender, CommandStateChangedEventArgs eventArgs)
 {
     Console.WriteLine();
     Console.WriteLine($"\"{this.Name}\" state changed!\n--Processed: {eventArgs.PreviousState.IsProcessed} -> {eventArgs.CurrentState.IsProcessed} \n--Rejected: {eventArgs.PreviousState.IsRejected} -> {eventArgs.CurrentState.IsRejected}");
 }