Skip to content

Instantly share code, notes, and snippets.

@robinmanuelthiel
Created December 2, 2015 10:44
Show Gist options
  • Save robinmanuelthiel/dd5de2215e98b634d250 to your computer and use it in GitHub Desktop.
Save robinmanuelthiel/dd5de2215e98b634d250 to your computer and use it in GitHub Desktop.
protected override void OnActivated(IActivatedEventArgs args)
{
base.OnActivated(args);
string infos = string.Empty;
// Get voice data
if (args.Kind == ActivationKind.VoiceCommand)
{
var commandArgs = args as VoiceCommandActivatedEventArgs;
var speechRecognitionResult = commandArgs.Result;
var commandName = speechRecognitionResult.RulePath[0];
switch (commandName)
{
case "switchLightOn":
var room = speechRecognitionResult.SemanticInterpretation.Properties["room"][0];
var status = speechRecognitionResult.SemanticInterpretation.Properties["status"][0];
infos = room + "|" + status;
break;
}
}
// Prepare frame
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
Window.Current.Content = rootFrame;
RestoreSavedSettings();
}
// Navigate and pass information
rootFrame.Navigate(typeof(MainPage), infos);
Window.Current.Activate();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment