瀏覽代碼

更新可视化控件集和属性绑定逻辑

master
fyf 2 年之前
父節點
當前提交
29d1449673
共有 29 個文件被更改,包括 2121 次插入184 次删除
  1. +1
    -1
      BPASmartClient.DATABUS/Class_DataBus.cs
  2. +67
    -13
      BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj
  3. +173
    -0
      BPASmartClient.SCADAControl/Converters/RelayCommandSimple.cs
  4. +59
    -0
      BPASmartClient.SCADAControl/Converters/Style3ArcConverter.cs
  5. +6
    -3
      BPASmartClient.SCADAControl/CustomerControls/NumberBox.cs
  6. +0
    -1
      BPASmartClient.SCADAControl/CustomerControls/Silos.xaml
  7. +58
    -41
      BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs
  8. +63
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheBlueProgressBar.cs
  9. +75
    -7
      BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs
  10. +7
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheCheckBox.xaml
  11. +5
    -2
      BPASmartClient.SCADAControl/CustomerControls/TheComboBox.xaml.cs
  12. +64
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheGreenProgressBar.cs
  13. +3
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheGroupBox.xaml.cs
  14. +19
    -5
      BPASmartClient.SCADAControl/CustomerControls/TheProgressBar.cs
  15. +3
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheRadioButton.cs
  16. +64
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheRedProgressBar.cs
  17. +12
    -39
      BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs
  18. +128
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs
  19. +0
    -9
      BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.xaml
  20. +88
    -4
      BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs
  21. +3
    -0
      BPASmartClient.SCADAControl/CustomerControls/WaveProgressBar.cs
  22. 二進制
     
  23. 二進制
     
  24. 二進制
     
  25. 二進制
     
  26. 二進制
     
  27. 二進制
     
  28. 二進制
     
  29. +1223
    -59
      BPASmartClient.SCADAControl/Themes/Generic.xaml

+ 1
- 1
BPASmartClient.DATABUS/Class_DataBus.cs 查看文件

@@ -28,7 +28,7 @@ namespace BPASmartClient.DATABUS
/// <summary>
/// 设备数据
/// </summary>
public ConcurrentDictionary<string, object> Dic_DeviceData = new ConcurrentDictionary<string, object>(); //原始目标链表
public ConcurrentDictionary<string, Dictionary<string,object>> Dic_DeviceData = new ConcurrentDictionary<string,Dictionary<string,object>>(); //原始目标链表
#endregion
}
}

+ 67
- 13
BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj 查看文件

@@ -9,9 +9,16 @@

<ItemGroup>
<None Remove="Fonts\ds-digib.ttf" />
<None Remove="Images\2609.png" />
<None Remove="Images\biogebj.png" />
<None Remove="Images\bj.png" />
<None Remove="Images\btn_normal.png" />
<None Remove="Images\button1.png" />
<None Remove="Images\button2.png" />
<None Remove="Images\Cb_Checked.png" />
<None Remove="Images\Cb_HalfChecked.png" />
<None Remove="Images\databj.png" />
<None Remove="Images\nbbj.png" />
<None Remove="Images\redis.png" />
<None Remove="Images\redisrun.png" />
<None Remove="Images\redisstop.png" />
@@ -50,22 +57,69 @@

<ItemGroup>
<Resource Include="Fonts\ds-digib.ttf" />
<Resource Include="Images\bj.png" />
<Resource Include="Images\databj.png" />
<Resource Include="Images\2609.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\bj.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\btn_normal.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Cb_Checked.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Cb_HalfChecked.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\databj.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\nbbj.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\redis.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\redisrun.png" />
<Resource Include="Images\redisstop.png" />
<Resource Include="Images\State0.png" />
<Resource Include="Images\State1.png" />
<Resource Include="Images\State11.png" />
<Resource Include="Images\State2.png" />
<Resource Include="Images\timericon.png" />
<Resource Include="Images\借出.png" />
<Resource Include="Images\光柱.png" />
<Resource Include="Images\biogebj.png" />
<Resource Include="Images\退出.png" />
<Resource Include="Images\redisrun.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\redisstop.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\State0.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\State1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\State11.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\State2.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\timericon.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\借出.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\光柱.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\biogebj.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\button1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\button2.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\退出.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>

