public void updateTodoItem(BitmapImage image, string title, string description, DateTimeOffset date) { this.allItems[selectId].image = image; this.allItems[selectId].title = title; this.allItems[selectId].description = description; this.allItems[selectId].date = date; TodoItemDataBase.update(allItems[selectId].id, allItems[selectId].title, allItems[selectId].description, allItems[selectId].date); }
public static string ImageName = "background.jpg"; // 默认图片的名称 public void AddTodoItem(BitmapImage image, string title, string description, DateTimeOffset date) { TodoItem newItem = new TodoItem(image, title, description, date); newItem.imageName = ImageName; this.allItems.Add(newItem); TodoItemDataBase.insert(newItem.id, newItem.title, newItem.description, newItem.date, newItem.completed, ImageName); // 插入数据库项 ImageName = "background.jpg"; // 恢复为默认图片 }
public static TodoItemViewModel ViewModel = new TodoItemViewModel(); // ViewModel存储Item数据.所有页面共享一份数据 public WholePage() { this.InitializeComponent(); Current = this; MainPageFrame.Navigate(typeof(MainPage)); NewPageFrame.Navigate(typeof(NewPage)); SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; // 创建后退Button TodoItemDataBase.createTable(); // 若数据库表不存在, 则创建数据库表 ViewModel.allItems = TodoItemDataBase.getAllItems(); // 从数据库中获取信息 Tile.tileCreate(); // 调用创建磁贴的函数 }
protected override async void OnNavigatedTo(NavigationEventArgs e) { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = Frame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; if (e.NavigationMode == NavigationMode.New) { ApplicationData.Current.LocalSettings.Values.Remove("NewPage"); } else { if (ApplicationData.Current.LocalSettings.Values["image"] != null) { StorageFile temp; temp = await StorageApplicationPermissions.FutureAccessList.GetFileAsync((string)ApplicationData.Current.LocalSettings.Values["image"]); IRandomAccessStream ir = await temp.OpenAsync(FileAccessMode.Read); BitmapImage bi = new BitmapImage(); await bi.SetSourceAsync(ir); NewPage.Current.image.Source = bi; ApplicationData.Current.LocalSettings.Values["image"] = null; } if (ApplicationData.Current.LocalSettings.Values.ContainsKey("NewPage")) { ViewModel.allItems = TodoItemDataBase.getAllItems(); var composite = ApplicationData.Current.LocalSettings.Values["NewPage"] as ApplicationDataCompositeValue; title.Text = (string)composite["Title"]; detail.Text = (string)composite["Details"]; dueDate.Date = (DateTimeOffset)composite["Date"]; isUpdate = (bool)composite["isUpdate"]; if (isUpdate) { create.Content = "Update"; cancel.Content = "Delete"; barShareButton.Visibility = Visibility.Visible; } ApplicationData.Current.LocalSettings.Values.Remove("NewPage"); } } }
private async void clickSearchButton(object sender, RoutedEventArgs e) { var messageDialog = new MessageDialog(""); messageDialog.Commands.Add(new UICommand("Close")); messageDialog.DefaultCommandIndex = 0; messageDialog.CancelCommandIndex = 1; if (searchMessage.Text == "") { messageDialog.Content = "Please input the message for search"; } else { StringBuilder result = TodoItemDataBase.query(searchMessage.Text); messageDialog.Content = result.ToString(); } await messageDialog.ShowAsync(); }
public void removeTodoItem() { TodoItemDataBase.delete(allItems[selectId].id); this.allItems.RemoveAt(selectId); }
private void clickCheckBox(object sender, RoutedEventArgs e) { TodoItemDataBase.updateCompleted(); }