public ProcessableListType ProcessingWrapper(ProcessableListType processableList) { ProcessableListType list = processableList; foreach (ListViewItem item in ListView.Items) { ProcessingListViewItem <ProcessableListType> processorItem = item as ProcessingListViewItem <ProcessableListType>; if (processorItem.Enabled) { list = processorItem.ProcessList(list); } } return(list); }
void ListView_KeyDown(object sender, KeyEventArgs e) { e.Handled = true; if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back) { if (ListView.Items.Count > 0) { foreach (ListViewItem item in ListView.SelectedItems) { ListView.Items.Remove(item); } OnItemsChanged(); } } else if (e.KeyCode == Keys.Space) { if (ListView.Items.Count > 0) { foreach (ListViewItem item in ListView.SelectedItems) { if (item is ProcessingListViewItem <ProcessableListType> ) { ProcessingListViewItem <ProcessableListType> processingItem = item as ProcessingListViewItem <ProcessableListType>; processingItem.Enabled = !processingItem.Enabled; if (processingItem.Enabled) { processingItem.ForeColor = Control.DefaultForeColor; } else { processingItem.ForeColor = Color.Gray; } } } OnItemsChanged(); } } else { e.Handled = false; } }
public void Add(ProcessingListViewItem <ProcessableListType> item) { listView1.Items.Add(item); OnItemsChanged(); }