</Project>

+ 173
- 0
BPASmartClient.SCADAControl/Converters/RelayCommandSimple.cs 查看文件

@@ -0,0 +1,173 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace BPASmartClient.SCADAControl.Converters
{
public class RelayCommandSimple :ICommand, IDisposable
{
private Action _executeCallback;
private Func<bool> _canExecute;

public RelayCommandSimple(Action execute)
{
_executeCallback = execute;
}

public RelayCommandSimple(Action execute,Func<bool> canExecute)
: this(execute)
{
_canExecute = canExecute;
}

public bool CanExecute(object parameter)
{
if (_canExecute == null)
return true;
return _canExecute();
}

public void Execute(object parameter)
{
_executeCallback();
}

public void Dispose()
{
_executeCallback = null;
_canExecute = null;
}

public event EventHandler CanExecuteChanged
{
add
{
if (this._canExecute != null)
{
CommandManager.RequerySuggested += value;
}
}
remove
{
if (this._canExecute != null)
{
CommandManager.RequerySuggested -= value;
}
}
}
}

public class RelayCommandSimple<TParam> :ICommand
{
private Action<TParam> _executeCallback;
private Func<TParam,bool> _canExecute;

public RelayCommandSimple(Action<TParam> execute)
{
if (execute == null)
throw new ArgumentNullException("execute");

_executeCallback = execute;
}

public RelayCommandSimple(Action<TParam> execute,Func<TParam,bool> canExecute)
: this(execute)
{
_canExecute = canExecute;
}

public bool CanExecute(object parameter)
{
if (_canExecute == null)
return true;

if (parameter != null && parameter is TParam)
{
return _canExecute((TParam)parameter);
}
return true;
}

public void Execute(object parameter)
{
if (parameter != null && parameter is TParam)
{
_executeCallback((TParam)parameter);
}
}

public event EventHandler CanExecuteChanged
{
add
{
if (this._canExecute != null)
{
CommandManager.RequerySuggested += value;
}
}
remove
{
if (this._canExecute != null)
{
CommandManager.RequerySuggested -= value;
}
}
}
}


public class RelayCommandSimpleNull<T> :ICommand
{
private Action<T> _executeCallback;
private Func<T,bool> _canExecute;

public RelayCommandSimpleNull(Action<T> execute)
{
if (execute == null)
throw new ArgumentNullException("execute");

_executeCallback = execute;
}

public RelayCommandSimpleNull(Action<T> execute,Func<T,bool> canExecute)
: this(execute)
{
_canExecute = canExecute;
}

public bool CanExecute(object parameter)
{
if (_canExecute == null)
return true;


return _canExecute((T)parameter);

}

public void Execute(object parameter)
{
_executeCallback((T)parameter);
}

public event EventHandler CanExecuteChanged
{
add
{
if (this._canExecute != null)
{
CommandManager.RequerySuggested += value;
}
}
remove
{
if (this._canExecute != null)
{
CommandManager.RequerySuggested -= value;
}
}
}
}
}

+ 59
- 0
BPASmartClient.SCADAControl/Converters/Style3ArcConverter.cs 查看文件

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;
namespace BPASmartClient.SCADAControl.Converters
{
public class Style3ArcConverter :IMultiValueConverter
{
public object Convert(object[] values,Type targetType,object parameter,CultureInfo culture)
{
double value = (double)values[0];
double thickness = (double)values[1];

double radius = 40;

double 周长 = Math.PI * (2 * radius - thickness) / thickness;

double showPrecent = value / 100 * 周长;

var converter = TypeDescriptor.GetConverter(typeof(DoubleCollection));

return (DoubleCollection)converter.ConvertFrom($"{showPrecent} {周长}");
}

public object[] ConvertBack(object value,Type[] targetTypes,object parameter,CultureInfo culture)
{
throw new NotImplementedException();
}
}

public class Style3DashConverter :IValueConverter
{
public object Convert(object value,Type targetType,object parameter,CultureInfo culture)
{
double v = (double)value;

if (v == 0)
{
return PenLineCap.Flat;
}
else
{
return PenLineCap.Round;
}

}

public object ConvertBack(object value,Type targetType,object parameter,CultureInfo culture)
{
throw new NotImplementedException();
}
}

}

