Example #1
0
/// <summary>
/// Get a pair of MobiusDataType objects of the specified type that can be used
/// for comparison to the specified text value. This is useful for comparing
/// decimal numbers for equality.
/// </summary>
/// <param name="type"></param>
/// <param name="textValue"></param>
/// <param name="mdtLow"></param>
/// <param name="mdtHigh"></param>

        public static void GetFuzzyEqualityComparators(
            MetaColumnType type,
            string textValue,
            out MobiusDataType mdtLow,
            out MobiusDataType mdtHigh)
        {
            try
            {
                mdtLow  = MobiusDataType.New(type, textValue);
                mdtHigh = MobiusDataType.New(type, textValue);

                if (MetaColumn.IsDecimalMetaColumnType(type))
                {
                    double e = GetEpsilon(textValue);
                    mdtLow.NumericValue  -= e;
                    mdtHigh.NumericValue += e;
                }
            }
            catch (Exception ex)
            {
                mdtLow  = MobiusDataType.New(type);
                mdtHigh = MobiusDataType.New(type);
            }

            return;
        }
Example #2
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;
        }
Example #3
0
        public void Setup(ColumnInfo colInfo)
        {
            InSetup = true;

            ColInfo = colInfo;             // save ref to colInfo
            QueryColumn qc = colInfo.Qc;

            Stats = colInfo.Rfld.GetStats();
            RangeFilter.Properties.Minimum = 0;
            RangeFilter.Properties.Maximum = Stats.DistinctValueList.Count - 1;

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

            TrackBarRange tbr = new TrackBarRange(0, Stats.DistinctValueList.Count - 1);

            RangeFilter.Value = tbr;

            if (psc != null && psc.OpEnum == CompareOp.Between && Stats.DistinctValueList.Count > 0)             // setup prev value
            {
                MetaColumnType type    = ColInfo.Mc.DataType;
                MobiusDataType lowVal  = MobiusDataType.New(type, psc.Value);
                MobiusDataType highVal = MobiusDataType.New(type, psc.Value2);
                if (MetaColumn.IsDecimalMetaColumnType(type))
                {                 // adjust decimal comparison values by an epsilon
                    double e = MobiusDataType.GetEpsilon(Stats.MaxValue.FormattedText);
                    lowVal.NumericValue  += e;
                    highVal.NumericValue -= e;
                }

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

                    if (mdt.CompareTo(lowVal) <= 0 || Lex.Eq(fTxt, psc.Value))
                    {
                        lowPos = i1;
                    }
                    else
                    {
                        break;
                    }
                }

                int highPos = -1;
                for (int i1 = Stats.DistinctValueList.Count - 1; i1 >= 0; i1--)
                {
                    MobiusDataType mdt  = Stats.DistinctValueList[i1];
                    string         fTxt = mdt.FormattedText;

                    if (mdt.CompareTo(highVal) >= 0 || Lex.Eq(fTxt, psc.Value2))
                    {
                        highPos = i1;
                    }
                    else
                    {
                        break;
                    }
                }

                if (lowPos >= 0 && highPos >= 0)
                {
                    tbr = new TrackBarRange(lowPos, highPos);
                    RangeFilter.Value = tbr;
                }
            }

            UpdateLabels();

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