public void SetValue(double value, SourceValue sourceValue = SourceValue.Digits, TimeResult timeValueResult = TimeResult.None, TimeResult timeShortestVariant = TimeResult.None)
        {
            string strFormat = string.Empty;

            if (timeShortestVariant > TimeResult.None && timeShortestVariant < timeValueResult)
            {
                var ts = new TimeShort(value, this.timeResultStrings, sourceValue);
                strFormat = ts.GetShortestString(timeShortestVariant);
            }
            else
            {
                strFormat = this.GetFormatTimeString(this.timeResultStrings, timeValueResult);
            }

            switch (sourceValue)
            {
            case SourceValue.Seconds:
                this.SetText(new TimeFormatFromSeconds()
                {
                    format = strFormat
                }.GetValue(value));
                return;

            case SourceValue.Milliseconds:
                this.SetText(new TimeFormatFromMilliseconds()
                {
                    format = strFormat
                }.GetValue(value));
                return;
            }
        }
Example #2
0
        public void SetValue(double value, SourceValue sourceValue = SourceValue.Digits, TimeResult timeValueResult = TimeResult.None, TimeResult timeShortestVariant = TimeResult.None)
        {
            var currentData = new ValueData()
            {
                value               = value,
                sourceValue         = sourceValue,
                timeValueResult     = timeValueResult,
                timeShortestVariant = timeShortestVariant,
                isCreated           = true,
            };

            if (this.lastValueData == currentData)
            {
                return;
            }
            this.lastValueData = currentData;
            this.lastText      = null;

            string strFormat;

            if (timeShortestVariant > TimeResult.None && timeShortestVariant < timeValueResult)
            {
                var ts = new TimeShort(value, this.timeResultStrings, sourceValue);
                strFormat = ts.GetShortestString(timeShortestVariant);
            }
            else
            {
                strFormat = this.GetFormatTimeString(this.timeResultStrings, timeValueResult);
            }

            switch (sourceValue)
            {
            case SourceValue.Digits:
                this.SetText(value.ToString());
                return;

            case SourceValue.Seconds:
                this.SetText(new TimeFormatFromSeconds()
                {
                    format = strFormat
                }.GetValue(value));
                return;

            case SourceValue.Milliseconds:
                this.SetText(new TimeFormatFromMilliseconds()
                {
                    format = strFormat
                }.GetValue(value));
                return;
            }
        }