private void RemoveButton_Click(object sender, EventArgs e) { try { string id = ((AppMessage)MessagesLB.SelectedIndex())?.Id; if (!string.IsNullOrEmpty(id) && _messages.Remove(id)) { if (!_messages.SaveMessages()) { MessageBox.Show("Unable to save some or all messages.", "Error Occurred.", MessageBoxButtons.OK, MessageBoxIcon.Error); } ClearMessageDetails(); ToggleButtons(false, DASH); SearchTB.SetText(string.Empty); UpdateMessages(); ClearMessageDisplay(); } } catch (Exception) { //Something happened } }
private void CreateButton_Click(object sender, EventArgs e) { if (_messages.Add()) { if (!_messages.SaveMessages()) { MessageBox.Show("Unable to save some or all messages.", "Error Occurred.", MessageBoxButtons.OK, MessageBoxIcon.Error); } ClearMessageDetails(); ToggleButtons(false, DASH); SearchTB.SetText(string.Empty); UpdateMessages(); ClearMessageDisplay(); } }
/// <summary> /// Updates the messages view /// </summary> public void UpdateMessagesView() { SearchTB.SetText(string.Empty); UpdateMessages(); ToggleButtons(false, DASH); }