| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 | 
							- using OpenSEMI.ClientBase;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Text.RegularExpressions;
 
- using System.Threading.Tasks;
 
- using System.Windows;
 
- using System.Windows.Controls;
 
- using System.Windows.Data;
 
- using System.Windows.Documents;
 
- using System.Windows.Input;
 
- using System.Windows.Media;
 
- using System.Windows.Media.Imaging;
 
- using System.Windows.Navigation;
 
- using System.Windows.Shapes;
 
- namespace MECF.Framework.UI.Client.CenterViews.Dialogs
 
- {
 
-     /// <summary>
 
-     /// NumberKeyboard.xaml 的交互逻辑
 
-     /// </summary>
 
-     public partial class NumberDigitKeyboard : Window
 
-     {
 
-         //public FullKeyboard()
 
-         //{
 
-         //    InitializeComponent();
 
-         //}
 
-         private String valueString;
 
-         private double _maxValue=double.MaxValue;
 
-         private double _minValue=double.MinValue;
 
-         private bool _isValidate = false;
 
-         public String ValueString
 
-         {
 
-             get
 
-             {
 
-                 ValueHandler(ref valueString);
 
-                 if (valueString == "")
 
-                 { return "0"; }
 
-                 else
 
-                 {
 
-                     return valueString;
 
-                 }
 
-             }
 
-         }
 
-         public NumberDigitKeyboard(String inputTitle, String inputvalue,Visibility btnHide=Visibility.Visible,bool isValidate=false ,double maxValue=double.MaxValue,double minValue=0)
 
-         {
 
-             InitializeComponent();
 
-             ValueHandler(ref inputvalue);
 
-             tbValue.Text = inputvalue;
 
-             valueString = inputvalue;
 
-             btnMinus.Visibility = btnHide;
 
-             btnQuotes.Visibility = btnHide;
 
-             _isValidate = isValidate;
 
-             _maxValue = maxValue;
 
-             _minValue = minValue;
 
-             if (btnHide == Visibility.Hidden) 
 
-             {
 
-                 btnCancel.SetValue(Grid.RowProperty, 3);
 
-                 btnClear.SetValue(Grid.RowProperty, 4);
 
-                 btnCancel.SetValue(Grid.ColumnProperty, 2);
 
-                 btnClear.SetValue(Grid.ColumnProperty, 0);
 
-             }
 
-         }
 
-         private void ValueHandler(ref string inputvalue)
 
-         {
 
-             if (!string.IsNullOrEmpty(inputvalue))
 
-             {
 
-                 if (Regex.Matches(inputvalue, ":").Count == 0 && inputvalue.Length > 1)
 
-                 {
 
-                     //if(inputvalue.Split('.').Length<=1)
 
-                     double outValue = 0;
 
-                     double.TryParse(inputvalue.ToString(),out outValue);
 
-                     inputvalue = outValue.ToString();
 
-                 }
 
-                     
 
-             }
 
-         }
 
-         private void Window_Deactivated(object sender, EventArgs e)
 
-         {
 
-             try
 
-             {
 
-                 this.DialogResult = false;
 
-                 this.Close();
 
-             }
 
-             catch (Exception)
 
-             {
 
-             }
 
-             // Close the window when it loses focus
 
-         }
 
-         //通过判断按钮的content属性来做对应处理,以简化大量按钮的编程
 
-         private void ButtonGrid_Click(object sender, RoutedEventArgs e)
 
-         {
 
-             Button clickedButton = (Button)e.OriginalSource;    //获取click事件触发源,即按了的按钮
 
-             if ((String)clickedButton.Content == "DEL")
 
-             {
 
-                 if (tbValue.Text.Length > 0)
 
-                 {
 
-                     tbValue.Text = tbValue.Text.Substring(0, tbValue.Text.Length - 1);
 
-                 }
 
-             }
 
-             else if ((String)clickedButton.Content == "Clear")
 
-             {
 
-                 tbValue.Text = "";
 
-             }
 
-             else if ((String)clickedButton.Content == "Cancel")
 
-             {
 
-                 this.DialogResult = false;
 
-                 this.Close();
 
-             }
 
-             else if ((String)clickedButton.Content == "OK")
 
-             {
 
-                 valueString = tbValue.Text;
 
-                 if (Regex.Matches(valueString, ":").Count > 0)
 
-                 {
 
-                     var value = Regex.IsMatch(valueString, "[0-9][0-9]:[0-9][0-9]:[0-9][0-9]");
 
-                     if (!value)
 
-                     {
 
-                         DialogBox.ShowWarning("输入格式不正确");
 
-                         return;
 
-                     }
 
-                 }
 
-                 double dtempValue;
 
-                 if (double.TryParse(tbValue.Text, out dtempValue))
 
-                 {
 
-                     if (_isValidate)
 
-                     {
 
-                         if (dtempValue > _maxValue) 
 
-                         {
 
-                             DialogBox.ShowWarning($"输入数值超过上限值.{_maxValue}");
 
-                             return;
 
-                         }
 
-                         if (dtempValue < _minValue)
 
-                         {
 
-                             DialogBox.ShowWarning($"输入数值低于下限值.{_minValue}");
 
-                             return;
 
-                         }
 
-                     }
 
-                 }
 
-                 this.DialogResult = true;
 
-                 this.Close();
 
-             }
 
-             else if ((String)clickedButton.Content == "-")
 
-             {
 
-                 if (tbValue.Text == "")
 
-                 {
 
-                     tbValue.Text += (String)clickedButton.Content;
 
-                 }
 
-                 else
 
-                 {
 
-                     if (tbValue.Text.Substring(0, 1) == "-")
 
-                     {
 
-                         tbValue.Text = tbValue.Text.Substring(1, tbValue.Text.Length - 1);
 
-                     }
 
-                     else
 
-                     {
 
-                         tbValue.Text = $"-{tbValue.Text }";
 
-                     }
 
-                 }
 
-             }
 
-             else if ((String)clickedButton.Content == "A/a")
 
-             {
 
-                 int count = ButtonGrid.Children.Count;
 
-                 for (int i = 10; i < count - 4; i++)
 
-                 {
 
-                     Button buttonTemp = ButtonGrid.Children[i] as Button;
 
-                     String contentTemp = buttonTemp.Content as String;
 
-                     buttonTemp.Content = contentTemp[0] > 90 ? contentTemp.ToUpper() : contentTemp.ToLower();
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 tbValue.Text += (String)clickedButton.Content;
 
-             }
 
-         }
 
-         private void ButtonAddSub_Click(object sender, RoutedEventArgs e)
 
-         {
 
-         }
 
-     }
 
- }
 
 
  |