diff --git a/BPASmartClient.MinimalistUI/物料仓管理.lay b/BPASmartClient.MinimalistUI/物料仓管理.lay index 13e8dc88..38c15d13 100644 Binary files a/BPASmartClient.MinimalistUI/物料仓管理.lay and b/BPASmartClient.MinimalistUI/物料仓管理.lay differ diff --git a/BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs b/BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs index 41fa4eff..8f13609e 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs @@ -178,9 +178,11 @@ namespace BPASmartClient.SCADAControl.CustomerControls timer.Interval = TimeSpan.FromMilliseconds(TimeCount); timer.Tick += Timer_Tick; ; timer.Start(); - Checked += TheCheckBox_Checked; - Unchecked += TheCheckBox_Unchecked; + this.Click += SwitchButton_Click; } + + + /// /// 属性刷新事件 /// @@ -214,7 +216,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType }); this.GetType().GetProperty("IsChecked").SetValue(this,_checked); - timer.Stop(); } } } @@ -226,8 +227,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls } } - private void TheCheckBox_Unchecked(object sender, RoutedEventArgs e) + private void SwitchButton_Click(object sender,RoutedEventArgs e) { + timer.Stop(); foreach (var item in propertyBing) { //{Binding 测试设备.VAR_A_2} @@ -241,36 +243,16 @@ namespace BPASmartClient.SCADAControl.CustomerControls { object _value = b[str[1]].VarVaule; EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); - Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = "Flase",DataType = eDataType }); + Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = this.IsChecked.ToString(),DataType = eDataType }); } } } } - Config.GetInstance().RunJsScipt(UnCheckedExec); + if(this.IsChecked==true) Config.GetInstance().RunJsScipt(CheckedExec); + else Config.GetInstance().RunJsScipt(UnCheckedExec); + timer.Start(); } - private void TheCheckBox_Checked(object sender, RoutedEventArgs e) - { - foreach (var item in propertyBing) - { - //{Binding 测试设备.VAR_A_2} - string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split("."); - if (str.Length > 1) - { - if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0])) - { - Dictionary b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]]; - if (b != null && b.ContainsKey(str[1])) - { - object _value = b[str[1]].VarVaule; - EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); - Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = "True",DataType = eDataType }); - } - } - } - } - Config.GetInstance().RunJsScipt(CheckedExec); - } public string ControlType => "控件"; } diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs b/BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs index 51395665..df758606 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs @@ -40,31 +40,43 @@ namespace BPASmartClient.SCADAControl.CustomerControls Height = 30; Width = 80; FontSize = 16; - + this.KeyDown += TheTextBox_KeyDown; this.TextChanged += TheTextBox_TextChanged; } + bool isRun=false; + private void TheTextBox_KeyDown(object sender,KeyEventArgs e) + { + isRun = true; + } private void TheTextBox_TextChanged(object sender,TextChangedEventArgs e) { - foreach (var item in propertyBing) + if (isRun) { - //{Binding 测试设备.VAR_A_2} - string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split("."); - if (str.Length > 1) + timer.Stop(); + foreach (var item in propertyBing) { - if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0])) + //{Binding 测试设备.VAR_A_2} + string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split("."); + if (str.Length > 1) { - Dictionary b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]]; - if (b != null && b.ContainsKey(str[1])) + if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0])) { - object _value = b[str[1]].VarVaule; - EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); - ChangedText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = Text,DataType = eDataType }); + Dictionary b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]]; + if (b != null && b.ContainsKey(str[1])) + { + object _value = b[str[1]].VarVaule; + EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); + ChangedText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = Text,DataType = eDataType }); + } } } } + Config.GetInstance().RunJsScipt(ValueChangedExecute); + timer.Start(); + isRun=false; } - Config.GetInstance().RunJsScipt(ValueChangedExecute); + } public string ControlType => "控件"; @@ -161,7 +173,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls { object _value = b[str[1]].VarVaule; this.GetType().GetProperty(item.Key).SetValue(this,_value); - timer.Stop(); } } } diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs index 15797917..731dff92 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs @@ -130,9 +130,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls timer.Interval = TimeSpan.FromMilliseconds(TimeCount); timer.Tick += Timer_Tick; ; timer.Start(); + Click += TheToggleButton_Click; Checked += TheCheckBox_Checked; Unchecked += TheCheckBox_Unchecked; } + + + /// /// 属性刷新事件 /// @@ -166,7 +170,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType }); this.GetType().GetProperty("IsChecked").SetValue(this,_checked); - timer.Stop(); + } } } @@ -177,8 +181,10 @@ namespace BPASmartClient.SCADAControl.CustomerControls } } - private void TheCheckBox_Unchecked(object sender, RoutedEventArgs e) + + private void TheToggleButton_Click(object sender,RoutedEventArgs e) { + timer.Stop(); foreach (var item in propertyBing) { //{Binding 测试设备.VAR_A_2} @@ -192,35 +198,25 @@ namespace BPASmartClient.SCADAControl.CustomerControls { object _value = b[str[1]].VarVaule; EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); - Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = "Flase",DataType = eDataType }); + Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = "False",DataType = eDataType }); } } } } - Config.GetInstance().RunJsScipt(UnCheckedExec); + if (this.IsChecked == true) Config.GetInstance().RunJsScipt(CheckedExec); + else Config.GetInstance().RunJsScipt(UnCheckedExec); + timer.Start(); + } + + + private void TheCheckBox_Unchecked(object sender, RoutedEventArgs e) + { + } private void TheCheckBox_Checked(object sender, RoutedEventArgs e) { - foreach (var item in propertyBing) - { - //{Binding 测试设备.VAR_A_2} - string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split("."); - if (str.Length > 1) - { - if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0])) - { - Dictionary b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]]; - if (b != null && b.ContainsKey(str[1])) - { - object _value = b[str[1]].VarVaule; - EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); - Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = "True",DataType = eDataType }); - } - } - } - } - Config.GetInstance().RunJsScipt(CheckedExec); + } } }