/// <summary> /// Get the list of ILStubEvents from the event list, which satisfy the filter. /// </summary> public List <ILStubEvent> Search(ILStubEventFilterList listFilter) { List <ILStubEvent> eventList = new List <ILStubEvent>(); lock (m_eventList) { for (int i = 0; i < m_eventList.Count; i++) { ILStubEvent ilStubEvent = m_eventList[i]; if (listFilter.Match(ilStubEvent)) { eventList.Add(ilStubEvent); } } } return(eventList); }
private void toolStripButtonRefresh_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; ILStubEventFilterList listFilter = new ILStubEventFilterList(); int rowCount = dataGridViewFilter.Rows.Count; for (int i = 0; i < rowCount; i++) { DataGridViewRow dataGridViewRow = dataGridViewFilter.Rows[i]; if (dataGridViewRow.IsNewRow) { continue; } if (dataGridViewRow.Cells[0].Value == null) { MessageBox.Show("The field of row " + (i + 1) + " is empty."); return; } string filterName = dataGridViewRow.Cells[0].Value.ToString(); IILStubEventFilterDef filterDef = ILStubEventFilterManager.GetInstance().GetFilterDef(filterName); Debug.Assert(filterDef != null); if (dataGridViewRow.Cells[1].Value == null) { MessageBox.Show("The operation of row '" + filterName + "' is empty."); return; } string operaton = dataGridViewRow.Cells[1].Value.ToString(); if (dataGridViewRow.Cells[2].Value == null) { MessageBox.Show("The value of row '" + filterName + "' is empty."); return; } string value = dataGridViewRow.Cells[2].Value.ToString(); try { IILStubEventFilter filter = filterDef.CreateFilter(operaton, value); listFilter.Add(filter); } catch (FilterOperationIsNullException ex) { MessageBox.Show(String.Format( Resource.ResourceManager.GetString("Wrn_FilterOperationIsNull"), ex.FilterName)); return; } catch (FilterOperationNotSupportException ex) { MessageBox.Show(String.Format( Resource.ResourceManager.GetString("Wrn_FilterOperationNotSupport"), ex.Operation, ex.FilterName)); return; } catch (FilterValueIsNullException ex) { MessageBox.Show(String.Format( Resource.ResourceManager.GetString("Wrn_FilterValueIsNull"), ex.FilterName)); return; } catch (FilterValueNotIntegerException ex) { MessageBox.Show(String.Format( Resource.ResourceManager.GetString("Wrn_FilterValueNotInteger"), ex.Value, ex.FilterName)); return; } } m_filterList = listFilter; UpdateFilterMessage(); UpdateEventList(); } finally { this.Cursor = Cursors.Default; } }