Пример #1
0
        void TextField_FocusChanged(object sender, bool newValue)
        {
            if (!newValue)
            {
                inputMachine.EndCurrentInput();

                if (inputMachine.Text.Contains('-'))
                {
                    inputMachine.Text = "-" + inputMachine.Text.Replace("-", "");
                }

                if (inputMachine.Text.Length != 0)
                {
                    try
                    {
                        Value = Convert.ToInt32(inputMachine.Text);
                    }
                    catch (OverflowException)
                    {
                        Value = 0;
                    }
                }
                else
                {
                    Value = 0;
                }
            }

            inputMachine.Text = Value.ToString();
        }
Пример #2
0
 void FileSelector_FocusChanged(object sender, bool newValue)
 {
     if (!newValue)
     {
         inputMachine.EndCurrentInput();
     }
 }
Пример #3
0
 void TextField_FocusChanged(object sender, bool newValue)
 {
     if (!newValue)
     {
         inputMachine.EndCurrentInput();
     }
 }
Пример #4
0
 void Console_FocusChanged(object sender, bool newValue)
 {
     if (!newValue)
     {
         inputMachine.EndCurrentInput();
     }
 }
Пример #5
0
        void TextField_FocusChanged(object sender, bool newValue)
        {
            if (!newValue)
            {
                inputMachine.EndCurrentInput();

                if (inputMachine.Text.Contains('.'))
                {
                    int firstIndex = inputMachine.Text.IndexOf('.');
                    inputMachine.Text = inputMachine.Text.Replace(".", "").Insert(firstIndex, ".");
                }

                if (inputMachine.Text.Contains('-'))
                {
                    inputMachine.Text = "-" + inputMachine.Text.Replace("-", "");
                }

                if (inputMachine.Text.Length != 0)
                {
                    try
                    {
                        Value = Convert.ToDouble(inputMachine.Text);
                    }
                    catch (OverflowException)
                    {
                        Value = 0;
                    }
                    catch (FormatException)
                    {
                        try
                        {
                            Value = Convert.ToDouble(inputMachine.Text.Replace('.', ','));
                        }
                        catch (OverflowException)
                        {
                            Value = 0;
                        }
                    }
                }
                else
                {
                    Value = 0;
                }
            }

            inputMachine.Text = Value.ToString().Replace(',', '.');
        }