/// <summary> /// Apply the filter /// </summary> private void btnApplyOrderFilter_Click(object sender, EventArgs e) { // return if object is not instantiated if (m_instrumentTradeSubscription == null) { return; } CreateInstrumentTradeSubscription(m_instrumentTradeSubscription.Instrument); // no filter to set, return if (this.cboFilter1.SelectedIndex < 0) { return; } // reset the current filters m_instrumentTradeSubscription.ClearFilter(); // create both "and" and "or" filters, setting false so the values are not negated TradeSubscriptionAndFilter andFilter = new TradeSubscriptionAndFilter(false); TradeSubscriptionOrFilter orFilter = new TradeSubscriptionOrFilter(false); // set the first filter if (this.rbAnd1.Checked) { andFilter.AddFilter(FilterFactory.Get(this.cboFilter1.SelectedIndex, this.txtFilter1.Text, m_instrumentTradeSubscription.Instrument)); } else { orFilter.AddFilter(FilterFactory.Get(this.cboFilter1.SelectedIndex, this.txtFilter1.Text, m_instrumentTradeSubscription.Instrument)); } // append additional filters if applicable if (this.cboFilter2.SelectedIndex >= 0) { if (this.rbAnd2.Checked) { andFilter.AddFilter(FilterFactory.Get(this.cboFilter2.SelectedIndex, this.txtFilter2.Text, m_instrumentTradeSubscription.Instrument)); } else { orFilter.AddFilter(FilterFactory.Get(this.cboFilter2.SelectedIndex, this.txtFilter2.Text, m_instrumentTradeSubscription.Instrument)); } } if (this.cboFilter3.SelectedIndex >= 0) { if (this.rbAnd3.Checked) { andFilter.AddFilter(FilterFactory.Get(this.cboFilter3.SelectedIndex, this.txtFilter3.Text, m_instrumentTradeSubscription.Instrument)); } else { orFilter.AddFilter(FilterFactory.Get(this.cboFilter3.SelectedIndex, this.txtFilter3.Text, m_instrumentTradeSubscription.Instrument)); } } if (this.cboFilter4.SelectedIndex >= 0) { if (this.rbAnd4.Checked) { andFilter.AddFilter(FilterFactory.Get(this.cboFilter4.SelectedIndex, this.txtFilter4.Text, m_instrumentTradeSubscription.Instrument)); } else { orFilter.AddFilter(FilterFactory.Get(this.cboFilter4.SelectedIndex, this.txtFilter4.Text, m_instrumentTradeSubscription.Instrument)); } } // add the "and" filter within the "or" filter if entries exist if (andFilter.Filters.Count > 0) { orFilter.AddFilter(andFilter); } // set the filter and restart the subscription m_instrumentTradeSubscription.SetFilter(orFilter); m_instrumentTradeSubscription.Start(); }