|
- using BPASmartClient.Compiler;
-
- using BPASmartClient.SCADAControl;
- using Newtonsoft.Json;
- 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);
- this.Loaded += TheTextBlock_Loaded;
- }
-
- private void TheTextBlock_Loaded(object sender, RoutedEventArgs e)
- {
- if (this.ActualWidth <= 0)
- {
- Text = "文本";
- Height = 30;
- Width = 80;
- FontSize = 16;
- }
- }
-
- public string ControlType => "控件";
-
- private bool isExecuteState;
- public bool IsExecuteState
- {
- get { return isExecuteState; }
- set
- {
- isExecuteState = value;
- if (IsExecuteState)
- {
- Register();
- }
- }
- }
-
- #region 数据绑定模块
- /// <summary>
- /// 数据模板
- /// </summary>
- private Dictionary<string, object> DataModel
- {
- get { return (Dictionary<string, object>)GetValue(DataModelProperty); }
- set { SetValue(DataModelProperty, value); }
- }
- private static readonly DependencyProperty DataModelProperty =
- DependencyProperty.Register("DataModel", typeof(Dictionary<string, object>), typeof(TheTextBlock), new PropertyMetadata(new Dictionary<string, object>()));
-
- public event EventHandler PropertyChange; //声明一个事件
- /// <summary>
- /// 运行事件
- /// </summary>
- public void Register()
- {
- Class_DataBus.GetInstance().BindingAction += BindingActionHeader;
- }
-
- public void BindingActionHeader(object sender, EventArgs e)
- {
- this.Dispatcher.Invoke((Action)(() =>
- {
- DataModel = Class_DataBus.GetInstance().Dic_RedisDataBinding;
- PropertyChange?.Invoke(this, EventArgs.Empty);
- }));
- }
- #endregion
- }
- }
|