+ 6
- 3
BPASmartClient.SCADAControl/CustomerControls/NumberBox.cs 查看文件

@@ -45,10 +45,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls
Height = 30;
CurValue = 0.01;
Digits = 2;
FontSize = 16;
VerticalContentAlignment = VerticalAlignment.Center;
Style = Application.Current.Resources["DesignNumberBox"] as Style;//FindResource("DesignNumberBox") as Style;
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);

//Style = Application.Current.Resources["DesignNumberBox"] as Style;//FindResource("DesignNumberBox") as Style;

this.TextChanged += NumberBox_TextChanged;
this.PreviewKeyDown += NumberBox_KeyDown;


+ 0
- 1
BPASmartClient.SCADAControl/CustomerControls/Silos.xaml 查看文件

@@ -74,7 +74,6 @@
<StackPanel Tag="ControlEvent" HorizontalAlignment="Right" Orientation="Vertical" Grid.Row="1" VerticalAlignment="Bottom" >
<Image Margin="20,10,0,0" Tag="出料" Source="/BPASmartClient.SCADAControl;component/Images/借出.png" Cursor="Hand" ToolTip="出料" Width="24" ></Image>
<Image Margin="20,10,0,10" Tag="停止出料" Source="/BPASmartClient.SCADAControl;component/Images/退出.png" Cursor="Hand" Width="24" ToolTip="停止出料"></Image>
</StackPanel>
</Grid>
</UserControl>

+ 58
- 41
BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs 查看文件

@@ -15,6 +15,7 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@@ -319,14 +320,14 @@ namespace BPASmartClient.SCADAControl.CustomerControls

