@@ -28,7 +28,7 @@ namespace BPASmartClient.DATABUS | |||||
/// <summary> | /// <summary> | ||||
/// 设备数据 | /// 设备数据 | ||||
/// </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 | #endregion | ||||
} | } | ||||
} | } |
@@ -9,9 +9,16 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<None Remove="Fonts\ds-digib.ttf" /> | <None Remove="Fonts\ds-digib.ttf" /> | ||||
<None Remove="Images\2609.png" /> | |||||
<None Remove="Images\biogebj.png" /> | <None Remove="Images\biogebj.png" /> | ||||
<None Remove="Images\bj.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\databj.png" /> | ||||
<None Remove="Images\nbbj.png" /> | |||||
<None Remove="Images\redis.png" /> | <None Remove="Images\redis.png" /> | ||||
<None Remove="Images\redisrun.png" /> | <None Remove="Images\redisrun.png" /> | ||||
<None Remove="Images\redisstop.png" /> | <None Remove="Images\redisstop.png" /> | ||||
@@ -50,22 +57,69 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<Resource Include="Fonts\ds-digib.ttf" /> | <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"> | <Resource Include="Images\redis.png"> | ||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||
</Resource> | </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> | </ItemGroup> | ||||
</Project> | </Project> |
@@ -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; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -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(); | |||||
} | |||||
} | |||||
} |
@@ -45,10 +45,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
Height = 30; | Height = 30; | ||||
CurValue = 0.01; | CurValue = 0.01; | ||||
Digits = 2; | Digits = 2; | ||||
FontSize = 16; | |||||
VerticalContentAlignment = VerticalAlignment.Center; | 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.TextChanged += NumberBox_TextChanged; | ||||
this.PreviewKeyDown += NumberBox_KeyDown; | this.PreviewKeyDown += NumberBox_KeyDown; | ||||
@@ -74,7 +74,6 @@ | |||||
<StackPanel Tag="ControlEvent" HorizontalAlignment="Right" Orientation="Vertical" Grid.Row="1" VerticalAlignment="Bottom" > | <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,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> | <Image Margin="20,10,0,10" Tag="停止出料" Source="/BPASmartClient.SCADAControl;component/Images/退出.png" Cursor="Hand" Width="24" ToolTip="停止出料"></Image> | ||||
</StackPanel> | </StackPanel> | ||||
</Grid> | </Grid> | ||||
</UserControl> | </UserControl> |
@@ -15,6 +15,7 @@ using System.Collections.ObjectModel; | |||||
using System.ComponentModel; | using System.ComponentModel; | ||||
using System.Drawing.Design; | using System.Drawing.Design; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Reflection; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using System.Windows; | using System.Windows; | ||||
@@ -319,14 +320,14 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
#region 数据绑定模块 | #region 数据绑定模块 | ||||
public event EventHandler PropertyChange; //声明一个事件 | 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("数据绑定-数据来源")] | [Category("数据绑定-数据来源")] | ||||
public int TimeCount | public int TimeCount | ||||
{ | { | ||||
@@ -335,30 +336,30 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
} | } | ||||
public static readonly DependencyProperty TimeCountProperty = | public static readonly DependencyProperty TimeCountProperty = | ||||
DependencyProperty.Register("TimeCount",typeof(int),typeof(Silos),new PropertyMetadata(5)); | 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("数据绑定")] | [Category("数据绑定")] | ||||
public string FDataSouce | public string FDataSouce | ||||
@@ -404,11 +405,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
} | } | ||||
public static readonly DependencyProperty GenerateDataProperty = | public static readonly DependencyProperty GenerateDataProperty = | ||||
DependencyProperty.Register("GenerateData",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty)); | DependencyProperty.Register("GenerateData",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty)); | ||||
public void RefreshData() | |||||
{ | |||||
; | |||||
} | |||||
#endregion | #endregion | ||||
#region 发送事件名称集合 | #region 发送事件名称集合 | ||||
@@ -510,6 +506,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
#region 运行事件 | #region 运行事件 | ||||
DispatcherTimer timer = new DispatcherTimer(); | DispatcherTimer timer = new DispatcherTimer(); | ||||
Dictionary<string, string> propertyBing = new Dictionary<string,string>(); | |||||
List<string> MessageNameL = null; | List<string> MessageNameL = null; | ||||
public void Register() | public void Register() | ||||
{ | { | ||||
@@ -545,7 +542,17 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
MessageNameL = MessageNameNew; | 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.Tick += Timer_Tick; ; | ||||
timer.Start(); | timer.Start(); | ||||
@@ -555,11 +562,21 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
{ | { | ||||
try | 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); | |||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -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() | |||||
{ | |||||
} | |||||
} | |||||
} |
@@ -1,8 +1,10 @@ | |||||
using BPASmartClient.Compiler; | using BPASmartClient.Compiler; | ||||
using BPASmartClient.DATABUS; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.ComponentModel; | using System.ComponentModel; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Reflection; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using System.Windows; | using System.Windows; | ||||
@@ -14,6 +16,7 @@ using System.Windows.Media; | |||||
using System.Windows.Media.Imaging; | using System.Windows.Media.Imaging; | ||||
using System.Windows.Navigation; | using System.Windows.Navigation; | ||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
using System.Windows.Threading; | |||||
namespace BPASmartClient.SCADAControl.CustomerControls | namespace BPASmartClient.SCADAControl.CustomerControls | ||||
{ | { | ||||
@@ -23,15 +26,15 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
/// </summary> | /// </summary> | ||||
public partial class TheButton : Button, IExecutable | public partial class TheButton : Button, IExecutable | ||||
{ | { | ||||
public event EventHandler PropertyChange; //声明一个事件 | |||||
public TheButton() | public TheButton() | ||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
ResourceDictionary languageResDic = new ResourceDictionary(); | |||||
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute); | |||||
this.Resources.MergedDictionaries.Add(languageResDic); | |||||
Content = "按钮"; | Content = "按钮"; | ||||
Width = 80; | Width = 80; | ||||
Height = 30; | Height = 30; | ||||
Style = Application.Current.Resources["DesignButton"] as Style;//FindResource("DesignButton") as Style; | |||||
} | } | ||||
public string ControlType => "控件"; | public string ControlType => "控件"; | ||||
@@ -60,17 +63,82 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
public static readonly DependencyProperty ClickExecProperty = | public static readonly DependencyProperty ClickExecProperty = | ||||
DependencyProperty.Register("ClickExec", typeof(string), typeof(TheButton), new PropertyMetadata(string.Empty)); | 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> | ||||
/// 注册需要处理的事件 | |||||
/// 运行事件 | |||||
/// </summary> | /// </summary> | ||||
public void Register() | public void Register() | ||||
{ | { | ||||
this.Click += MyButton_Click; | 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 | |||||
} | } | ||||
} | } |
@@ -6,4 +6,11 @@ | |||||
xmlns:local="clr-namespace:BPASmartClient.SCADAControl.CustomerControls" | xmlns:local="clr-namespace:BPASmartClient.SCADAControl.CustomerControls" | ||||
mc:Ignorable="d" | mc:Ignorable="d" | ||||
d:DesignHeight="450" d:DesignWidth="800"> | 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> | </CheckBox> |
@@ -28,9 +28,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
public TheComboBox() | public TheComboBox() | ||||
{ | { | ||||
InitializeComponent(); | 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" }; | ItemsString = new ItemsList() { "AA", "BB" }; | ||||
Style = Application.Current.Resources["DesignComboBox"] as Style; | |||||
//Style = Application.Current.Resources["DesignComboBox"] as Style; | |||||
Width = 80; | Width = 80; | ||||
Height = 30; | Height = 30; | ||||
Focusable = false; | Focusable = false; | ||||
@@ -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() | |||||
{ | |||||
} | |||||
} | |||||
} |
@@ -27,6 +27,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
public TheGroupBox() | public TheGroupBox() | ||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
ResourceDictionary languageResDic = new ResourceDictionary(); | |||||
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute); | |||||
this.Resources.MergedDictionaries.Add(languageResDic); | |||||
Width = 150; | Width = 150; | ||||
Height = 150; | Height = 150; | ||||
Header = "分组"; | Header = "分组"; | ||||
@@ -18,16 +18,24 @@ using System.Windows.Shapes; | |||||
namespace BPASmartClient.SCADAControl.CustomerControls | namespace BPASmartClient.SCADAControl.CustomerControls | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// TheTextBlock.xaml 的交互逻辑 | |||||
/// 正常进度条 | |||||
/// </summary> | /// </summary> | ||||
public partial class TheTextBlock : TextBlock, IExecutable | |||||
public class TheProgressBar:ProgressBar, IExecutable, IDisposable | |||||
{ | { | ||||
public event EventHandler PropertyChange; //声明一个事件 | 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 => "控件"; | public string ControlType => "控件"; | ||||
@@ -42,12 +50,18 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
if (IsExecuteState) | if (IsExecuteState) | ||||
{ | { | ||||
Register(); | Register(); | ||||
Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
public void Register() | public void Register() | ||||
{ | { | ||||
} | |||||
public void Dispose() | |||||
{ | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -23,6 +23,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
public TheRadioButton() | 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, "单选按钮"); | SetCurrentValue(ContentProperty, "单选按钮"); | ||||
} | } | ||||
static TheRadioButton() | static TheRadioButton() | ||||
@@ -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() | |||||
{ | |||||
} | |||||
} | |||||
} |
@@ -131,7 +131,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
Direction = 2; | Direction = 2; | ||||
} | } | ||||
} | } | ||||
timer.Interval = TimeSpan.FromSeconds(Interval); | |||||
timer.Interval = TimeSpan.FromSeconds(TimeCount); | |||||
timer.Tick += Timer_Tick; | timer.Tick += Timer_Tick; | ||||
timer.Start(); | timer.Start(); | ||||
@@ -159,13 +159,18 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
} | } | ||||
if (Direction == 1) //定时读取数据 | 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 属性 | #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("值设定")] | [Category("值设定")] | ||||
public int Direction | public int Direction | ||||
{ | { | ||||
@@ -251,14 +245,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
#region 数据绑定模块 | #region 数据绑定模块 | ||||
public event EventHandler PropertyChange; //声明一个事件 | public event EventHandler PropertyChange; //声明一个事件 | ||||
[Category("数据绑定-数据来源")] | [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 | public int TimeCount | ||||
{ | { | ||||
get { return (int)GetValue(TimeCountProperty); } | get { return (int)GetValue(TimeCountProperty); } | ||||
@@ -282,15 +268,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
} | } | ||||
public static readonly DependencyProperty DeviceNameProperty = | public static readonly DependencyProperty DeviceNameProperty = | ||||
DependencyProperty.Register("DeviceName",typeof(string),typeof(TheRedis),new PropertyMetadata(string.Empty)); | 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("数据绑定")] | [Category("数据绑定")] | ||||
public string FDataSouce | public string FDataSouce | ||||
{ | { | ||||
@@ -335,10 +312,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
} | } | ||||
public static readonly DependencyProperty GenerateDataProperty = | public static readonly DependencyProperty GenerateDataProperty = | ||||
DependencyProperty.Register("GenerateData",typeof(string),typeof(TheRedis),new PropertyMetadata(string.Empty)); | DependencyProperty.Register("GenerateData",typeof(string),typeof(TheRedis),new PropertyMetadata(string.Empty)); | ||||
public void RefreshData() | |||||
{ | |||||
; | |||||
} | |||||
#endregion | #endregion | ||||
@@ -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 | |||||
} | |||||
} |
@@ -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> |
@@ -1,8 +1,11 @@ | |||||
using BPASmartClient.Compiler; | using BPASmartClient.Compiler; | ||||
using BPASmartClient.DATABUS; | |||||
using BPASmartClient.SCADAControl; | using BPASmartClient.SCADAControl; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.ComponentModel; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Reflection; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using System.Windows; | using System.Windows; | ||||
@@ -14,12 +17,13 @@ using System.Windows.Media; | |||||
using System.Windows.Media.Imaging; | using System.Windows.Media.Imaging; | ||||
using System.Windows.Navigation; | using System.Windows.Navigation; | ||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
using System.Windows.Threading; | |||||
namespace BPASmartClient.SCADAControl.CustomerControls | namespace BPASmartClient.SCADAControl.CustomerControls | ||||
{ | { | ||||
public class TheTextBox : TextBox, IExecutable | public class TheTextBox : TextBox, IExecutable | ||||
{ | { | ||||
public event EventHandler PropertyChange; //声明一个事件 | |||||
static TheTextBox() | static TheTextBox() | ||||
{ | { | ||||
@@ -28,10 +32,20 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
public TheTextBox() | 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"; | 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 => "控件"; | 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() | 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 | |||||
} | } | ||||
} | } |
@@ -30,6 +30,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
public WaveProgressBar() | 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); | Loaded += (s, e) => UpdateWave(Value); | ||||
SetCurrentValue(WidthProperty, 200d); | SetCurrentValue(WidthProperty, 200d); | ||||
SetCurrentValue(HeightProperty, 200d); | SetCurrentValue(HeightProperty, 200d); | ||||