private void BtnRegularExpressionSearch_Click(object sender, EventArgs e) { if (this.InvokeRequired) { DelegateSearchRegEx inv = new DelegateSearchRegEx(this.BtnRegularExpressionSearch_Click); this.Invoke(inv, new object [] { sender, e }); } else { Cursor.Current = Cursors.WaitCursor; if (this.LbxNodeKey.Items.Count > 0) { this.LbxNodeKey.Items.Clear(); } if (string.IsNullOrEmpty(this.TxtSearchRegEx.Text)) { MessageBox.Show("Please enter search pattern.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); this.TxtSearchRegEx.Focus(); this.UnselectServerList(); Cursor.Current = Cursors.Default; return; } try { Regex objNotNaturalPattern1 = new Regex(this.TxtSearchRegEx.Text); } catch (Exception ex) { MessageBox.Show("RegEx Parser Error: " + ex.Message + Environment.NewLine + "Please re-check you pattern and search again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); this.TxtSearchRegEx.Focus(); this.UnselectServerList(); Cursor.Current = Cursors.Default; return; } IDictionary <string, byte[]> dict = CACHE.SharedCache.RegexGet(this.TxtSearchRegEx.Text); if (dict != null && dict.Count > 0) { if (this.LbxNodeKey.Items.Count > 0) { this.LbxNodeKey.Items.Clear(); } foreach (KeyValuePair <string, byte[]> item in dict) { this.LbxNodeKey.Items.Add( new Common.ComboBoxItem(item.Key, -1) ); } this.LbxNodeKey.Sorted = true; } else { MessageBox.Show("Your search term does not return any result, please revalidate your term: '" + this.TxtSearchRegEx.Text + "'", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.UnselectServerList(); Cursor.Current = Cursors.Default; return; } Cursor.Current = Cursors.Default; this.BindStats(); this.UnselectServerList(); this.UpdateLblAmount(); } }
private void BtnRegularExpressionSearch_Click(object sender, EventArgs e) { if (this.InvokeRequired) { DelegateSearchRegEx inv = new DelegateSearchRegEx(this.BtnRegularExpressionSearch_Click); this.Invoke(inv, new object [] {sender, e} ); } else { Cursor.Current = Cursors.WaitCursor; if (this.LbxNodeKey.Items.Count > 0) this.LbxNodeKey.Items.Clear(); if (string.IsNullOrEmpty(this.TxtSearchRegEx.Text)) { MessageBox.Show("Please enter search pattern.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); this.TxtSearchRegEx.Focus(); this.UnselectServerList(); Cursor.Current = Cursors.Default; return; } try { Regex objNotNaturalPattern1 = new Regex(this.TxtSearchRegEx.Text); } catch (Exception ex) { MessageBox.Show("RegEx Parser Error: " + ex.Message + Environment.NewLine + "Please re-check you pattern and search again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); this.TxtSearchRegEx.Focus(); this.UnselectServerList(); Cursor.Current = Cursors.Default; return; } IDictionary<string, byte[]> dict = CACHE.SharedCache.RegexGet(this.TxtSearchRegEx.Text); if (dict != null && dict.Count > 0) { if (this.LbxNodeKey.Items.Count > 0) this.LbxNodeKey.Items.Clear(); foreach (KeyValuePair<string, byte[]> item in dict) { this.LbxNodeKey.Items.Add( new Common.ComboBoxItem(item.Key, -1) ); } this.LbxNodeKey.Sorted = true; } else { MessageBox.Show("Your search term does not return any result, please revalidate your term: '" + this.TxtSearchRegEx.Text + "'", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.UnselectServerList(); Cursor.Current = Cursors.Default; return; } Cursor.Current = Cursors.Default; this.BindStats(); this.UnselectServerList(); this.UpdateLblAmount(); } }