Example #1
0
        public MainPage()
        {
            this.InitializeComponent();
            hueSlider.Maximum        = (double)uint.MaxValue;
            saturationSlider.Maximum = (double)uint.MaxValue;
            brightnessSlider.Maximum = (double)uint.MaxValue;

            lampHelper                   = new LampHelper();
            lampHelper.LampFound        += LampHelper_LampFound;
            lampHelper.LampStateChanged += LampHelper_LampStateChanged;

            // Setting up timer for random colors
            dispatchTimer          = new DispatcherTimer();
            dispatchTimer.Interval = new TimeSpan(0, 0, 1);
            dispatchTimer.Tick    += setRandomHue;

            // Initialize face detection stuff
            InitializeCameraAsync(true);
        }
Example #2
0
        public static void ProcessVoiceCommand(VoiceCommandActivatedEventArgs eventArgs)
        {
            LampHelper lampHelper = new LampHelper();

            switch (eventArgs.Result.RulePath[0])
            {
            case "ToggleLamp":
                string switchableStateChange = eventArgs.Result.SemanticInterpretation.Properties["switchableStateChange"][0];
                if (string.Equals(switchableStateChange, "on", StringComparison.OrdinalIgnoreCase))
                {
                    onStateChangeRequested = true;
                }
                else
                {
                    onStateChangeRequested = false;
                }

                lampHelper.LampFound += LampHelper_LampFound;
                break;

            case "SwitchHue":
                //do things
                string color = eventArgs.Result.SemanticInterpretation.Properties["color"][0];
                lampHelper.LampFound += LampHelper_LampFound_color;
                switch (color)
                {
                case "red":
                    color_value = 110;
                    break;

                case "blue":
                    color_value = 2495806458;
                    break;
                }
                lampHelper.LampFound += LampHelper_LampFound_color;
                break;

            default:
                break;
            }
        }
Example #3
0
 private static async void LampHelper_LampFound_color(object sender, EventArgs e)
 {
     LampHelper lampHelper = sender as LampHelper;
     await lampHelper.SetHueAsync(color_value);
 }
Example #4
0
        private static void LampHelper_LampFound(object sender, EventArgs e)
        {
            LampHelper lampHelper = sender as LampHelper;

            lampHelper.SetOnOffAsync(onStateChangeRequested);
        }