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();
            }
        }
Exemple #2
0
        private void ScreenGrabTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var fileName = String.Format("ARTorch_{0:}.jpg", DateTime.Now.Ticks);
            var bmpCurrentScreenImage = new WriteableBitmap((int)this.ActualWidth, (int)this.ActualHeight);

            bmpCurrentScreenImage.Render(LayoutRoot, new MatrixTransform());
            bmpCurrentScreenImage.Invalidate();
            SaveToMediaLibrary(bmpCurrentScreenImage, fileName, 100);

            var toast = new Coding4Fun.Toolkit.Controls.ToastPrompt();

            toast.Title       = "AR Torch";
            toast.Message     = "Image saved to 'Saved Pictures'";
            toast.ImageSource = new BitmapImage(new Uri("/Assets/ToastIcon.png", UriKind.RelativeOrAbsolute));
            toast.Show();
        }