Ejemplo n.º 1
0
        private async void Button_Click_Create_Update(object sender, RoutedEventArgs e)
        {
            string output;

            if (title.Text.Length == 0)
            {
                output = "Title不能为空";
            }
            else if (description.Text.Length == 0)
            {
                output = "Description不能为空";
            }
            else if (dueDate.Date < DateTime.Now.Date)
            {
                output = "dueDate不合法";
            }
            else
            {
                if (isNew == true)
                {
                    ViewModel.Add(title.Text, description.Text, dueDate.Date.Date);
                    output = "创建TODO成功";
                }
                else
                {
                    ViewModel.Update(TodoList.Current.SelectItem, title.Text, description.Text, dueDate.Date.Date, image.Source as BitmapImage);
                    output = "修改TODO成功";
                }
                MessageDialog tMsg = new MessageDialog(output);
                await tMsg.ShowAsync();

                double width = Window.Current.Bounds.Width;
                if (width > 0 && width < 960)
                {
                    TodoMain.Current.State = "OnlyListState";
                    TodoMain.Current.UpdateState();
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
                        AppViewBackButtonVisibility.Collapsed;
                }
                else
                {
                    Hide();
                }
                return;
            }
            MessageDialog msg = new MessageDialog(output);
            await msg.ShowAsync();
        }
Ejemplo n.º 2
0
        private async void title_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key == VirtualKey.Enter)
            {
                if (title.Text == String.Empty)
                {
                    MessageDialog msg = new MessageDialog("标题不能为空");
                    await msg.ShowAsync();

                    return;
                }
                viewModel.Add(title.Text);
                title.Text = String.Empty;
                UpdateListViewEmptyVisibility();
                TileGenerator.Update(Core.Database.ViewModel.Collection);
            }
        }