Beispiel #1
0
        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
            }
        }
Beispiel #2
0
        private void UpdateMessageDetails()
        {
            try
            {
                string id = ((AppMessage)MessagesLB.SelectedIndex())?.Id;
                if (!string.IsNullOrEmpty(id))
                {
                    AppMessage message = _messages.GetMessage(id);

                    if (message != null)
                    {
                        SetMessageDetails(message);
                        ToggleButtons(true, message.Show ? HIDE : SHOW);
                    }
                }
            }
            catch (Exception)
            {
                // Something happened
            }
        }