Bläddra i källkod

更新

master
fyf 2 år sedan
förälder
incheckning
b1c68d6d7f
4 ändrade filer med 53 tillägg och 64 borttagningar
  1. Binär
     
  2. +10
    -28
      BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs
  3. +24
    -13
      BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs
  4. +19
    -23
      BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs

Binär
Visa fil


+ 10
- 28
BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs Visa fil

@@ -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;
}



/// <summary>
/// 属性刷新事件
/// </summary>
@@ -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<string,DeviceDataModel> 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 => "控件";

}


+ 24
- 13
BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs Visa fil

@@ -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<string,DeviceDataModel> 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<string,DeviceDataModel> 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();
}
}
}


+ 19
- 23
BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs Visa fil

@@ -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;
}



/// <summary>
/// 属性刷新事件
/// </summary>
@@ -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<string,DeviceDataModel> 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);

}
}
}

Laddar…
Avbryt
Spara