예제 #1
0
        void AuthenticationCompleted(object sender, HealthVaultResponseEventArgs e)
        {
            SetProgressBarVisibility(false);

            if (e != null && e.ErrorText != null)
            {
                SetErrorMesasge(e.ErrorText);
                return;
            }

            if (App.HealthVaultService.CurrentRecord == null)
            {
                App.HealthVaultService.CurrentRecord = App.HealthVaultService.Records[0];
            }

            App.HealthVaultService.SaveSettings(App.SettingsFilename);
            if (App.HealthVaultService.CurrentRecord != null)
            {
                SetRecordName(App.HealthVaultService.CurrentRecord.RecordName);
                // We are only interested in the last item
                HealthVaultMethods.GetThings(EmotionalStateModel.TypeId, 1, null, null, GetThingsCompleted);
                SetProgressBarVisibility(true);
            }

            // Check to see if we should upload all the reading from Trial
            if (TrialModeStorageProvider.Instance.TrialStage == TrialState.UpgradeData)
            {
                if (TrialModeStorageProvider.Instance.TrialMode.emotionalStates.Count > 0)
                {
                    Dispatcher.BeginInvoke(() =>
                    {
                        MessageBoxResult result = MessageBox.Show(string.Format("You have {0} emotional state item(s).",
                                                                                TrialModeStorageProvider.Instance.TrialMode.emotionalStates.Count),
                                                                  "Upload local items to HealthVault", MessageBoxButton.OKCancel);
                        if (result == MessageBoxResult.Cancel)
                        {
                            CancelUpgrade();
                        }
                        if (result == MessageBoxResult.OK)
                        {
                            if (TrialModeStorageProvider.Instance.TrialMode.emotionalStates.Count > 0)
                            {
                                HealthVaultMethods.PutThings(TrialModeStorageProvider.Instance.TrialMode.emotionalStates,
                                                             PutThingsDoUpgradeCompleted);
                                SetProgressBarVisibility(true);
                            }
                        }
                    });
                }
                else
                {
                    EnjoyHealthVault();
                }
            }
        }
예제 #2
0
        // Save the reading to HealthVault
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            EmotionalStateModel model = new EmotionalStateModel();

            model.Mood      = (Mood)c_MoodSlider.Value;
            model.Stress    = (Stress)c_StressSlider.Value;
            model.Wellbeing = (Wellbeing)c_WellbeingSlider.Value;
            model.When      = DateTime.Now;
            HealthVaultMethods.PutThings(model, PutThingsCompleted);
            SetProgressBarVisibility(true);
        }
예제 #3
0
        // Save the readings to HealthVault
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            EmotionalStateModel model = new EmotionalStateModel();

            model.Mood      = (Mood)(moodSliderSelector.DataSource.SelectedItem as ValueData).ID;
            model.Stress    = (Stress)(stressSliderSelector.DataSource.SelectedItem as ValueData).ID;
            model.Wellbeing = (Wellbeing)(wellbeingSliderSelector.DataSource.SelectedItem as ValueData).ID;
            model.Note      = Txt_Note.Text;
            model.When      = DateTime.Now;
            if (!App.IsTrial)
            {
                HealthVaultMethods.PutThings(model, PutThingsCompleted);
                SetProgressBarVisibility(true);
            }
            else
            {
                SetProgressBarVisibility(true);
                TrialModeStorageProvider.Instance.TrialMode.emotionalStates.Add(model);
                TrialModeStorageProvider.Instance.Save();
                SetProgressBarVisibility(false);
                SetUserToast("Mood successfully saved on the device!");
            }
        }