//Edits the alert that is selected private void editSelectedAlert() { if (alertsListView.SelectedItems.Count == 0) return; int selectedIndex = alertsListView.SelectedIndices[0]; string selectedItem = alertsListView.SelectedItems[0].SubItems[1].Text; Alert alert = htAlerts[selectedItem]; Setup setup = new Setup(alert, controller.getSetting("AlertBackground")); if (setup.ShowDialog() == DialogResult.OK) { alert = setup.getAlert(); //Update alert controller.updateAlert(alert); //Recreate Alert Dialog using asynchronous delegate recreateAlertThread(alert); //Recreate Alert in htAlerts hashtable htAlerts.Remove(selectedItem); htAlerts.Add(selectedItem, alert); //Update List View Record ListViewItem lvi = alertsListView.Items[selectedIndex]; if (alert.getValid()) lvi.Checked = true; else lvi.Checked = false; lvi.SubItems[1].Text = "" + alert.getAlertId(); lvi.SubItems[2].Text = alert.getTitle(); lvi.SubItems[3].Text = "" + alert.getWakeUpTime(); } alertsListView.Items[selectedIndex].Selected = true; alertsListView.Select(); sortAlertListView(); }
private void createNewAlertBut_Click(object sender, EventArgs e) { if (!Registration.isValid()) { if( alertsListView.Items.Count >= 19 ) { new MaxAlertPopUp().ShowDialog(); return; } } Setup setup = new Setup(controller.getSetting("AlertBackground"), System.Convert.ToInt32(controller.getSetting("AlertFont"))); if (setup.ShowDialog() == DialogResult.OK) { Alert alert = setup.getAlert(); //Create Alert in the Database alert = controller.createNewAlert(alert); //Add Alert to the Application htAlerts.Add("" + alert.getAlertId(), alert); addAlertListViewItem(alert); createAlertThread(alert); sortAlertListView(); } }