Example #1
0
        public void Setup(ColumnInfo colInfo)
        {
            MobiusDataType mdtLow, mdtHigh;

            InSetup = true;

            ColInfo = colInfo;             // save ref to colInfo

            Stats = colInfo.Rfld.GetStats();
            ItemFilter.Properties.Minimum = 0;
            ItemFilter.Properties.Maximum = Stats.DistinctValueList.Count + 2 - 1;                // (All) on left, (Blanks) on right

            ParsedSingleCriteria psc = MqlUtil.ParseSingleCriteria(ColInfo.Qc.SecondaryCriteria); // parse criteria

            ItemFilter.Value = 0;
            ValueLabel.Text  = "(All)";
            if (psc != null && psc.OpEnum == CompareOp.Eq && Stats.DistinctValueList.Count > 0)
            {
                MetaColumnType type    = ColInfo.Mc.DataType;
                MobiusDataType lowVal  = MobiusDataType.New(type, psc.Value);
                MobiusDataType highVal = MobiusDataType.New(type, psc.Value);

                if (MetaColumn.IsDecimalMetaColumnType(type))
                {                 // adjust decimal comparison values by an epsilon
                    double e = MobiusDataType.GetEpsilon(Stats.MaxValue.FormattedText);
                    lowVal.NumericValue  -= e;
                    highVal.NumericValue += e;
                }

                for (int i1 = 0; i1 < Stats.DistinctValueList.Count; i1++)
                {
                    MobiusDataType mdt  = Stats.DistinctValueList[i1];
                    string         fTxt = mdt.FormattedText;

                    if (Lex.Eq(psc.Value, fTxt) ||
                        (mdt.CompareTo(lowVal) >= 0 && mdt.CompareTo(highVal) <= 0))
                    {
                        ItemFilter.Value = i1 + 1;
                        ValueLabel.Text  = Stats.DistinctValueList[i1].FormattedText;
                        break;
                    }
                }
            }

            else if (psc != null && psc.OpEnum == CompareOp.IsNull)             // (Blanks)
            {
                ItemFilter.Value = Stats.DistinctValueList.Count + 1;
                ValueLabel.Text  = "(Blanks)";
            }

            ItemFilter.Focus();
            InSetup = false;
            return;
        }