Example #1
0
        public static async void buttonClick(object sender, EventArgs e, TimePicker picker, Label txt, CancellationTokenSource tokenSource
                                             , CancellationTokenSource token_for_logic, int type)
        {
            txt.Text = "alarm at: " + picker.Time.ToString();
            // cancelling last calls
            if (tokenSource != null)
            {
                tokenSource.Cancel();
            }
            if (token_for_logic != null)
            {
                token_for_logic.Cancel();
            }
            //new call
            tokenSource     = new CancellationTokenSource();
            token_for_logic = new CancellationTokenSource();

            TimeSpan timeToWait = picker.Time - DateTime.Now.TimeOfDay;

            if (timeToWait.CompareTo(TimeSpan.Zero) < 0)
            {
                var temp = new TimeSpan(24, 0, 0);  // next day
                timeToWait = temp + timeToWait;
            }
            SetTimer(timeToWait, tokenSource, token_for_logic, txt);
            //LoadingLabelXaml.CheckToWakeUpAsync(sender, e, type, DateTime.Now.Add(timeToWait), DateTime.Now, tokenSource, token_for_logic,txt);
            LoadingLabelXaml.CheckToWakeUpAsync2(sender, e, type, DateTime.Now.Add(timeToWait), DateTime.Now, tokenSource, token_for_logic, txt);
        }
Example #2
0
        private async void OnButtonClicked(object sender, EventArgs e)
        {
            Button bt = (Button)sender;

            switch (bt.ClassId)
            {
            case "Sign In":
                await Navigation.PushAsync(new LoadingLabelXaml());

                break;

            case "help":
                await Navigation.PushAsync(new SleepItOff.HelpPage());

                break;

            case "Sign Out":
                //Navigation.PushAsync(new SleepItOff.SignOutPage());
                await LoadingLabelXaml.SignoutButton_ClickAsync(sender, e);

                //cancel alarms in all pages
                SleepItOff.Utils.cancel(SleepItOff.SmartAlarmPage.tokenSource, SleepItOff.SmartAlarmPage.token_for_logic);
                SleepItOff.Utils.cancel(SleepItOff.CompatNapPage.tokenSource, SleepItOff.CompatNapPage.token_for_logic);
                SleepItOff.Utils.cancel(SleepItOff.CreativeSleepPage.tokenSource, SleepItOff.CreativeSleepPage.token_for_logic);
                await Navigation.PushAsync(new SleepItOff.SignOutPage());

                await Task.Delay(new TimeSpan(0, 0, 1));

                await Navigation.PushAsync(new SleepItOff.SignInPage());

                break;
            }
        }