#region 数据绑定模块
public event EventHandler PropertyChange; //声明一个事件
[Category("数据绑定-数据来源")]
public DataTypeEnum DataSouceType
{
get { return (DataTypeEnum)GetValue(DataSouceTypeProperty); }
set { SetValue(DataSouceTypeProperty,value); }
}
public static readonly DependencyProperty DataSouceTypeProperty =
DependencyProperty.Register("DataSouceType",typeof(DataTypeEnum),typeof(Silos),new PropertyMetadata(DataTypeEnum.静态数据));
//[Category("数据绑定-数据来源")]
//public DataTypeEnum DataSouceType
//{
// get { return (DataTypeEnum)GetValue(DataSouceTypeProperty); }
// set { SetValue(DataSouceTypeProperty,value); }
//}
//public static readonly DependencyProperty DataSouceTypeProperty =
// DependencyProperty.Register("DataSouceType",typeof(DataTypeEnum),typeof(Silos),new PropertyMetadata(DataTypeEnum.静态数据));
[Category("数据绑定-数据来源")]
public int TimeCount
{
@@ -335,30 +336,30 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(Silos),new PropertyMetadata(5));
[Category("数据绑定-数据来源")]
public string DataSouceInformation
{
get { return (string)GetValue(DataSouceInformationProperty); }
set { SetValue(DataSouceInformationProperty,value); }
}
public static readonly DependencyProperty DataSouceInformationProperty =
DependencyProperty.Register("DataSouceInformation",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
[Category("数据绑定-数据来源")]
public string DeviceName
{
get { return (string)GetValue(DeviceNameProperty); }
set { SetValue(DeviceNameProperty,value); }
}
public static readonly DependencyProperty DeviceNameProperty =
DependencyProperty.Register("DeviceName",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
[Category("数据绑定-数据来源")]
public string DeviceValuleName
{
get { return (string)GetValue(DeviceValuleNameProperty); }
set { SetValue(DeviceValuleNameProperty,value); }
}
public static readonly DependencyProperty DeviceValuleNameProperty =
DependencyProperty.Register("DeviceValuleName",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
//[Category("数据绑定-数据来源")]
//public string DataSouceInformation
//{
// get { return (string)GetValue(DataSouceInformationProperty); }
// set { SetValue(DataSouceInformationProperty,value); }
//}
//public static readonly DependencyProperty DataSouceInformationProperty =
// DependencyProperty.Register("DataSouceInformation",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
//[Category("数据绑定-数据来源")]
//public string DeviceName
//{
// get { return (string)GetValue(DeviceNameProperty); }
// set { SetValue(DeviceNameProperty,value); }
//}
//public static readonly DependencyProperty DeviceNameProperty =
// DependencyProperty.Register("DeviceName",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
//[Category("数据绑定-数据来源")]
//public string DeviceValuleName
//{
// get { return (string)GetValue(DeviceValuleNameProperty); }
// set { SetValue(DeviceValuleNameProperty,value); }
//}
//public static readonly DependencyProperty DeviceValuleNameProperty =
// DependencyProperty.Register("DeviceValuleName",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));

[Category("数据绑定")]
public string FDataSouce
@@ -404,11 +405,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
public static readonly DependencyProperty GenerateDataProperty =
DependencyProperty.Register("GenerateData",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
public void RefreshData()
{
;
}

#endregion

#region 发送事件名称集合
@@ -510,6 +506,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls

#region 运行事件
DispatcherTimer timer = new DispatcherTimer();
Dictionary<string, string> propertyBing = new Dictionary<string,string>();
List<string> MessageNameL = null;
public void Register()
{
@@ -545,7 +542,17 @@ namespace BPASmartClient.SCADAControl.CustomerControls
MessageNameL = MessageNameNew;
}

timer.Interval = TimeSpan.FromMilliseconds(50);
PropertyInfo[] propertyInfos = this.GetType().GetProperties();
foreach (PropertyInfo propertyInfo in propertyInfos)
{
var propName = propertyInfo?.GetValue(this,null);
if (propName is string && propName != null && propName.ToString().Contains("Binding ") && propName.ToString().Contains("."))
{
propertyBing[propertyInfo.Name] = propName.ToString();
}
}

timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();

@@ -555,11 +562,21 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
try
{
if (!string.IsNullOrEmpty(DeviceName) && !string.IsNullOrEmpty(DeviceValuleName))
foreach (var item in propertyBing)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(DeviceValuleName))
//{Binding 测试设备.VAR_A_2}
string[] str= item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
textBlockTitle.Text= Class_DataBus.GetInstance().Dic_DeviceData[DeviceValuleName].ToString();
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
{
Dictionary<string,object> b= Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b!=null && b.ContainsKey(str[1]))
{
object _value = b[str[1]];
this.GetType().GetProperty(item.Key).SetValue(this,_value);
}
}
}
}
}


+ 63
- 0
BPASmartClient.SCADAControl/CustomerControls/TheBlueProgressBar.cs 查看文件

@@ -0,0 +1,63 @@
using BPASmartClient.Compiler;
using BPASmartClient.SCADAControl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 BPASmartClient.SCADAControl.CustomerControls
{
public class TheBlueProgressBar :ProgressBar, IExecutable, IDisposable
{
public event EventHandler PropertyChange; //声明一个事件

public TheBlueProgressBar()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
SetCurrentValue(WidthProperty,100d);
SetCurrentValue(HeightProperty,100d);
SetCurrentValue(ValueProperty,50d);
}
static TheBlueProgressBar()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TheBlueProgressBar),new FrameworkPropertyMetadata(typeof(TheBlueProgressBar)));
}

public string ControlType => "控件";

private bool isExecuteState;
public bool IsExecuteState
{
get { return isExecuteState; }
set
{
isExecuteState = value;
if (IsExecuteState)
{
Register();
Style = null;
}
}
}

public void Register()
{

}

public void Dispose()
{
}
}
}

+ 75
- 7
BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs 查看文件

