コード例 #1
0
        private void DigitalCommandCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            if (e.Parameter != null)
            {
                var number = Int32.Parse((string)e.Parameter);

                if (!_isInputed)
                {
                    e.CanExecute = ValidateValueRange(number);
                }
                else
                {
                    try
                    {
                        var newValue = Int32.Parse(ValueCurrent.ToString() + number);
                        e.CanExecute = ValidateValueRange(newValue);
                    }
                    catch (FormatException)
                    {
                        e.CanExecute = false;
                        return;
                    }
                }
            }
        }
コード例 #2
0
        private void DigitalCommandExecuted(object Sender, ExecutedRoutedEventArgs e)
        {
            var number = double.Parse((string)e.Parameter);

            if (!_isInputed)
            {
                ValueCurrent       = number;
                StringValueCurrent = ValueCurrent.ToString();
                _isInputed         = true;
            }
            else if (_isDotCount == 1)
            {
                StringValueCurrent = StringValueCurrent + number;
                ValueCurrent       = StringValueCurrent.ToDouble();
                _isInputed         = true;
            }
            else
            {
                var str = StringValueCurrent + number;
                ValueCurrent       = Double.Parse(str);
                StringValueCurrent = str;
                _isInputed         = true;
            }
            if (ValueCurrent < ValueMin || ValueCurrent > ValueMax)
            {
                IsValid = true;
            }
            else
            {
                IsValid = false;
            }
        }
コード例 #3
0
        private void BackspaceCommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var str = ValueCurrent.ToString();

            if (str.Length == 1)
            {
                ValueCurrent = null;
                return;
            }

            string tempStr;

            if (str.Length > 2 && str[str.Length - 2] == '.')
            {
                tempStr = str.Remove(str.Length - 2);
            }
            else
            {
                tempStr = str.Remove(str.Length - 1);
            }

            if (tempStr == "-")
            {
                ValueCurrent = null;
                return;
            }

            ValueCurrent = Int32.Parse(tempStr);
        }
コード例 #4
0
 private void MinCommandExecuted(object Sender, ExecutedRoutedEventArgs e)
 {
     if (!_isInputed)
     {
         _isInputed         = true;
         _isPositiveNum     = false;
         StringValueCurrent = "-" + StringValueCurrent;
         ValueCurrent       = StringValueCurrent.ToDouble();
     }
     _isInputed = true;
     if (ValueCurrent > 0)
     {
         ValueCurrent      -= 2 * ValueCurrent;
         StringValueCurrent = ValueCurrent.ToString();
     }
     else if (ValueCurrent == 0)
     {
         StringValueCurrent = "-0.";
         ValueCurrent       = StringValueCurrent.ToDouble();
     }
     //            ValueCurrent = ValueMin;
     //            IsValid = true;
     if ((ValueCurrent < ValueMin) || (ValueCurrent > ValueMax) || StringValueCurrent.Length > 5)
     {
         IsValid = false;
     }
     else
     {
         IsValid = true;
     }
 }
コード例 #5
0
        private void MaxCommandExecuted(object Sender, ExecutedRoutedEventArgs e)
        {
            _isInputed = true;
            if (ValueCurrent < 0)
            {
                ValueCurrent -= 2 * ValueCurrent;

                StringValueCurrent = ValueCurrent.ToString();
            }
            else if (ValueCurrent == 0)
            {
                StringValueCurrent = "0.";
            }
            _isPositiveNum = true;

            //            ValueCurrent = ValueMax;
            //            IsValid = true;
            if ((ValueCurrent < ValueMin) || (ValueCurrent > ValueMax) || StringValueCurrent.Length > 5)
            {
                IsValid = false;
            }
            else
            {
                IsValid = true;
            }
        }
コード例 #6
0
        private void BackspaceCommandCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            if (ValueCurrent == null)
            {
                return;
            }

            var str = ValueCurrent.ToString();

            if (str.Length > 0)
            {
                e.CanExecute = true;
            }
        }
コード例 #7
0
        private void DigitalCommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var number = Int32.Parse((string)e.Parameter);

            if (!_isInputed)
            {
                ValueCurrent = number;
                _isInputed   = true;
            }
            else
            {
                var str = ValueCurrent.ToString() + number;
                ValueCurrent = Int32.Parse(str);
            }
        }
コード例 #8
0
 private void NegativeCommandExecuted(object Sender, ExecutedRoutedEventArgs e)
 {
     if (!_isInputed)
     {
         _isInputed         = true;
         StringValueCurrent = "";
         ValueCurrent       = 0;
     }
     ValueCurrent -= 2 * ValueCurrent;
     if (ValueCurrent == 0)
     {
         StringValueCurrent = "";
     }
     else
     {
         StringValueCurrent = ValueCurrent.ToString();
     }
 }
コード例 #9
0
        private void DigitalCommandCanExecute(object Sender, CanExecuteRoutedEventArgs e)
        {
            if (e.Parameter != null)
            {
                double number = double.Parse((string)e.Parameter);

                if (!_isInputed)
                {
                    e.CanExecute = ValidateValueRange(number);
                }
                else
                {
                    try
                    {
                        if (_isDot)
                        {
                            if (_isDotCount == 1)
                            {
                                var str = Double.Parse(ValueCurrent.ToString() + "." + number);
                                e.CanExecute = ValidateValueRange(str);
                            }
                        }
                        else
                        {
                            var str = Double.Parse(ValueCurrent.ToString() + number);
                            e.CanExecute = ValidateValueRange(str);
                        }
                        //                        _isDot = false;
                        //                        StringValueCurrent = ValueCurrent.ToString();

                        //                        var newValue = Double.Parse(ValueCurrent.ToString() + number);
                        //                        e.CanExecute = ValidateValueRange(newValue);
                    }
                    catch (FormatException)
                    {
                        e.CanExecute = false;
                        return;
                    }
                }
            }
        }
コード例 #10
0
 private void MinCommandExecuted(object Sender, ExecutedRoutedEventArgs e)
 {
     _isInputed         = true;
     ValueCurrent       = ValueMin;
     StringValueCurrent = ValueCurrent.ToString();
 }