public static LightsControll GetLightControll() { if (controll == null) { controll = new LightsControll(); } return(controll); }
protected override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); if (args.Kind != Windows.ApplicationModel.Activation.ActivationKind.VoiceCommand) { return; } var commandArgs = args as Windows.ApplicationModel.Activation.VoiceCommandActivatedEventArgs; Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = commandArgs.Result; // Get the name of the voice command and the text spoken string voiceCommandName = speechRecognitionResult.RulePath[0]; switch (voiceCommandName) { case "toggleLight": // Access the value of the {lightColor} and {action} phrase in the voice command string lightColor = speechRecognitionResult.SemanticInterpretation.Properties["lightColor"][0]; string action = speechRecognitionResult.SemanticInterpretation.Properties["action"][0]; //i use this to pass the data from here to the MainPage LightsControll.SetLightControll(lightColor, action); break; default: break; } Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage)); } // Ensure the current window is active Window.Current.Activate(); }
public static LightsControll SetLightControll(string bulb, string action) { controll = new LightsControll(bulb, action); return(controll); }
private void TurnOnLight() { LightsControll controll = LightsControll.GetLightControll(); arduino.digitalWrite(controll.Pin, controll.State); }