From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点
---
HMI.UI/Controls/NumberPanel.xaml.cs | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 164 insertions(+), 0 deletions(-)
diff --git a/HMI.UI/Controls/NumberPanel.xaml.cs b/HMI.UI/Controls/NumberPanel.xaml.cs
new file mode 100644
index 0000000..e3eee9d
--- /dev/null
+++ b/HMI.UI/Controls/NumberPanel.xaml.cs
@@ -0,0 +1,164 @@
+锘縰sing Panuon.WPF.UI;
+using System;
+using System.ComponentModel;
+using System.Windows.Controls;
+
+namespace HMI.UI
+{
+ /// <summary>
+ /// ModalWindow.xaml 鐨勪氦浜掗�昏緫
+ /// </summary>
+ public partial class NumberPanel : WindowX
+ {
+ public NumberPanel()
+ {
+ this.DataContext = this;
+ InitializeComponent();
+ }
+
+ private bool dotEnabled = true;
+
+ public bool DotEnabled
+ {
+ get { return dotEnabled; }
+ set
+ {
+ Set(ref dotEnabled, value);
+ }
+ }
+
+
+ public double? Data { get; private set; }
+
+ private bool _isProcessing;
+
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ //Press Continue Button
+ if (DialogResult == true)
+ {
+ if (_isProcessing)
+ {
+ e.Cancel = true;
+ return;
+ }
+ try
+ {
+
+ }
+ catch
+ {
+ return;
+ }
+ finally
+ {
+ _isProcessing = false;
+ }
+ }
+ base.OnClosing(e);
+ }
+
+ private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
+ {
+ Button btn = sender as Button;
+ switch (btn.Tag.ToString())
+ {
+ case "LeftArrow":
+ break;
+ case "RightArrow":
+ break;
+ case "AC":
+ NiNumber.Text = null;
+ break;
+ case "Backspace":
+ HandleBackspace();
+ break;
+ case "Enter":
+ DialogResult = true;
+ Data = double.Parse(NiNumber.Text);
+ this.Close();
+ break;
+ case "ESC":
+ DialogResult = false;
+ this.Close();
+ break;
+ case "-":
+ var str = NiNumber.Text;
+ if (string.IsNullOrEmpty(str))
+ {
+ NiNumber.Text = "-";
+ }
+ else if (str.StartsWith("-"))
+ {
+ NiNumber.Text = str.Replace("-", "");
+ }
+ else
+ {
+ NiNumber.Text = "-" + str;
+ }
+ break;
+ case ".":
+ HandleDot();
+ break;
+ default:
+ HandleNumberInput(btn.Tag.ToString());
+ break;
+ }
+ }
+
+ private void HandleBackspace()
+ {
+ var str = NiNumber.Text?.ToString();
+ if (string.IsNullOrEmpty(str))
+ {
+ return;
+ }
+ else
+ {
+ NiNumber.Text = str.Substring(0, str.Length - 1);
+ }
+ }
+
+ private void HandleDot()
+ {
+ var str = NiNumber.Text?.ToString();
+ if (string.IsNullOrEmpty(str) || str.IndexOf(".") > 0)
+ {
+ return;
+ }
+ else
+ {
+ NiNumber.Text = str + ".";
+ }
+ }
+
+ public bool? Open(string dataStr)
+ {
+ try
+ {
+ Data = double.Parse(dataStr);
+ NiNumber.Text = dataStr;
+ }
+ catch (Exception ex)
+ {
+ Data = null;
+ NiNumber.Text = null;
+ }
+ return this.ShowDialog();
+ }
+
+ private void HandleNumberInput(string numStr)
+ {
+ var str = NiNumber.Text?.ToString();
+ if (string.IsNullOrEmpty(str))
+ {
+ NiNumber.Text = numStr;
+ }
+ else
+ {
+ NiNumber.Text = str + numStr;
+ }
+ }
+
+ }
+}
--
Gitblit v1.9.1