@@ -1,8 +1,10 @@
using BPASmartClient.Compiler;
using BPASmartClient.DATABUS;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@@ -14,6 +16,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace BPASmartClient.SCADAControl.CustomerControls
{
@@ -23,15 +26,15 @@ namespace BPASmartClient.SCADAControl.CustomerControls
/// </summary>
public partial class TheButton : Button, IExecutable
{
public event EventHandler PropertyChange; //声明一个事件

public TheButton()
{
InitializeComponent();
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
Content = "按钮";
Width = 80;
Height = 30;
Style = Application.Current.Resources["DesignButton"] as Style;//FindResource("DesignButton") as Style;
}

public string ControlType => "控件";
@@ -60,17 +63,82 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public static readonly DependencyProperty ClickExecProperty =
DependencyProperty.Register("ClickExec", typeof(string), typeof(TheButton), new PropertyMetadata(string.Empty));


private void MyButton_Click(object sender, RoutedEventArgs e)
{
Config.GetInstance().RunJsScipt(ClickExec);
}

#region 数据绑定模块
[Category("数据绑定-数据来源")]
public int TimeCount
{
get { return (int)GetValue(TimeCountProperty); }
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheButton),new PropertyMetadata(5));
public event EventHandler PropertyChange; //声明一个事件
/// <summary>
/// 属性刷新器
/// </summary>
DispatcherTimer timer = new DispatcherTimer();
/// <summary>
/// 属性绑定变量集合
/// </summary>
Dictionary<string,string> propertyBing = new Dictionary<string,string>();
/// <summary>
/// 注册需要处理的事件
/// 运行事件
/// </summary>
public void Register()
{
this.Click += MyButton_Click;
}
PropertyInfo[] propertyInfos = this.GetType().GetProperties();
foreach (PropertyInfo propertyInfo in propertyInfos)
{
var propName = propertyInfo?.GetValue(this,null);
if (propName is string && propName != null && propName.ToString().Contains("Binding ") && propName.ToString().Contains("."))
{
propertyBing[propertyInfo.Name] = propName.ToString();
}
}

private void MyButton_Click(object sender, RoutedEventArgs e)
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
}
/// <summary>
/// 属性刷新事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Timer_Tick(object? sender,EventArgs e)
{
Config.GetInstance().RunJsScipt(ClickExec);
try
{
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,object> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b != null && b.ContainsKey(str[1]))
{
object _value = b[str[1]];
this.GetType().GetProperty(item.Key).SetValue(this,_value);
}
}
}
}
}
catch (Exception ex)
{

}
}
#endregion
}
}

+ 7
- 0
BPASmartClient.SCADAControl/CustomerControls/TheCheckBox.xaml 查看文件

@@ -6,4 +6,11 @@
xmlns:local="clr-namespace:BPASmartClient.SCADAControl.CustomerControls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<CheckBox.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</CheckBox.Resources>
</CheckBox>

+ 5
- 2
BPASmartClient.SCADAControl/CustomerControls/TheComboBox.xaml.cs 查看文件

@@ -28,9 +28,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public TheComboBox()
{
InitializeComponent();
VerticalContentAlignment = VerticalAlignment.Center;
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
//VerticalContentAlignment = VerticalAlignment.Center;
ItemsString = new ItemsList() { "AA", "BB" };
Style = Application.Current.Resources["DesignComboBox"] as Style;
//Style = Application.Current.Resources["DesignComboBox"] as Style;
Width = 80;
Height = 30;
Focusable = false;


+ 64
- 0
BPASmartClient.SCADAControl/CustomerControls/TheGreenProgressBar.cs 查看文件

@@ -0,0 +1,64 @@
using BPASmartClient.Compiler;
using BPASmartClient.SCADAControl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 BPASmartClient.SCADAControl.CustomerControls
{
public class TheGreenProgressBar :ProgressBar, IExecutable, IDisposable
{
public event EventHandler PropertyChange; //声明一个事件

public TheGreenProgressBar()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
SetCurrentValue(WidthProperty,100d);
SetCurrentValue(HeightProperty,100d);
SetCurrentValue(ValueProperty,50d);
}
static TheGreenProgressBar()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TheGreenProgressBar),new FrameworkPropertyMetadata(typeof(TheGreenProgressBar)));
}

public string ControlType => "控件";

