private void AddSirenEvent() { SirenEventForm seForm = new SirenEventForm(); seForm.Timestamp = SirenEvent.GetCurretnTimestamp(); seForm.dateTimePicker1.Value = DateTime.Now; seForm.dateTimePicker1.Value = seForm.dateTimePicker1.Value.AddHours(24); seForm.textBox1.Text = ""; EventFormDisplayed = true; DialogResult result = seForm.ShowDialog(this); EventFormDisplayed = false; if (result == DialogResult.Cancel) { return; } SirenEvent se = new SirenEvent( seForm.dateTimePicker1.Value, seForm.textBox1.Text ); sirenEvents.Add(se); try { sirenEvents.Flush(); } catch (Exception e) { MessageBox.Show(e.ToString()); return; } AddListItem(se); }
private void EditSirenEvent() { ListView.SelectedListViewItemCollection lvs = listView1.SelectedItems; if (1 != lvs.Count) { return; } SirenEvent se; try { se = sirenEvents.Find(Int32.Parse(lvs[0].Name)); } catch (Exception e) { MessageBox.Show(e.ToString()); return; } if (null == se) { MessageBox.Show("Item not found"); } SirenEventForm seForm = new SirenEventForm(); seForm.Timestamp = se.Timestamp; seForm.dateTimePicker1.Value = se.DateTimeFromTimestamp; seForm.textBox1.Text = se.EventText; EventFormDisplayed = true; DialogResult result = seForm.ShowDialog(this); EventFormDisplayed = false; if (result == DialogResult.Cancel) { return; } SirenEvent newSe = new SirenEvent( seForm.dateTimePicker1.Value, seForm.textBox1.Text ); sirenEvents.Remove(se.Timestamp); sirenEvents.Add(newSe); try { sirenEvents.Flush(); } catch (Exception e) { MessageBox.Show(e.ToString()); return; } lvs[0].Remove(); AddListItem(newSe); }