Provides data for the IInputProvider.CommandStateChanged event.
Inheritance: System.EventArgs
Esempio n. 1
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;
			}
		}
Esempio n. 2
0
 private void OnCommandStateChanged(CommandStateChangedEventArgs e)
 {
     EventHandler<CommandStateChangedEventArgs> handler = this.CommandStateChanged;
     if (handler != null)
         handler (this, e);
 }