private async void Period_pickerFlyout_TimePicked(TimePickerFlyout sender, TimePickedEventArgs args)
        {
            if (Convert.ToInt32(sender.Time.TotalMinutes) != 0)
            {
                Period_picker_tamp.TIME_PERIOD = Convert.ToInt32(sender.Time.TotalMinutes);
                Period_picker_tamp.TIMESTART   = DateTime.Now.ToString("s");
                Period_picker_tamp.TIMEEND     = DateTime.Now.AddMinutes(Period_picker_tamp.TIME_PERIOD).ToString("s");
                DB_Controller db = new DB_Controller();
                await db.update_TimePeriodList(Period_picker_tamp);

                foreach (ScheduledToastNotification s in ToastNotificationManager.CreateToastNotifier().GetScheduledToastNotifications())
                {
                    if (s.Id == "Period" + Period_picker_tamp.ID.ToString())
                    {
                        ScheduledToastNotification recurringToast = new ScheduledToastNotification(s.Content, DateTime.Parse(Period_picker_tamp.TIMEEND));
                        ToastNotificationManager.CreateToastNotifier().RemoveFromSchedule(s);
                        ToastNotificationManager.CreateToastNotifier().AddToSchedule(recurringToast);
                        break;
                    }
                }

                foreach (DB_TimePeriodList s in timePeriodListData)
                {
                    if (s.ID == Period_picker_tamp.ID)
                    {
                        s.TIME_PERIOD      = Period_picker_tamp.TIME_PERIOD;
                        s.TIMESTART        = Period_picker_tamp.TIMESTART;
                        s.TIMEEND          = Period_picker_tamp.TIMEEND;
                        Period_picker_tamp = null;
                        break;
                    }
                }
            }
        }
        private async void timePeriod_IsWork_Click(object sender, RoutedEventArgs e)
        {
            DB_TimePeriodList selectedTimePeriod = ((Coding4Fun.Toolkit.Controls.OpacityToggleButton)sender).DataContext as DB_TimePeriodList;

            if (((ToggleButton)sender).IsChecked == true & timePeriodWorkMutexCheck())
            {
                selectedTimePeriod.TIMESTART           = DateTime.Now.ToString("s");
                selectedTimePeriod.IS_WORK             = true;
                selectedTimePeriod.TimePeriod_barValue = 0;
                selectedTimePeriod.TIMEEND             = DateTime.Parse(selectedTimePeriod.TIMESTART).AddMinutes(selectedTimePeriod.TIME_PERIOD).ToString("s");
                foreach (DB_TimePeriodList s in timePeriodListData)
                {
                    if (s.ID == selectedTimePeriod.ID)
                    {
                        timePeriodListData[timePeriodListData.IndexOf(s)] = selectedTimePeriod;
                        break;
                    }
                }
                DB_Controller db = new DB_Controller();
                await db.update_TimePeriodList(selectedTimePeriod);

                XmlDocument toastXml      = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
                XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
                toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode("Time is up"));
                toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode("Time Period toast test"));
                ScheduledToastNotification recurringToast = new ScheduledToastNotification(toastXml, DateTime.Parse(selectedTimePeriod.TIMEEND));
                recurringToast.Id = "Period" + selectedTimePeriod.ID.ToString();
                ToastNotificationManager.CreateToastNotifier().AddToSchedule(recurringToast);

                dispatcherTimer.Start();
            }
            else if (((ToggleButton)sender).IsChecked == false)
            {
                selectedTimePeriod.IS_WORK = false;
                DB_Controller db = new DB_Controller();
                await db.update_TimePeriodList(selectedTimePeriod);

                DB_Controller db_test = new DB_Controller();
                await db_test.reflesh_timePeriod();

                List <DB_TimePeriodList> test_list = db_test.get_timePeriodList;
                dispatcherTimer.Stop();
                foreach (ScheduledToastNotification s in ToastNotificationManager.CreateToastNotifier().GetScheduledToastNotifications())
                {
                    if (s.Id == "Period" + selectedTimePeriod.ID.ToString())
                    {
                        ToastNotificationManager.CreateToastNotifier().RemoveFromSchedule(s);
                        break;
                    }
                }
            }
            else
            {
                ((ToggleButton)sender).IsChecked = false;
                Coding4Fun.Toolkit.Controls.ToastPrompt toast = new Coding4Fun.Toolkit.Controls.ToastPrompt();
                toast.Message = "一心不可二用poi";
                toast.Show();
            }
        }
        private void confirm_Click(object sender, RoutedEventArgs e)
        {
            DB_TimePeriodList timePeriodList = new DB_TimePeriodList(__name.Text, Convert.ToInt32(((ComboBoxItem)__time.SelectedItem).Content.ToString()), (bool)__is_work.IsChecked);
            DB_Controller     DB             = new DB_Controller();

            DB.insert_TimePeriodList(timePeriodList);
            toGoodNightPage();
        }
        private void Period_picker_button_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button != null)
            {
                ((TimePickerFlyout)FlyoutBase.GetAttachedFlyout(button)).Time = TimeSpan.FromMinutes(Convert.ToDouble(button.Content.ToString()));
                Period_picker_tamp = button.DataContext as DB_TimePeriodList;
                FlyoutBase.ShowAttachedFlyout(button);
            }
        }
        private async void timePeriod_delete_Click(object sender, RoutedEventArgs e)
        {
            DB_TimePeriodList selectedTimePeriod = ((MenuFlyoutItem)sender).DataContext as DB_TimePeriodList;
            DB_Controller     DB = new DB_Controller();

            DB.delete_TimePeriodList(selectedTimePeriod);
            await DB.reflesh_timePeriod();

            timePeriodListData           = DB.get_timePeriodList;
            time_Period_list.ItemsSource = timePeriodListData;
        }
Exemple #6
0
 public async Task update_TimePeriodList(DB_TimePeriodList data)
 {
     SQLiteAsyncConnection conn = GetConn();
     await conn.UpdateAsync(data);
 }
Exemple #7
0
 public async void delete_TimePeriodList(DB_TimePeriodList data)
 {
     SQLiteAsyncConnection conn = GetConn();
     await conn.DeleteAsync(data);
 }
Exemple #8
0
 public async void insert_TimePeriodList(DB_TimePeriodList data)
 {
     SQLiteAsyncConnection conn = GetConn();
     await conn.InsertAsync(data);
 }