private bool isExecuteState;
public bool IsExecuteState
{
get { return isExecuteState; }
set
{
isExecuteState = value;
if (IsExecuteState)
{
Register();
Style = null;
}
}
}

public void Register()
{

}

public void Dispose()
{
}
}
}

+ 3
- 0
BPASmartClient.SCADAControl/CustomerControls/TheGroupBox.xaml.cs 查看文件

@@ -27,6 +27,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public TheGroupBox()
{
InitializeComponent();
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
Width = 150;
Height = 150;
Header = "分组";


BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.xaml.cs → BPASmartClient.SCADAControl/CustomerControls/TheProgressBar.cs 查看文件

@@ -18,16 +18,24 @@ using System.Windows.Shapes;
namespace BPASmartClient.SCADAControl.CustomerControls
{
/// <summary>
/// TheTextBlock.xaml 的交互逻辑
/// 正常进度条
/// </summary>
public partial class TheTextBlock : TextBlock, IExecutable
public class TheProgressBar:ProgressBar, IExecutable, IDisposable
{
public event EventHandler PropertyChange; //声明一个事件

public TheTextBlock()
public TheProgressBar()
{
InitializeComponent();
Text = "文本块";
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
SetCurrentValue(WidthProperty,200d);
SetCurrentValue(HeightProperty,16d);
SetCurrentValue(ValueProperty,50d);
}
static TheProgressBar()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TheProgressBar),new FrameworkPropertyMetadata(typeof(TheProgressBar)));
}

public string ControlType => "控件";
@@ -42,12 +50,18 @@ namespace BPASmartClient.SCADAControl.CustomerControls
if (IsExecuteState)
{
Register();
Style = null;
}
}
}

public void Register()
{

}

public void Dispose()
{
}
}
}

+ 3
- 0
BPASmartClient.SCADAControl/CustomerControls/TheRadioButton.cs 查看文件

@@ -23,6 +23,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls

public TheRadioButton()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
SetCurrentValue(ContentProperty, "单选按钮");
}
static TheRadioButton()


+ 64
- 0
BPASmartClient.SCADAControl/CustomerControls/TheRedProgressBar.cs 查看文件

@@ -0,0 +1,64 @@
using BPASmartClient.Compiler;
using BPASmartClient.SCADAControl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 BPASmartClient.SCADAControl.CustomerControls
{
public class TheRedProgressBar :ProgressBar, IExecutable, IDisposable
{
public event EventHandler PropertyChange; //声明一个事件

public TheRedProgressBar()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
SetCurrentValue(WidthProperty,100d);
SetCurrentValue(HeightProperty,100d);
SetCurrentValue(ValueProperty,50d);
}
static TheRedProgressBar()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TheRedProgressBar),new FrameworkPropertyMetadata(typeof(TheRedProgressBar)));
}

public string ControlType => "控件";

private bool isExecuteState;
public bool IsExecuteState
{
get { return isExecuteState; }
set
{
isExecuteState = value;
if (IsExecuteState)
{
Register();
Style = null;
}
}
}

public void Register()
{

}

public void Dispose()
{
}
}
}

+ 12
- 39
BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs 查看文件

@@ -131,7 +131,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
Direction = 2;
}
}
timer.Interval = TimeSpan.FromSeconds(Interval);
timer.Interval = TimeSpan.FromSeconds(TimeCount);
timer.Tick += Timer_Tick;
timer.Start();

@@ -159,13 +159,18 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
if (Direction == 1) //定时读取数据
{
RedisValue obj = fRedisClient.RedisGet(DeviceName);
FDataSouce = obj.ToString();
List<ReeisDataModel> str = JsonConvert.DeserializeObject<List<ReeisDataModel>>(FDataSouce);
str?.ForEach(par =>
if (!string.IsNullOrEmpty(DeviceName))
{
Class_DataBus.GetInstance().Dic_DeviceData[par.VarName] = par.VarVaule;
});
RedisValue obj = fRedisClient.RedisGet(DeviceName);
FDataSouce = obj.ToString();
List<ReeisDataModel> str = JsonConvert.DeserializeObject<List<ReeisDataModel>>(FDataSouce);
Dictionary<string,object> keys=new Dictionary<string, object>();
str?.ForEach(par =>
{
keys[par.VarName] = par.VarVaule;
});
Class_DataBus.GetInstance().Dic_DeviceData[DeviceName] = keys;
}
}
}

