private void lvwMonitorItems_ItemCheck(object sender, ItemCheckEventArgs e) { ListViewItem changedItem = lvwMonitorItems.Items[e.Index]; MonitorConfigurationItem mci = changedItem.Tag as MonitorConfigurationItem; bool ischecked = e.NewValue == CheckState.Checked; mci.Active = ischecked; }
private ListViewItem BuildItem(MonitorConfigurationItem mci) { ListViewItem result = new ListViewItem(new String[] { mci.Title, mci.MonitorPath, mci.Filter }); result.Checked = mci.Active; result.Tag = mci; return(result); }
private void RefreshItem(ListViewItem refreshit) { MonitorConfigurationItem mci = (MonitorConfigurationItem)refreshit.Tag; refreshit.Text = mci.Title; refreshit.SubItems[0].Text = mci.MonitorPath; refreshit.SubItems[1].Text = mci.Filter; refreshit.Checked = mci.Active; }
private void tsRemove_Click(object sender, EventArgs e) { if (lvwMonitorItems.SelectedItems.Count > 0) { ListViewItem selecteditem = lvwMonitorItems.SelectedItems[0]; MonitorConfigurationItem mci = selecteditem.Tag as MonitorConfigurationItem; if (MessageBox.Show("Are you sure you want to remove the item " + mci.Title + "?", "Confirm Remove", MessageBoxButtons.YesNo) == DialogResult.Yes) { lvwMonitorItems.Items.Remove(selecteditem); } } }
private void tsEdit_Click(object sender, EventArgs e) { if (lvwMonitorItems.SelectedItems.Count > 0) { ListViewItem selecteditem = lvwMonitorItems.SelectedItems[0]; MonitorConfigurationItem mci = selecteditem.Tag as MonitorConfigurationItem; if (EditMonitorItem.EditItem(this, mci)) { RefreshItem(selecteditem); } } }
private void cmdApply_Click(object sender, EventArgs e) { var grabitems = config.GetItems(); grabitems.Clear(); foreach (ListViewItem lvi in lvwMonitorItems.Items) { MonitorConfigurationItem mci = lvi.Tag as MonitorConfigurationItem; grabitems.Add(mci); } config.Save(); RestartMonitor(); }
private void tsNewItem_Click(object sender, EventArgs e) { MonitorConfigurationItem mci = new MonitorConfigurationItem(); ListViewItem newitem = BuildItem(mci); lvwMonitorItems.Items.Add(newitem); if (EditMonitorItem.EditItem(this, mci)) { RefreshItem(newitem); } else { lvwMonitorItems.Items.Remove(newitem); } }
private void LoadItems(XDocument docSource) { ConfigurationElements = new List <MonitorConfigurationItem>(); XElement RootNode = docSource.Root; if (RootNode == null) { return; } foreach (XElement MonitorItem in RootNode.Descendants("MonitorItem")) { MonitorConfigurationItem mci = new MonitorConfigurationItem(MonitorItem); ConfigurationElements.Add(mci); } }
public static bool EditItem(IWin32Window owner, MonitorConfigurationItem mciitem) { EditMonitorItem dlgUse = new EditMonitorItem(mciitem); return(dlgUse.ShowDialog(owner) == System.Windows.Forms.DialogResult.OK); }
public EditMonitorItem(MonitorConfigurationItem itemedit) { mci = itemedit; InitializeComponent(); }