private static void ExecuteTextBoxClickCommand(object sender, ExecutedRoutedEventArgs e)
        {
            TextBox textBox = null;

            if (Equipment.MainEquipment.Instance.UseVirtualKeyboard == false)
            {
                if (e.OriginalSource == null) return;
                if ((e.OriginalSource is TextBox) == false) return;
                textBox = e.OriginalSource as TextBox;
                textBox.Focus();
                return;
            }

            if ((e.OriginalSource is TextBox) == false) return;
            if (e.OriginalSource == null) return;

            textBox = e.OriginalSource as TextBox;
            var textBoxPosition = textBox.PointToScreen(new Point(textBox.ActualWidth / 2, textBox.ActualHeight / 2));
            var topControl = GetTopLevelControl(textBox);

            bool isString;
            var rangeRule = GetNumberRangeRule(textBox, out isString);

            if (isString)
            {
                var keyboard = new GUI.KeyboardWindow();

                //keyboard.Left = textBoxPosition.X;
                //keyboard.Top = textBoxPosition.Y;
                keyboard.InputString = textBox.Text;

                if (topControl is Window)
                    keyboard.Owner = (Window)topControl;

                if (keyboard.ShowDialog() == true)
                {
                    textBox.Text = keyboard.InputString;
                    try
                    {
                        var bx = textBox.GetBindingExpression(TextBox.TextProperty);
                        bx.UpdateSource();
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine(ex.ToString());
                    }
                }
            }
            else
            {
                textBox.PointToScreen(ZeroPoint);

                var keyboard = new GUI.NumericKeyboardWindow();
                keyboard.Min = rangeRule.Range.Min;
                keyboard.Max = rangeRule.Range.Max;
                keyboard.NumType = rangeRule.NumberType;
                //keyboard.Left = textBoxPosition.X;
                //keyboard.Top = textBoxPosition.Y;
                keyboard.InputValueString = textBox.Text;

                if (topControl is Window)
                    keyboard.Owner = (Window)topControl;

                if (keyboard.ShowDialog() == true)
                {                    
                    textBox.Text = keyboard.Value.ToString();
                    try
                    {
                        var bx = textBox.GetBindingExpression(TextBox.TextProperty);
                        bx.UpdateSource();
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine(ex.ToString());
                    }
                }
            }            
        }
        private static void ExecutePasswordBoxClickCommand(object sender, ExecutedRoutedEventArgs e)
        {
            PasswordBox textBox = null;

            if (Equipment.MainEquipment.Instance.UseVirtualKeyboard == false)
            {
                if (e.OriginalSource == null) return;
                if ((e.OriginalSource is PasswordBox) == false) return;
                textBox = e.OriginalSource as PasswordBox;
                textBox.Focus();
                return;
            }

            if ((e.OriginalSource is PasswordBox) == false) return;
            if (e.OriginalSource == null) return;

            textBox = e.OriginalSource as PasswordBox;
            var textBoxPosition = textBox.PointToScreen(new Point(textBox.ActualWidth / 2, textBox.ActualHeight / 2));
            var topControl = GetTopLevelControl(textBox);

            var keyboard = new GUI.KeyboardWindow();

            keyboard.Left = textBoxPosition.X;
            keyboard.Top = textBoxPosition.Y;
            keyboard.PasswordMode = true;

            if (topControl is Window)
                keyboard.Owner = (Window)topControl;

            if (keyboard.ShowDialog() == true)
            {
                textBox.Password = keyboard.InputString;
            }            
        }