@@ -178,17 +183,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}

#region 属性
/// <summary>
/// 时间间隔
/// </summary>
[Category("值设定")]
public int Interval
{
get { return (int)GetValue(IntervalProperty); }
set { SetValue(IntervalProperty,value); }
}
public static readonly DependencyProperty IntervalProperty =
DependencyProperty.Register("Interval",typeof(int),typeof(TheRedis),new PropertyMetadata(1));
[Category("值设定")]
public int Direction
{
@@ -251,14 +245,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
#region 数据绑定模块
public event EventHandler PropertyChange; //声明一个事件
[Category("数据绑定-数据来源")]
public DataTypeEnum DataSouceType
{
get { return (DataTypeEnum)GetValue(DataSouceTypeProperty); }
set { SetValue(DataSouceTypeProperty,value); }
}
public static readonly DependencyProperty DataSouceTypeProperty =
DependencyProperty.Register("DataSouceType",typeof(DataTypeEnum),typeof(TheRedis),new PropertyMetadata(DataTypeEnum.静态数据));
[Category("数据绑定-数据来源")]
public int TimeCount
{
get { return (int)GetValue(TimeCountProperty); }
@@ -282,15 +268,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
public static readonly DependencyProperty DeviceNameProperty =
DependencyProperty.Register("DeviceName",typeof(string),typeof(TheRedis),new PropertyMetadata(string.Empty));
[Category("数据绑定-数据来源")]
public string DeviceValuleName
{
get { return (string)GetValue(DeviceValuleNameProperty); }
set { SetValue(DeviceValuleNameProperty,value); }
}
public static readonly DependencyProperty DeviceValuleNameProperty =
DependencyProperty.Register("DeviceValuleName",typeof(string),typeof(TheRedis),new PropertyMetadata(string.Empty));

[Category("数据绑定")]
public string FDataSouce
{
@@ -335,10 +312,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
public static readonly DependencyProperty GenerateDataProperty =
DependencyProperty.Register("GenerateData",typeof(string),typeof(TheRedis),new PropertyMetadata(string.Empty));
public void RefreshData()
{
;
}
#endregion




+ 128
- 0
BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs 查看文件

@@ -0,0 +1,128 @@
using BPASmartClient.Compiler;
using BPASmartClient.DATABUS;
using BPASmartClient.SCADAControl;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
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;
using System.Windows.Threading;


namespace BPASmartClient.SCADAControl.CustomerControls
{
public class TheTextBlock :TextBlock, IExecutable
{
static TheTextBlock()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TheTextBlock),new FrameworkPropertyMetadata(typeof(TheTextBlock)));
}
public TheTextBlock()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
}

public string ControlType => "控件";

private bool isExecuteState;
public bool IsExecuteState
{
get { return isExecuteState; }
set
{
isExecuteState = value;
if (IsExecuteState)
{
Register();
}
}
}

#region 数据绑定模块
[Category("数据绑定-数据来源")]
public int TimeCount
{
get { return (int)GetValue(TimeCountProperty); }
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheTextBlock),new PropertyMetadata(5));
public event EventHandler PropertyChange; //声明一个事件
/// <summary>
/// 属性刷新器
/// </summary>
DispatcherTimer timer = new DispatcherTimer();
/// <summary>
/// 属性绑定变量集合
/// </summary>
Dictionary<string,string> propertyBing = new Dictionary<string,string>();
/// <summary>
/// 运行事件
/// </summary>
public void Register()
{
PropertyInfo[] propertyInfos = this.GetType().GetProperties();
foreach (PropertyInfo propertyInfo in propertyInfos)
{
var propName = propertyInfo?.GetValue(this,null);
if (propName is string && propName != null && propName.ToString().Contains("Binding ") && propName.ToString().Contains("."))
{
string va = string.Empty;
if (propName.ToString().StartsWith("{}")) va = propName.ToString().Replace("{}","");
else va = propName.ToString();
propertyBing[propertyInfo.Name] = va;
}
}

timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
}
/// <summary>
/// 属性刷新事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Timer_Tick(object? sender,EventArgs e)
{
try
{
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,object> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b != null && b.ContainsKey(str[1]))
{
object _value = b[str[1]];
this.GetType().GetProperty(item.Key).SetValue(this,_value);
}
}
}
}
}
catch (Exception ex)
{

}
}
#endregion
}
}

