Exemplo n.º 1
0
        private async void PedometerOnReadingChanged(object sender, BandSensorReadingEventArgs <IBandPedometerReading> e)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                gg.Value++;
                if (goal1)
                {
                    gg.Unit = gg.Value + "/" + numberGoal;
                }
                if (gg.Value > bestSteps)
                {
                    bestSteps = gg.Value;
                    IsolatedStorageHelper.SaveObject <double>("bestSteps", bestSteps);
                    if (!popupBest)
                    {
                        NewScore.Visibility = Visibility.Visible;
                        Storyboard2.Begin();
                        setText.Visibility  = Visibility.Collapsed;
                        setText2.Visibility = Visibility.Collapsed;
                        txtGoal.Visibility  = Visibility.Collapsed;
                        btnOk.Visibility    = Visibility.Collapsed;
                        AudioWinner.Play();
                        popupBest = true;
                    }
                }

                if (goal1 && gg.Value > numberGoal && !notification)
                {
                    var toastXmlContent = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

                    var txtNodes = toastXmlContent.GetElementsByTagName("text");
                    txtNodes[0].AppendChild(toastXmlContent.CreateTextNode("Congratulation"));
                    txtNodes[1].AppendChild(toastXmlContent.CreateTextNode("Goal achieved"));

                    var toast         = new ToastNotification(toastXmlContent);
                    var toastNotifier = ToastNotificationManager.CreateToastNotifier();
                    toastNotifier.Show(toast);
                    notification = true;
                }
            }).AsTask();
        }
        private void addPush(object sender, RoutedEventArgs e)
        {
            gg.Value++;
            if (goal1)
            {
                gg.Unit = gg.Value + "/" + numberGoal;
            }
            if (gg.Value > bestPush)
            {
                bestPush = gg.Value;
                IsolatedStorageHelper.SaveObject <double>("bestPush", bestPush);
                if (!popupBest)
                {
                    NewScore.Visibility = Visibility.Visible;
                    Storyboard2.Begin();
                    setGoal1.Visibility = Visibility.Collapsed;
                    setGoal2.Visibility = Visibility.Collapsed;
                    txtGoal.Visibility  = Visibility.Collapsed;
                    btnOk.Visibility    = Visibility.Collapsed;
                    AudioWinner.Play();
                    popupBest = true;
                }
            }


            if (goal1 && gg.Value > numberGoal && !notification)
            {
                var toastXmlContent = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

                var txtNodes = toastXmlContent.GetElementsByTagName("text");
                txtNodes[0].AppendChild(toastXmlContent.CreateTextNode("Congratulation"));
                txtNodes[1].AppendChild(toastXmlContent.CreateTextNode("Goal achieved"));

                var toast         = new ToastNotification(toastXmlContent);
                var toastNotifier = ToastNotificationManager.CreateToastNotifier();
                toastNotifier.Show(toast);
                notification = true;
            }
        }
        async void accelerometer_ReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args)
        {
            await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                if (args.Reading.AccelerationZ < -0.2 && step == false)
                {
                    step = true;
                    gg.Value++;
                    if (goal1)
                    {
                        gg.Unit = gg.Value + "/" + numberGoal;
                    }
                    if (gg.Value > bestSteps)
                    {
                        bestSteps = gg.Value;
                        IsolatedStorageHelper.SaveObject <double>("bestSteps", bestSteps);
                    }
                }
                if (args.Reading.AccelerationZ > 0.2 && step == true)
                {
                    step = false;
                    gg.Value++;
                    if (goal1)
                    {
                        gg.Unit = gg.Value + "/" + numberGoal;
                    }
                    if (gg.Value > bestSteps)
                    {
                        bestSteps = gg.Value;
                        IsolatedStorageHelper.SaveObject <double>("bestSteps", bestSteps);
                        if (!popupBest)
                        {
                            NewScore.Visibility = Visibility.Visible;
                            Storyboard2.Begin();
                            setText.Visibility  = Visibility.Collapsed;
                            setText2.Visibility = Visibility.Collapsed;
                            txtGoal.Visibility  = Visibility.Collapsed;
                            btnOk.Visibility    = Visibility.Collapsed;
                            AudioWinner.Play();
                            popupBest = true;
                        }
                    }
                }



                if (goal1 && gg.Value > numberGoal && !notification)
                {
                    var toastXmlContent = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

                    var txtNodes = toastXmlContent.GetElementsByTagName("text");
                    txtNodes[0].AppendChild(toastXmlContent.CreateTextNode("Congratulation"));
                    txtNodes[1].AppendChild(toastXmlContent.CreateTextNode("Goal achieved"));

                    var toast         = new ToastNotification(toastXmlContent);
                    var toastNotifier = ToastNotificationManager.CreateToastNotifier();
                    toastNotifier.Show(toast);
                    notification = true;
                }


                //  reading.Text = "X: " + args.Reading.AccelerationX.ToString() + "\nY: " + args.Reading.AccelerationY.ToString() + "\nZ: " + args.Reading.AccelerationZ.ToString();
            });
        }