Esempio n. 1
0
        private void Service_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("InvalidRequest"))
            {
                rootPage.NotifyUser("Invalid request!", NotifyType.ErrorMessage);
            }

            //new characteristic value received
            if (e.PropertyName.Equals("Value"))
            {
                byte[] newColor = rootPage.Ble.lightBulbService.LightBulbColor.argb;
                rootPage.NotifyUser($"New color received: {newColor[0]} {newColor[1]} {newColor[2]} {newColor[3]}", NotifyType.StatusMessage);

                //initial check already in the characteristic, assuming [A R G B] here
                lightBulbBrush.Color = Windows.UI.Color.FromArgb(newColor[0], newColor[1], newColor[2], newColor[3]);
                LightBulb.ARGB(lightBulbBrush);

                //check if half dim red (FF0000) received
                if ((newColor[0] > 110) && (newColor[0] < 150) && (newColor[1] == 255) && (newColor[1] == 255) && (newColor[2] == 0) && (newColor[3] == 0))
                {
                    rootPage.NotifyCorrect(scenarioName);
                    Solved.Visibility = Visibility.Visible;
                }
            }
        }
Esempio n. 2
0
        private void Service_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("InvalidRequest"))
            {
                rootPage.NotifyUser("Invalid request!", NotifyType.ErrorMessage);
            }

            else if (e.PropertyName.Equals("InvalidPin"))
            {
                rootPage.NotifyUser("Invalid password, access denied!", NotifyType.ErrorMessage);
            }

            // process ARGB Value
            if (e.PropertyName.Equals("Value"))
            {
                byte[] newColor = rootPage.Ble.lightBulbService.LightBulbColor.argb;
                rootPage.NotifyUser($"New color received: {newColor[0]} {newColor[1]} {newColor[2]} {newColor[3]}", NotifyType.StatusMessage);

                //initial check already in the characteristic, assuming [A R G B] here
                lightBulbBrush.Color = Windows.UI.Color.FromArgb(newColor[0], newColor[1], newColor[2], newColor[3]);
                LightBulb.ARGB(lightBulbBrush);
            }

            // password protected special scenario received
            else if (e.PropertyName.Equals("SpecialValue"))
            {
                byte specialEffects = rootPage.Ble.lightBulbService.LightBulbColor.specialEffectsScenario;
                rootPage.NotifyUser($"Correct PIN, new special effects scenario received: {specialEffects}", NotifyType.StatusMessage);

                //initial check already in the characteristic, assuming [A R G B] here
                if (specialEffects == 0x01)
                {
                    //Green
                    lightBulbBrush.Color = Windows.UI.Color.FromArgb(0xFF, 0x00, 0xFF, 0x00);
                    LightBulb.ARGB(lightBulbBrush);

                    //TextToSpeech.AutoPlay = true;
                    VoiceCongrats.SetSource(speechStream, speechStream.ContentType);
                    VoiceCongrats.Play();
                    // play Rick after the voice congrats finishes
                    VoiceCongrats.MediaEnded += RickRoll;

                    rootPage.NotifyCorrect(scenarioName);
                    Solved.Visibility       = Visibility.Visible;
                    ShowValidPin.Visibility = Visibility.Visible;
                    LightBulb.Checked(true);
                }
                else
                {
                    LightBulb.Off();
                    LightBulb.Checked(false);
                    Rick.Stop();
                    Rick.Visibility = Visibility.Collapsed;
                    colorTicker.Stop();
                }
            }
        }
Esempio n. 3
0
        private void UpdateColor(object sender, object e)
        {
            if (effectCount == 0)
            {
                UpdateSpringAnimation(1.2f);
                StartAnimationIfAPIPresent(LightBulb, _springAnimation);
                effectCount++;

                var red   = (byte)rnd.Next(0, 255);
                var green = (byte)rnd.Next(0, 255);
                var blue  = (byte)rnd.Next(0, 255);

                lightBulbBrush.Color = Windows.UI.Color.FromArgb(255, red, green, blue);
                LightBulb.ARGB(lightBulbBrush);
            }
            else
            {
                UpdateSpringAnimation(1f);
                StartAnimationIfAPIPresent(LightBulb, _springAnimation);
                effectCount--;
            }
        }