+ 0
- 9
BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.xaml 查看文件

@@ -1,9 +0,0 @@
<TextBlock x:Class="BPASmartClient.SCADAControl.CustomerControls.TheTextBlock"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.SCADAControl.CustomerControls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
</TextBlock>

+ 88
- 4
BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs 查看文件

@@ -1,8 +1,11 @@
using BPASmartClient.Compiler;
using BPASmartClient.DATABUS;
using BPASmartClient.SCADAControl;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@@ -14,12 +17,13 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace BPASmartClient.SCADAControl.CustomerControls
{
public class TheTextBox : TextBox, IExecutable
{
public event EventHandler PropertyChange; //声明一个事件

static TheTextBox()
{
@@ -28,10 +32,20 @@ namespace BPASmartClient.SCADAControl.CustomerControls

public TheTextBox()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
Text = "0.01";
VerticalContentAlignment = VerticalAlignment.Center;
Style = Application.Current.Resources["DesignTheTextBox"] as Style;//FindResource("DesignTheTextBox") as Style;
Focusable = false;
//VerticalContentAlignment = VerticalAlignment.Center;
//Style = Application.Current.Resources["DesignTheTextBox"] as Style;//FindResource("DesignTheTextBox") as Style;
//Focusable = false;
Height = 30;
Width = 80;
FontSize = 16;
//HorizontalAlignment = HorizontalAlignment.Left;
//VerticalAlignment = VerticalAlignment.Center;
//Foreground = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#a2c2e8"));
//BorderThickness=new Thickness(1);
}
public string ControlType => "控件";

@@ -52,8 +66,78 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
}



#region 数据绑定模块
[Category("数据绑定-数据来源")]
public int TimeCount
{
get { return (int)GetValue(TimeCountProperty); }
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheTextBox),new PropertyMetadata(5));
public event EventHandler PropertyChange; //声明一个事件
/// <summary>
/// 属性刷新器
/// </summary>
DispatcherTimer timer = new DispatcherTimer();
/// <summary>
/// 属性绑定变量集合
/// </summary>
Dictionary<string,string> propertyBing = new Dictionary<string,string>();
/// <summary>
/// 运行事件
/// </summary>
public void Register()
{
PropertyInfo[] propertyInfos = this.GetType().GetProperties();
foreach (PropertyInfo propertyInfo in propertyInfos)
{
var propName = propertyInfo?.GetValue(this,null);
if (propName is string && propName != null && propName.ToString().Contains("Binding ") && propName.ToString().Contains("."))
{
propertyBing[propertyInfo.Name] = propName.ToString();
}
}

timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
}
/// <summary>
/// 属性刷新事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Timer_Tick(object? sender,EventArgs e)
{
try
{
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,object> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b != null && b.ContainsKey(str[1]))
{
object _value = b[str[1]];
this.GetType().GetProperty(item.Key).SetValue(this,_value);
}
}
}
}
}
catch (Exception ex)
{

}
}
#endregion

}
}

+ 3
- 0
BPASmartClient.SCADAControl/CustomerControls/WaveProgressBar.cs 查看文件

@@ -30,6 +30,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls

public WaveProgressBar()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
Loaded += (s, e) => UpdateWave(Value);
SetCurrentValue(WidthProperty, 200d);
SetCurrentValue(HeightProperty, 200d);


二進制
查看文件


二進制
查看文件


二進制
查看文件


二進制
查看文件


二進制
查看文件


二進制
查看文件


二進制
查看文件


+ 1223
- 59
BPASmartClient.SCADAControl/Themes/Generic.xaml
文件差異過大導致無法顯示
查看文件


Loading…
取消
儲存