static bool IsLimitingSearch(LogColumnType column, string pattern, string currentFilterString) { if (string.IsNullOrEmpty(pattern)) { return(false); } if (pattern.StartsWith(NegationPrefix)) { return(false); } if (column == LogColumnType.LineNr) { return(false); } if (currentFilterString == DefaultFilterString) { return(true); } if (pattern.StartsWith(currentFilterString) && currentFilterString.Length < pattern.Length) { var newString = pattern.Substring(currentFilterString.Length); if (Regex.Escape(newString).Length == newString.Length) { return(true); } } return(false); }
public void FilterColumn(LogColumnType column, string pattern, Func <bool> shouldCancel) { var currentFilterString = m_Filters.CurrentFilterString(column); if (pattern == currentFilterString) { return; } if (pattern == NegationPrefix) { pattern = DefaultFilterString; } //negated all matches nothing. User is about to exclude more... else if (pattern.StartsWith(NegationPrefix) && pattern.EndsWith("|")) { return; } if (!m_Filters.TrySetFilter(column, pattern)) { return; } ReloadItemsWithCurrentFilter(m_Filters.Matches, shouldCancel); //var limitingSearch = IsLimitingSearch(column, pattern, currentFilterString); //if (!limitingSearch) //{ // ReloadItemsWithCurrentFilter(m_Filters.Matches, shouldCancel); //} //else //{ // ApplyFilterToVisibleItems(m_Filters.GetMatcher(column), shouldCancel); //} }
/// <summary> /// Creates a new instance of a <see cref="LogColumn"/> with the specified parameters. /// </summary> /// <param name="name">The name of the <see cref="LogColumn"/>.</param> /// <param name="expression">The <see cref="Regex"/> string of the <see cref="LogColumn"/>.</param> /// <param name="optional">The value of this <see cref="LogColumn"/> is optional on parsing, or not.</param> /// <param name="type">The <see cref="LogColumnType"/> of the <see cref="LogColumn"/>.</param> public LogColumn(string name, string expression, bool optional, LogColumnType type) { Name = name; Expression = expression; Optional = optional; ColumnType = type; }
/// <summary> /// Handles the Click event of the test columnizer <see cref="ToolStripButton"/>. /// </summary> private void TsbTestColumnizerClick(object sender, System.EventArgs e) { // Create a new temporary columnizer object for testing. Columnizer tmpColumnizer = new Columnizer(txtName.Text); foreach (DataGridViewRow dgvRow in dgvColumns.Rows) { bool optional = dgvRow.Cells[2].Value != null; LogColumnType columnType = (LogColumnType)System.Enum.Parse( typeof(LogColumnType) , (string)dgvRow.Cells[3].Value); tmpColumnizer.Columns.Add(new LogColumn( (string)dgvRow.Cells[0].Value , (string)dgvRow.Cells[1].Value , optional , columnType , int.Parse((string)dgvRow.Cells[4].Value))); } using (FrmColumnizerTest testColumnizerDlg = new FrmColumnizerTest(tmpColumnizer)) { testColumnizerDlg.ShowDialog(this); } }
/// <summary> /// deserializes the <see cref="LogColumn"/> instance from the spezified <paramref name="node"/>. /// </summary> /// <param name="node">The <see cref="XmlNode"/> that may contain <see cref="LogColumn"/> data to deserialize.</param> /// <returns><c>True</c> if the deserialialzation was successfull; otherwise <c>false</c>.</returns> public bool DeserializeFromXml(XmlNode node) { if (node != null && Equals(node.Name, "LogColumn") && node.Attributes != null) { if (node.Attributes["Name"] == null || node.Attributes["Expression"] == null || node.Attributes["Optional"] == null || node.Attributes["Type"] == null) { return(false); } Name = node.Attributes["Name"].Value ?? Resources.strColumnizerColumnDefaultName; Expression = node.Attributes["Expression"].Value ?? Resources.strColumnizerColumnDefaultExpresssion; Optional = Equals(node.Attributes["Optional"].Value, bool.TrueString); int typeResult = 0; int.TryParse(node.Attributes["Type"].Value ?? "0", out typeResult); ColumnType = (LogColumnType)typeResult; return(true); } return(false); }