Exemplo n.º 1
0
        private void OnScheduleToast(string timeStr, string title, string content)

        {
            ToastUtil toastUtil = new ToastUtil();

            toastUtil.showToast(timeStr, title, content);
        }
Exemplo n.º 2
0
        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);
            }
        }