Esempio n. 1
0
        private async void timePoint_check_Click(object sender, RoutedEventArgs e)
        {
            DB_TimePointList selectedTimePoint = ((CheckBox)sender).DataContext as DB_TimePointList;

            if (((CheckBox)sender).IsChecked == true)
            {
                selectedTimePoint.IS_WORK = true;
                foreach (DB_TimePointList s in timePointListData)
                {
                    if (s.ID == selectedTimePoint.ID)
                    {
                        s.IS_WORK = selectedTimePoint.IS_WORK;
                        break;
                    }
                }
                DB_Controller db = new DB_Controller();
                await db.update_TimePointList(selectedTimePoint);

                DateTime now = DateTime.Now;
                DateTime notificationTime = new DateTime(now.Year, now.Month, now.Day, (int)selectedTimePoint.TIME_POINT.Hours, (int)selectedTimePoint.TIME_POINT.Minutes, 0);
                if (isTimePassed(selectedTimePoint.TIME_POINT))
                {
                    return;
                }
                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 Point toast test"));
                ScheduledToastNotification recurringToast = new ScheduledToastNotification(toastXml, notificationTime);
                recurringToast.Id = "Point" + selectedTimePoint.ID.ToString();
                ToastNotificationManager.CreateToastNotifier().AddToSchedule(recurringToast);
            }
            else
            {
                selectedTimePoint.IS_WORK = false;
                foreach (DB_TimePointList s in timePointListData)
                {
                    if (s.ID == selectedTimePoint.ID)
                    {
                        s.IS_WORK = selectedTimePoint.IS_WORK;
                        break;
                    }
                }
                DB_Controller db = new DB_Controller();
                await db.update_TimePointList(selectedTimePoint);

                foreach (ScheduledToastNotification s in ToastNotificationManager.CreateToastNotifier().GetScheduledToastNotifications())
                {
                    if (s.Id == "Point" + selectedTimePoint.ID.ToString())
                    {
                        ToastNotificationManager.CreateToastNotifier().RemoveFromSchedule(s);
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        private async void timePoint_delete_Click(object sender, RoutedEventArgs e)
        {
            DB_TimePointList selectedTimePoint = ((MenuFlyoutItem)sender).DataContext as DB_TimePointList;
            DB_Controller    DB = new DB_Controller();

            DB.delete_TimePointList(selectedTimePoint);
            await DB.reflesh_timePoint();

            timePointListData            = DB.get_timePointList;
            time_points_list.ItemsSource = timePointListData;
        }
Esempio n. 3
0
 public async Task update_TimePointList(DB_TimePointList data)
 {
     SQLiteAsyncConnection conn = GetConn();
     await conn.UpdateAsync(data);
 }
Esempio n. 4
0
 public async void delete_TimePointList(DB_TimePointList data)
 {
     SQLiteAsyncConnection conn = GetConn();
     await conn.DeleteAsync(data);
 }
Esempio n. 5
0
 public async void insert_TimePointList(DB_TimePointList data)
 {
     SQLiteAsyncConnection conn = GetConn();
     await conn.InsertAsync(data);
 }