private void DeleteItem() { try { if (SelectedTask == null) { return; } else if (!MessageBoxFactory.ShowConfirmAsBool("Are you sure you want to delete this Task and ALL it's SubTasks?", "Confirm Delete", System.Windows.MessageBoxImage.Exclamation)) { return; } var parent = SelectedTask.Parent; int?pid = parent == null ? null : (int?)parent.TaskItemID; Workspace.API.DeleteTask(SelectedTask); TasksChanged(); if (pid != null) { ExpandAndSelect(tasks, pid.Value); } //Need to update list as well //TODO Duplicate: RefreshListsView(); } catch (Exception e) { MessageBoxFactory.ShowError(e); } }
private void ClearLogs() { try { if (selectedTask == null) { return; } else if (!MessageBoxFactory.ShowConfirmAsBool("Delete all log entries?", "Confirm Delete")) { return; } foreach (var t in Workspace.Instance.TasksLog.Where(x => x.TaskID == SelectedTask.Data.TaskItemID)) { Workspace.Instance.TasksLog.Remove(t); } Workspace.Instance.SaveChanges(); UpdateCalendar(); } catch (Exception e) { } }
private void Export() { try { if (string.IsNullOrEmpty(SavePath)) { throw new Exception("Save path not defined."); } else if (string.IsNullOrEmpty(SelectedExporter)) { throw new Exception("No exporter selected."); } else if (SelectedBook == null) { throw new Exception("No book selected."); } if (File.Exists(SavePath) && !MessageBoxFactory.ShowConfirmAsBool("Overwrite existing file?", "File Exists")) { return; } BaseExporter exporter = GetExporter(); exporter.Export(SelectedBook, SavePath); MessageBoxFactory.ShowInfo("Book has been exported to: " + SavePath, "Book Exported"); } catch (Exception e) { MessageBoxFactory.ShowError(e); } }
private void ClearDatabase() { if (MessageBoxFactory.ShowConfirmAsBool("Are you sure you want to clear the database?", "Confirm Clear Database", MessageBoxImage.Exclamation)) { QuoteService.Instance.DataStore.ClearTables(); //TODO: Change all to use QuoteService } }
private void DeleteQuote() { if (SelectedQuote != null && MessageBoxFactory.ShowConfirmAsBool("Are you sure you want to delete the selected quote?", "Confirm Delete")) { dataStore.DeleteQuote(SelectedQuote); LoadItem(); } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (vm.HasUnsaved) { var ctnu = MessageBoxFactory.ShowConfirmAsBool("There are unsaved documents. Continue closing?", "Unsaved Documents", MessageBoxImage.Exclamation); if (!ctnu) { e.Cancel = true; } } }
private void DeleteSelected() { try { if (SelectedNode == null) { MessageBoxFactory.ShowError("No item selected"); return; } INodeData parent = null; if (SelectedNode.IsBook) { Book bk = (Book)SelectedNode.GetData(); if (!MessageBoxFactory.ShowConfirmAsBool("Delete book and all notes for '" + bk.Title + "'?", "Delete Book")) { return; } parent = bk.DefaultTopic; Util.DB.Books.Remove(bk); } else if (SelectedNode.IsNote) { Note n = (Note)SelectedNode.GetData(); if (!MessageBoxFactory.ShowConfirmAsBool("Delete " + n.OriginalText + "'?", "Delete Note")) { return; } parent = n.Book; Util.DB.Notes.Remove(n); } else if (SelectedNode.IsTopic) { Util.DB.Topics.Remove((Topic)SelectedNode.GetData()); } else { throw new Exception("Type not supported: " + SelectedNode.GetDataType()); } Util.DB.SaveChanges(); SetFilter(parent); } catch (Exception e) { Util.DB.RejectChanges(); MessageBoxFactory.ShowError(e); } }
private void DeleteList() { if (SelectedList == null) { return; } if (MessageBoxFactory.ShowConfirmAsBool("Are you sure you want to delete: " + SelectedList.Name, "Delete List")) { Workspace.API.DeleteList(SelectedList.Data); ReloadLists(); } }
private void ClearDatabase() { if (MessageBoxFactory.ShowConfirmAsBool("Are you sure you want to clear the database?", "Confirm Clear Database", MessageBoxImage.Exclamation)) { var DB = Workspace.Instance; DB.Comments.RemoveRange(DB.Comments); DB.Lists.RemoveRange(DB.Lists); DB.Tasks.RemoveRange(DB.Tasks); DB.TasksLog.RemoveRange(DB.TasksLog); DatabaseUpdated = true; } }
private void ChangeDB() { if (!MessageBoxFactory.ShowConfirmAsBool("Are you sure you want to close the current database?", "Close Database?", MessageBoxImage.Asterisk)) { return; } Workspace.Unload(); LoadWindow loader = new LoadWindow(); loader.Show(); window.Close(); }
private void DeleteTag() { try { if (SelectedTag == null) { return; } else if (MessageBoxFactory.ShowConfirmAsBool($"Delete {SelectedTag.Name}?", "Confirm Delete")) { StateManager.Instance.DataStore.DeleteTag(SelectedTag.ID); LoadWindow(SelectedCategory.ID); } } catch (Exception e) { MessageBoxFactory.ShowError(e); } }
private void DeleteLogin() { try { if (SelectedLogin == null) { return; } if (MessageBoxFactory.ShowConfirmAsBool("Delete " + SelectedLogin.Name + "?", "Delete Login", System.Windows.MessageBoxImage.Exclamation)) { ds.DeleteEntry(SelectedLogin); LoadLists(); } } catch (Exception e) { MessageBoxFactory.ShowError(e); } }
private void DoClick() { if (info.IsMine) { //TODO: Make Auto-Undo a global setting bool undo; if (alwaysContinue) { undo = true; } else { undo = MessageBoxFactory.ShowConfirmAsBool("Undo?", "You hit a mine!"); } if (undo) { Flag(true); return; } SetColor(ButtonStates.Mine); } else { ButtonText = info.IsEmpty ? null : info.Value.ToString(); SetColor(ButtonStates.Number); } Clicked = true; if (onClick != null) { onClick.Invoke(info.Row, info.Column); } }
private void DeletePassword() { try { if (SelectedPassword == null) { return; } //TODO: Should make PasswordOptional and if doesn't have, mark red if (MessageBoxFactory.ShowConfirmAsBool("Delete " + SelectedPassword.Name + "? All logins will be deleted.", "Delete Password", System.Windows.MessageBoxImage.Exclamation)) { ds.DeletePassword(SelectedPassword); LoadLists(); } } catch (Exception e) { MessageBoxFactory.ShowError(e); } }
private void Delete() { try { if (SelectedTopic != null) { var notes = Util.DB.Notes.Count(x => x.TopicId == SelectedTopic.ID); if (MessageBoxFactory.ShowConfirmAsBool(SelectedTopic.Name + " has " + notes + " notes. These will be orphaned. Continue?", "Confirm Delete")) { Util.DB.Topics.Remove(SelectedTopic); Util.DB.SaveChanges(); RaisePropertyChanged("Topic"); } } } catch (Exception e) { Util.DB.RejectChanges(); MessageBoxFactory.ShowError(e); } }
public void Load() { try { FileInfo fi = new FileInfo(SelectedPath); if (!fi.Exists) { if (MessageBoxFactory.ShowConfirmAsBool("Do you want to create a new workspace?", "Create New Workspace")) { Workspace.CreateWorkspace(SelectedPath); } else { return; } } else { Workspace.LoadWorkspace(SelectedPath); } if (!Settings.Default.PathHistory.Contains(selectedPath)) { Settings.Default.PathHistory.Add(selectedPath); Settings.Default.Save(); } WorkspaceWindow wiw = new WorkspaceWindow(); wiw.Show(); window.Close(); } catch (Exception e) { MessageBoxFactory.ShowError(e, "Error Loading Workspace"); } }
private void DeleteCategory() { try { if (SelectedCategory == null) { return; } else if (SelectedCategory.ItemCount > 0) { throw new Exception("Cannot delete a category with items."); } else if (MessageBoxFactory.ShowConfirmAsBool($"Delete {SelectedCategory.Name}?", "Confirm Delete")) { StateManager.Instance.DataStore.DeleteCategory(SelectedCategory.ID); LoadWindow(); } } catch (Exception e) { MessageBoxFactory.ShowError(e); } }
private void DeleteFromList() { try { switch (SelectedList) { case Author: Author author = SelectedListItem as Author; if (author != null && MessageBoxFactory.ShowConfirmAsBool("Delete author: " + author.Name, "Delete Author")) { dataStore.DeleteAuthor(author); } break; case Tag: Tag tag = selectedListItem as Tag; if (tag != null) { int count = dataStore.GetQuotesCount(tag); if (MessageBoxFactory.ShowConfirmAsBool(String.Format("{0} has {1} quotes associated with it. Continue delete?", tag.TagName, count), "Delete Tag")) { dataStore.DeleteTag(tag); } } break; } RefreshList(); } catch (Exception e) { MessageBoxFactory.ShowError(e); } }