示例#1
0
 private void FadeOn_Click(object sender, RoutedEventArgs e)
 {
     if (Setting.Instance.FadeOn == false)
     {
         Setting.Instance.fadeTime = Convert.ToInt32(FadeTime.Text);
         Setting.Instance.FadeOn   = true;
         Ledstrip.Fade();
     }
     else
     {
         Setting.Instance.FadeOn = false;
     }
 }
示例#2
0
 private void FlashOn_Click(object sender, RoutedEventArgs e)
 {
     if (Setting.Instance.FlashOn == false)
     {
         Setting.Instance.flashColor = FlashColor.Text;
         Setting.Instance.flashTime  = Convert.ToInt32(FlashTime.Text);
         Setting.Instance.FlashOn    = true;
         Ledstrip.Flash();
     }
     else
     {
         Setting.Instance.FlashOn = false;
     }
 }
示例#3
0
        protected override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);
            if (e.Kind != ActivationKind.VoiceCommand)
            {
                return;
            }

            var commandArgs             = e as Windows.ApplicationModel.Activation.VoiceCommandActivatedEventArgs;
            var speechRecognitionResult = commandArgs.Result;
            var command = speechRecognitionResult.Text;


            // Get the name of the voice command and the text spoken.
            string voiceCommandName = speechRecognitionResult.RulePath[0];

            switch (voiceCommandName)
            {
            case "desk":
                Board.Instance.AllOff();
                Board.instance.ChangePinState(Setting.Instance.OfficeLightpin, 1);
                Setting.Instance.OfficeLightOn = true;
                Board.instance.ChangePinState(Setting.Instance.Officepin, 1);
                Setting.Instance.OfficeOn = true;
                break;

            case "officelighton":
                Board.instance.ChangePinState(Setting.Instance.OfficeLightpin, 1);
                Setting.Instance.OfficeLightOn = true;
                break;

            case "officelightoff":
                Board.instance.ChangePinState(Setting.Instance.OfficeLightpin, 0);
                Setting.Instance.OfficeLightOn = false;
                break;

            case "mainlighton":
                Board.instance.ChangePinState(Setting.Instance.MainLightpin, 0);
                Setting.Instance.MainLightOn = true;
                break;

            case "mainlightoff":
                Board.instance.ChangePinState(Setting.Instance.MainLightpin, 1);
                Setting.Instance.MainLightOn = false;
                break;

            case "readinglighton":
                Board.instance.ChangePinState(Setting.Instance.ReadingLightpin, 0);
                Setting.Instance.ReadingLightOn = true;
                break;

            case "readinglightoff":
                Board.instance.ChangePinState(Setting.Instance.ReadingLightpin, 1);
                Setting.Instance.ReadingLightOn = false;
                break;

            case "officedeviceson":
                Board.instance.ChangePinState(Setting.Instance.Officepin, 1);
                Setting.Instance.OfficeOn = true;
                break;

            case "officedevicesoff":
                Board.instance.ChangePinState(Setting.Instance.Officepin, 0);
                Setting.Instance.OfficeOn = false;
                break;

            case "TVOn":
                Board.instance.ChangePinState(Setting.Instance.TVpin, 0);
                Setting.Instance.TVOn = true;
                break;

            case "TVOff":
                Board.instance.ChangePinState(Setting.Instance.TVpin, 1);
                Setting.Instance.TVOn = false;
                break;

            case "ledstripon":
                Setting.Instance.FadeOn    = false;
                Setting.Instance.FadeOneOn = false;
                Setting.Instance.FlashOn   = false;
                Board.instance.WriteSmoothColor(255, 255, 255);
                Setting.Instance.LedColor = "White";
                break;

            case "ledstriponblue":
                Setting.Instance.FadeOn    = false;
                Setting.Instance.FadeOneOn = false;
                Setting.Instance.FlashOn   = false;
                Board.instance.WriteSmoothColor(0, 0, 255);
                Setting.Instance.LedColor = "Blue";
                break;

            case "ledstriponred":
                Setting.Instance.FadeOn    = false;
                Setting.Instance.FadeOneOn = false;
                Setting.Instance.FlashOn   = false;
                Board.instance.WriteSmoothColor(255, 0, 0);
                Setting.Instance.LedColor = "Red";
                break;

            case "ledstripongreen":
                Setting.Instance.FadeOn    = false;
                Setting.Instance.FadeOneOn = false;
                Setting.Instance.FlashOn   = false;
                Board.instance.WriteSmoothColor(0, 255, 0);
                Setting.Instance.LedColor = "Green";
                break;

            case "ledstriponyellow":
                Setting.Instance.FadeOn    = false;
                Setting.Instance.FadeOneOn = false;
                Setting.Instance.FlashOn   = false;
                Board.instance.WriteSmoothColor(255, 0, 255);
                Setting.Instance.LedColor = "Yellow";
                break;

            case "ledstriponcyan":
                Setting.Instance.FadeOn    = false;
                Setting.Instance.FadeOneOn = false;
                Setting.Instance.FlashOn   = false;
                Board.instance.WriteSmoothColor(0, 255, 255);
                Setting.Instance.LedColor = "Cyan";
                break;

            case "ledstriponpurple":
                Setting.Instance.FadeOn    = false;
                Setting.Instance.FadeOneOn = false;
                Setting.Instance.FlashOn   = false;
                Board.instance.WriteSmoothColor(128, 0, 128);
                Setting.Instance.LedColor = "Purple";
                break;

            case "ledstriponwhite":
                Setting.Instance.FadeOn    = false;
                Setting.Instance.FadeOneOn = false;
                Setting.Instance.FlashOn   = false;
                Board.instance.WriteSmoothColor(255, 255, 255);
                Setting.Instance.LedColor = "White";
                break;

            case "ledstripoff":
                Setting.Instance.FadeOn    = false;
                Setting.Instance.FadeOneOn = false;
                Setting.Instance.FlashOn   = false;
                Board.instance.WriteSmoothColor(0, 0, 0);
                Setting.Instance.LedColor = "blank";
                break;

            case "alloff":
                Board.instance.AllOff();
                break;

            case "allon":
                Board.instance.AllOn();
                break;

            case "Fade":
                Setting.Instance.FadeOn = true;
                Ledstrip.Fade();
                break;

            case "Flash":
                Setting.Instance.FlashOn = true;
                Ledstrip.Flash();
                break;

            case "FadeOne":
                Setting.Instance.FadeOneOn = true;
                Ledstrip.FadeOne();
                break;

            case "Sleep":
                Board.Instance.AllOff();
                break;

            case "Game":
                Setting.Instance.OfficeLightOn = true;
                Board.instance.ChangePinState(Setting.Instance.OfficeLightpin, 1);
                Setting.Instance.OfficeOn = true;
                Board.instance.ChangePinState(Setting.Instance.Officepin, 1);


                /*
                 * Board.Instance.AllOff();
                 * Setting.Instance.FadeOneOn = true;
                 * Setting.Instance.fadeOneColor = "Red";
                 * Ledstrip.FadeOne();
                 * Board.Instance.ChangePinState(Setting.Instance.TVpin, 0);
                 */
                break;

            case "Leaving":
                Board.Instance.AllOff();
                break;

            case "AlarmOn":
                Setting.Instance.AlarmOn = true;
                break;

            case "AlarmOff":
                Setting.Instance.AlarmOn = false;
                break;

            case "morning":

                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)
            {
                //use the "command" which was spoken by the user.
                // i am just checking weather the Activation is by Voice command or not and  navigating.
                if (e.Kind != Windows.ApplicationModel.Activation.ActivationKind.VoiceCommand)
                {
                    rootFrame.Navigate(typeof(MainPage), e.Kind);
                }
                else
                {
                    rootFrame.Navigate(typeof(MainPage), e.Kind);
                }

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }