private void OnScheduleToast(string timeStr, string title, string content)

        {
            ToastUtil toastUtil = new ToastUtil();

            toastUtil.showToast(timeStr, title, content);
        }
        private void SubmitAction(object sender, RoutedEventArgs e)
        {
            if (titleTextBox.Text.Length > 0 && contentTextBox.Text.Length > 0)
            {
                if (selectedAlarmTime != null)
                {
                    DateTime        dt           = DateTime.Parse(selectedAlarmTime);
                    System.DateTime startTime    = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区
                    long            timeStamp    = (long)(dt - startTime).TotalMilliseconds / 1000;
                    DateTime        nowDateTime  = DateTime.Now;
                    long            nowTimeStamp = (long)(nowDateTime - startTime).TotalMilliseconds / 1000;
                    if (timeStamp <= nowTimeStamp)
                    {
                        FlyoutBase.ShowAttachedFlyout((FrameworkElement)alarmTime);
                        return;
                    }
                }


                //back
                SolidColorBrush brush = new SolidColorBrush();
                brush.Color = mycolor;
                //noti
                string toastId = null;
                if (selectedAlarmTime != null)
                {
                    ToastUtil toastUtil = new ToastUtil();
                    toastId = toastUtil.showToast(selectedAlarmTime, titleTextBox.Text, contentTextBox.Text);
                }
                if (this.editCardContent != null)
                {
                    if (this.editCardContent.ToastId != null)
                    {
                        //remove old toast
                        ToastUtil toastUtil = new ToastUtil();
                        toastUtil.removeToast(this.editCardContent);
                    }
                    int index = this.model.Contents.IndexOf(this.editCardContent);
                    this.editCardContent = new CardContent {
                        ContentTitle = titleTextBox.Text, ContentDetail = contentTextBox.Text, AlarmTime = selectedAlarmTime, StatusColor = brush, ToastId = toastId
                    };;
                    this.model.Contents.RemoveAt(index);
                    this.model.Contents.Insert(index, this.editCardContent);
                }
                else
                {
                    this.model.Contents.Add(new CardContent {
                        ContentTitle = titleTextBox.Text, ContentDetail = contentTextBox.Text, AlarmTime = selectedAlarmTime, StatusColor = brush, ToastId = toastId
                    });
                }

                Frame.GoBack();
            }
            else
            {
                FlyoutBase.ShowAttachedFlyout((FrameworkElement)sender);
            }
        }
Beispiel #3
0
        private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
        {
            MenuFlyoutItem item = sender as MenuFlyoutItem;
            //delete
            CardContent clickVM = item.DataContext as CardContent;

            this.cardTitleVM.Contents.Remove(clickVM);
            //remove toast
            if (clickVM.AlarmTime != null && clickVM.AlarmTime.Length > 0)
            {
                ToastUtil toastUtil = new ToastUtil();
                toastUtil.removeToast(clickVM);
            }
        }
Beispiel #4
0
        //public CardTitleVM cardTitleVM { get; set; }

        private async void deleteCardListAction(object parameter)
        {
            //dialog
            CardTitleViewModel model        = parameter as CardTitleViewModel;
            ContentDialog      deleteDialog = new ContentDialog
            {
                Title             = "Delete",
                Content           = "Are you sure to delete" + " \"" + model.HeaderTitle + " \" list",
                PrimaryButtonText = "Delete",
                CloseButtonText   = "Cancel"
            };

            ContentDialogResult result = await deleteDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                int index = 0;
                for (int i = 0; i < this.cardListViewModel.CardLists.Count; i++)
                {
                    CardTitleViewModel singleVM = this.cardListViewModel.CardLists[i];
                    if (singleVM.CardId == model.CardId)
                    {
                        index = i;
                        break;
                    }
                }
                SingleCardUserControl deleteCardUC = this.cardUCLists[index];
                CardPanel.Children.Remove(deleteCardUC);
                this.cardUCLists.RemoveAt(index);
                this.cardListViewModel.CardLists.RemoveAt(index);

                foreach (CardContent content in deleteCardUC.cardTitleVM.Contents)
                {
                    if (content.AlarmTime != null)
                    {
                        ToastUtil toastUtil = new ToastUtil();
                        toastUtil.removeToast(content);
                    }
                }
            }
        }