private void RemoveButton_Click(object sender, System.EventArgs e) { Button B = sender as Button; if (B == null) { return; } ItemPredicate IP = B.Tag as ItemPredicate; if (IP != null) { int idx = this.Predicates_.IndexOf(IP); this.pnlSearchOptions.Controls.Remove(IP); this.pnlSearchOptions.Controls.Remove(B); this.Predicates_.Remove(IP); for (int i = idx; i < this.Predicates_.Count; ++i) { ItemPredicate LowerIP = this.Predicates_[i]; LowerIP.Top -= 4 + IP.Height; Button LowerButton = LowerIP.Tag as Button; if (LowerButton != null) { LowerButton.Top -= 4 + IP.Height; } } this.pnlSearchOptions.Height -= 4 + IP.Height; } }
private void AddPredicate() { ItemPredicate IP = new ItemPredicate(); IP.Width = this.pnlSearchOptions.Width; IP.Left = 0; if (this.Predicates_.Count > 0) { ItemPredicate LastIP = this.Predicates_[this.Predicates_.Count - 1]; IP.Top = LastIP.Top + LastIP.Height; } else IP.Top = this.btnClose.Top; IP.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; this.pnlSearchOptions.Height += IP.Height; this.pnlSearchOptions.Controls.Add(IP); Button B = new Button(); // Add or Remove button B.Tag = IP; IP.Tag = B; B.FlatStyle = FlatStyle.System; B.Width = 20; B.Height = 20; IP.Width -= 3 + B.Width; B.Top = IP.Top; B.Left = IP.Left + IP.Width; B.Anchor = AnchorStyles.Right | AnchorStyles.Top; if (this.Predicates_.Count == 0) { B.Text = "+"; B.Click += new EventHandler(this.AddButton_Click); } else { B.Text = "-"; B.Click += new EventHandler(this.RemoveButton_Click); } this.pnlSearchOptions.Controls.Add(B); this.Predicates_.Add(IP); }
private void btnRunQuery_Click(object sender, System.EventArgs e) { // Ensure the query is valid for (int i = 0; i < this.Predicates_.Count; ++i) { ItemPredicate IP = this.Predicates_[i]; if (IP == null) { continue; } string ValidationError = IP.ValidateQuery(); if (ValidationError != null) { MessageBox.Show(this, String.Format(I18N.GetText("Message:InvalidQuery"), i + 1, ValidationError), I18N.GetText("Title:InvalidQuery"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } // Clear the results this.InitializeResultsPane(); // And add all items that match foreach (Item I in this.Items_) { if (this.CheckQuery(I)) { this.SearchResults_.Add(I); this.stbStatus.Text = String.Format(I18N.GetText("Status:ItemSearch"), this.SearchResults_.Count); Application.DoEvents(); } } foreach (Item I in this.SearchResults_) { this.ilItemIcons.Images.Add(I.GetIcon()); ListViewItem LVI = this.lstItems.Items.Add("", this.ilItemIcons.Images.Count - 1); LVI.Tag = I; LVI.Text = this.lstItems.Items.Count.ToString(); foreach (string Field in I.GetAllFields()) { LVI.SubItems.Add(I.GetFieldText(Field)); } } this.FinalizeResultsPane(); }
private void AddPredicate() { ItemPredicate IP = new ItemPredicate(); IP.Width = this.pnlSearchOptions.Width; IP.Left = 0; if (this.Predicates_.Count > 0) { ItemPredicate LastIP = this.Predicates_[this.Predicates_.Count - 1]; IP.Top = LastIP.Top + LastIP.Height; } else { IP.Top = this.btnClose.Top; } IP.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; this.pnlSearchOptions.Height += IP.Height; this.pnlSearchOptions.Controls.Add(IP); Button B = new Button(); // Add or Remove button B.Tag = IP; IP.Tag = B; B.FlatStyle = FlatStyle.System; B.Width = 20; B.Height = 20; IP.Width -= 3 + B.Width; B.Top = IP.Top; B.Left = IP.Left + IP.Width; B.Anchor = AnchorStyles.Right | AnchorStyles.Top; if (this.Predicates_.Count == 0) { B.Text = "+"; B.Click += new EventHandler(this.AddButton_Click); } else { B.Text = "-"; B.Click += new EventHandler(this.RemoveButton_Click); } this.pnlSearchOptions.Controls.Add(B); this.Predicates_.Add(IP); }