コード例 #1
0
        async void Save_Clicked(object sender, System.EventArgs e)
        {
            /*
             * var medsItem = (Meds)BindingContext;
             * await App.Database.SaveMedsAsync(medsItem);
             * await Navigation.PopAsync();*/
            meds.Wake      = WakeToggle.IsToggled;
            meds.Breakfast = BreakfastToggle.IsToggled;
            meds.Lunch     = LunchToggle.IsToggled;
            meds.Dinner    = DinnerToggle.IsToggled;
            meds.Sleep     = SleepToggle.IsToggled;

            meds.Name   = medname.Text;
            meds.Dosage = meddose.Text;
            //System.Diagnostics.Debug.WriteLine("New WakeTime is:" + alarm.WakeTime);

            //Save meds to Database
            await App.Database.SaveMedsAsync(meds);

            //Save and Set Notifications
            DependencyService.Get <IMedNotification>().SaveAlarm();

            //Delete all future doses
            try
            {
                Adhere toDelete = new Adhere();
                int    x        = 1;
                while (x != 0)
                {
                    toDelete = await App.AdhereDB.GetFutureAdhereAsync();

                    if (toDelete != null)
                    {
                        await App.AdhereDB.DeleteAdhereAsync(toDelete);
                    }
                    else
                    {
                        x = 0;
                    }
                }
            }
            catch
            {
                System.Diagnostics.Debug.WriteLine("Could not delete future doses");
            }

            //Start checking for bluetooth connection. Should be connected to start. Upon disconnect, will mark dose as taken.
            //BluetoothManager.Instance.CheckBluetoothConnection();
            await DisplayAlert("Success", "Medication has been saved", "OK");

            await Navigation.PopAsync();
        }
コード例 #2
0
 public Task <int> SaveAdhereAsync(Adhere item)
 {
     if (item.DoseId != 0)
     {
         System.Diagnostics.Debug.WriteLine(item);
         return(adherencedatabase.UpdateAsync(item));
     }
     else
     {
         System.Diagnostics.Debug.WriteLine(item);
         return(adherencedatabase.InsertAsync(item));
     }
 }
コード例 #3
0
        //Automatically connect to bluetooth if connection lost
        public async void OnConnectionLost(IDevice lostDevice)
        {
            //Set Dose Taken to 1
            Adhere thisDose = new Adhere();

            thisDose = await App.AdhereDB.GetRecentAdhereAsync();

            thisDose.DoseTaken = true;
            await App.AdhereDB.SaveAdhereAsync(thisDose);

            System.Diagnostics.Debug.WriteLine("Dose taken");
            AttemptReconnect(lostDevice.Id, cancellationToken);
        }
コード例 #4
0
 public Task <int> DeleteAdhereAsync(Adhere item)
 {
     return(adherencedatabase.DeleteAsync(item));
 }
コード例 #5
0
        protected override async void OnAppearing()
        {
            NavigationPage.SetHasNavigationBar(this, false);

            /*
             * if (BluetoothManager.Instance.BLEDevice == null)
             * {
             *  await Navigation.PushAsync(new DeviceListPage());
             * }*/


            thisDose = await App.AdhereDB.GetRecentAdhereAsync();

            if (thisDose.DoseTaken == false)
            {
                int doseBins = thisDose.DoseBins;
                System.Diagnostics.Debug.WriteLine("doseBins = " + doseBins);

                if (doseBins == 1)
                {
                    BluetoothManager.Instance.LED1();
                    await DisplayAlert("Take Medication", "Take Medication from compartment 1", "Ok");
                }

                if (doseBins == 4)
                {
                    BluetoothManager.Instance.LED2();
                    await DisplayAlert("Take Medication", "Take Medication from compartment 2", "Ok");
                }

                if (doseBins == 9)
                {
                    BluetoothManager.Instance.LED3();
                    await DisplayAlert("Take Medication", "Take Medication from compartment 3", "Ok");
                }

                if (doseBins == 16)
                {
                    BluetoothManager.Instance.LED4();
                    await DisplayAlert("Take Medication", "Take Medication from compartment 4", "Ok");
                }

                if (doseBins == 5)
                {
                    BluetoothManager.Instance.LED1();
                    BluetoothManager.Instance.LED2();
                    await DisplayAlert("Take Medication", "Take Medication from compartments 1 and 2", "Ok");
                }

                if (doseBins == 10)
                {
                    BluetoothManager.Instance.LED1();
                    BluetoothManager.Instance.LED3();
                    await DisplayAlert("Take Medication", "Take Medication from compartments 1 and 3", "Ok");
                }

                if (doseBins == 17)
                {
                    BluetoothManager.Instance.LED1();
                    BluetoothManager.Instance.LED4();
                    await DisplayAlert("Take Medication", "Take Medication from compartments 1 and 4", "Ok");
                }

                if (doseBins == 13)
                {
                    BluetoothManager.Instance.LED3();
                    BluetoothManager.Instance.LED2();
                    await DisplayAlert("Take Medication", "Take Medication from compartments 2 and 3", "Ok");
                }

                if (doseBins == 20)
                {
                    BluetoothManager.Instance.LED4();
                    BluetoothManager.Instance.LED2();
                    await DisplayAlert("Take Medication", "Take Medication from compartments 2 and 4", "Ok");
                }

                if (doseBins == 25)
                {
                    BluetoothManager.Instance.LED3();
                    BluetoothManager.Instance.LED4();
                    await DisplayAlert("Take Medication", "Take Medication from compartments 3 and 4", "Ok");
                }

                if (doseBins == 14)
                {
                    BluetoothManager.Instance.LED1();
                    BluetoothManager.Instance.LED2();
                    BluetoothManager.Instance.LED3();
                    await DisplayAlert("Take Medication", "Take Medication from compartments 1, 2 and 3", "Ok");
                }

                if (doseBins == 21)
                {
                    BluetoothManager.Instance.LED1();
                    BluetoothManager.Instance.LED2();
                    BluetoothManager.Instance.LED4();
                    await DisplayAlert("Take Medication", "Take Medication from compartments 1, 2 and 4", "Ok");
                }

                if (doseBins == 26)
                {
                    BluetoothManager.Instance.LED1();
                    BluetoothManager.Instance.LED3();
                    BluetoothManager.Instance.LED4();
                    await DisplayAlert("Take Medication", "Take Medication from compartments 1, 3 and 4", "Ok");
                }

                if (doseBins == 29)
                {
                    BluetoothManager.Instance.LED3();
                    BluetoothManager.Instance.LED2();
                    BluetoothManager.Instance.LED4();
                    await DisplayAlert("Take Medication", "Take Medication from compartments 2, 3 and 4", "Ok");
                }

                if (doseBins == 30)
                {
                    BluetoothManager.Instance.LED1();
                    BluetoothManager.Instance.LED2();
                    BluetoothManager.Instance.LED3();
                    BluetoothManager.Instance.LED4();
                    await DisplayAlert("Take Medication", "Take Medication from compartments 1, 2, 3, and 4", "Ok");
                }
            }

            /*
             * else
             * {
             *  await DisplayAlert("Great Job!", "You have already taken your medication", "Ok");
             * }*/

            //await Navigation.PopToRootAsync();
            await Navigation.PushAsync(new MedAdhere_0_6Page(1));
        }