Ejemplo n.º 1
0
        // Updates TextBox.Text with the formatted Value
        private void UpdateTextToValue()
        {
            if (m_textBox != null)
            {
                string newText = string.Empty;

                var value = Value;
                if (!double.IsNaN(value))
                {
                    // Rounding the value here will prevent displaying digits caused by floating point imprecision.
                    var roundedValue = m_displayRounder.RoundDouble(value);
                    newText = NumberFormatter.FormatDouble(roundedValue);
                }

                m_textBox.Text = newText;

                try
                {
                    m_textUpdating = true;
                    SetCurrentValue(TextProperty, newText);
                }
                finally
                {
                    m_textUpdating = false;
                }
            }
        }
Ejemplo n.º 2
0
        // Updates TextBox.Text with the formatted Value
        private void UpdateTextToValue()
        {
            if (m_textBox != null)
            {
                string newText = "";

                var value = Value;
                if (!double.IsNaN(value))
                {
                    // Rounding the value here will prevent displaying digits caused by floating point imprecision.
                    var roundedValue = m_displayRounder.RoundDouble(value);

                    if (ApiInformation.IsTypePresent(NumberFormatter.GetType().FullName))
                    {
                        newText = NumberFormatter.FormatDouble(roundedValue);
                    }
                    else
                    {
                        newText = roundedValue.ToString($"0." + new string('#', (int)m_displayRounder.SignificantDigits), CultureInfo.CurrentCulture);
                    }
                }

                m_textBox.Text = newText;

                try
                {
                    m_textUpdating = true;
                    Text           = newText;

                    // This places the caret at the end of the text.
                    m_textBox.Select(newText.Length, 0);
                }
                finally
                {
                    m_textUpdating = false;
                }
            }
        }
Ejemplo n.º 3
0
        // Updates TextBox.Text with the formatted Value
        private void UpdateTextToValue()
        {
            if (m_textBox != null)
            {
                var newText = string.Empty;

                var value = Value;
                if (!double.IsNaN(value))
                {
                    // Rounding the value here will prevent displaying digits caused by floating point imprecision.
                    newText = NumberFormatter.FormatDouble(Math.Round(value, 12));
                }

                m_textBox.Text = newText;

                m_textUpdating = true;
                Text           = newText;

                // This places the caret at the end of the text.
                m_textBox.Select(newText.Length, 0);
                m_textUpdating = false;
            }
        }