From c630ea117abaef569051cb37264855bb87e7cf1a Mon Sep 17 00:00:00 2001 From: fyf Date: Thu, 6 Oct 2022 15:10:11 +0800 Subject: [PATCH] gengx --- .../BPASmartClient.SCADAControl.csproj | 2 - .../CustomerControls/NewConveyorBelt.xaml.cs | 99 ---- .../CustomerControls/Silos.xaml.cs | 7 - .../CustomerControls/TheAPI.xaml.cs | 2 +- .../CustomerControls/TheDataGrid.xaml.cs | 3 +- .../CustomerControls/TheListBox.xaml.cs | 3 +- .../CustomerControls/TheMQTT.xaml.cs | 1 - .../CustomerControls/TheRedis.xaml.cs | 1 - .../CustomerControls/TheWuLiaoControl.xaml.cs | 7 - .../EnumClass/DataTypeEnum.cs | 49 ++ BeDesignerSCADA/BeDesignerSCADA.csproj | 1 + BeDesignerSCADA/Controls/CanvasPanelNew.xaml | 513 ++++++++++++++++++ .../Controls/CanvasPanelNew.xaml.cs | 513 ++++++++++++++++++ .../Controls/MainCanvasPanel.xaml.cs | 1 - BeDesignerSCADA/MainWindow.xaml.cs | 2 +- BeDesignerSCADA/ViewModel/EventModel.cs | 80 --- SmartClient.sln | 30 +- 17 files changed, 1082 insertions(+), 232 deletions(-) create mode 100644 BPASmartClient.SCADAControl/EnumClass/DataTypeEnum.cs create mode 100644 BeDesignerSCADA/Controls/CanvasPanelNew.xaml create mode 100644 BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs delete mode 100644 BeDesignerSCADA/ViewModel/EventModel.cs diff --git a/BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj b/BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj index d9582a0a..58e89f6e 100644 --- a/BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj +++ b/BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj @@ -53,8 +53,6 @@ - - diff --git a/BPASmartClient.SCADAControl/CustomerControls/NewConveyorBelt.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/NewConveyorBelt.xaml.cs index 358271db..c218e248 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/NewConveyorBelt.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/NewConveyorBelt.xaml.cs @@ -1,11 +1,4 @@ using BPASmartClient.Compiler; -using BPASmartClient.MessageCommunication; -using BPASmartClient.MessageCommunication.MsgControl; -using BPASmartClient.MessageName; -using BPASmartClient.MessageName.EnumHelp; -using BPASmartClient.MessageName.发送消息Model; -using BPASmartClient.MessageName.接收消息Model; -using BPASmartClient.MessageName.接收消息Model.滚动线; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -55,26 +48,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls StrokeDashArray = new DoubleCollection { 1.5, 1.5 }; StrokeFillBrush = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#00BEFA")); StrokeThickness = 2; - this.Loaded += NewConveyorBelt_Loaded; ; - } - - private void NewConveyorBelt_Loaded(object sender, RoutedEventArgs e) - { - EventReceiveNameList.CollectionChanged += EventNameList_CollectionChanged; - } - private void EventNameList_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) - { - if (EventReceiveNameList.Count > 0) - { - try - { - EventReceiveNameListStr = JsonConvert.SerializeObject(EventReceiveNameList); - - } - catch (Exception ex) - { - } - } } public string ControlType => "滚动线"; @@ -315,84 +288,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls } public static readonly DependencyProperty ConveyorBeltStopProperty = DependencyProperty.Register("ConveyorBeltStop", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(string.Empty)); - [Category("名称[自动生成]")] - public string EventReceiveNameListStr - { - get { return (string)GetValue(EventReceiveNameListStrProperty); } - set { SetValue(EventReceiveNameListStrProperty, value); } - } - public static readonly DependencyProperty EventReceiveNameListStrProperty = - DependencyProperty.Register("EventReceiveNameListStr",typeof(string),typeof(NewConveyorBelt),new PropertyMetadata(string.Empty,new PropertyChangedCallback(onEventReceiveNameListStrChanged))); - private static void onEventReceiveNameListStrChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as NewConveyorBelt)?.ReceiveNameRefresh(); - - [Category("消息接收名称集合")] - public ObservableCollection EventReceiveNameList - { - get { return (ObservableCollection)GetValue(EventReceiveNameListProperty); } - set { SetValue(EventReceiveNameListProperty, value); } - } - public static readonly DependencyProperty EventReceiveNameListProperty = - DependencyProperty.Register("EventReceiveNameList", typeof(ObservableCollection), typeof(NewConveyorBelt), new PropertyMetadata(new ObservableCollection(), onEventNameListChanged)); - private static void onEventNameListChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as NewConveyorBelt)?.RunNameRefresh(); #endregion #region 属性变更事件 List MessageNameL = null; public void Register() { - if (!string.IsNullOrEmpty(EventReceiveNameListStr)) - { - try - { - EventReceiveNameList = JsonConvert.DeserializeObject>(EventReceiveNameListStr); - } - catch (Exception ex) - { - - } - } - - List MessageNameNew = EventReceiveNameList?.Select(o => o.MeaageName.ToString())?.Distinct()?.ToList(); - if (MessageNameL == null || !MessageNameNew.SequenceEqual(MessageNameL)) - { - MessageNameL?.ForEach(o => Class_InnerMessageBus.GetInstance().RemoveMessage(o,"NewConveyorBeltEventHandler")); - MessageNameNew?.ForEach(x => Class_InnerMessageBus.GetInstance().ListenMessage(this,x,"NewConveyorBeltEventHandler")); - MessageNameL = MessageNameNew; - } - } - - public void NewConveyorBeltEventHandler(object sender, InnerMessageEventArgs e) - { - try - { - if (IsExecuteState = true) - { - if (e.obj_MessageObj is RunEnumModel)//接收到运行消息 - { - RunEnumModel mode = (RunEnumModel)e.obj_MessageObj; - var msg = EventReceiveNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID); - //必对消息号: - if (msg != null) - { - Direction = mode.Run == RunEnum.Run ? 1 : ((mode.Run == RunEnum.Run_Left) ? 2 : 0); - } - } - else if (e.obj_MessageObj is ConveyorBeltMessageModel)//接收到数据模型 - { - ConveyorBeltMessageModel mode = (ConveyorBeltMessageModel)e.obj_MessageObj; - var msg = EventReceiveNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID); - //必对消息号: - if (msg != null) - { - Text = mode.Title; - } - } - } - } - catch (Exception ex) - { - - } } private void Refursh() diff --git a/BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs index 7db7221d..a287087e 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs @@ -1,12 +1,5 @@ using BPASmartClient.Compiler; using BPASmartClient.DATABUS; -using BPASmartClient.MessageCommunication; -using BPASmartClient.MessageCommunication.MsgControl; -using BPASmartClient.MessageName; -using BPASmartClient.MessageName.EnumHelp; -using BPASmartClient.MessageName.发送消息Model; -using BPASmartClient.MessageName.接收消息Model; -using BPASmartClient.MessageName.接收消息Model.物料仓; using Newtonsoft.Json; using System; using System.Collections; diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheAPI.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheAPI.xaml.cs index 3dca1094..62e9c41b 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheAPI.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheAPI.xaml.cs @@ -1,8 +1,8 @@ using BPASmart.Model; using BPASmartClient.Compiler; using BPASmartClient.DATABUS; -using BPASmartClient.MessageName.EnumHelp; using BPASmartClient.SCADAControl; +using BPASmartClient.SCADAControl.EnumClass; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using StackExchange.Redis; diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs index 697c54f2..2d469710 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs @@ -1,8 +1,7 @@ using BPASmartClient.Compiler; using BPASmartClient.DATABUS; -using BPASmartClient.MessageName.EnumHelp; -using BPASmartClient.MessageName.接收消息Model.物料仓; using BPASmartClient.SCADAControl.Converters; +using BPASmartClient.SCADAControl.EnumClass; using Newtonsoft.Json; using System; using System.Collections.Generic; diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml.cs index c5e0174b..74438559 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml.cs @@ -1,8 +1,7 @@ using BPASmartClient.Compiler; using BPASmartClient.DATABUS; -using BPASmartClient.MessageName.EnumHelp; -using BPASmartClient.MessageName.接收消息Model.物料仓; using BPASmartClient.SCADAControl.Converters; +using BPASmartClient.SCADAControl.EnumClass; using Newtonsoft.Json; using System; using System.Collections.Generic; diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs index 5131a2ef..37152e1c 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs @@ -1,7 +1,6 @@ using BPASmart.Model; using BPASmartClient.Compiler; using BPASmartClient.DATABUS; -using BPASmartClient.MessageName.EnumHelp; using BPASmartClient.SCADAControl; using Newtonsoft.Json; using StackExchange.Redis; diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs index 36b073f0..a2214fe5 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs @@ -1,7 +1,6 @@ using BPASmart.Model; using BPASmartClient.Compiler; using BPASmartClient.DATABUS; -using BPASmartClient.MessageName.EnumHelp; using BPASmartClient.SCADAControl; using Newtonsoft.Json; using StackExchange.Redis; diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheWuLiaoControl.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheWuLiaoControl.xaml.cs index 74d86d4a..e83c2318 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheWuLiaoControl.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheWuLiaoControl.xaml.cs @@ -1,12 +1,5 @@ using BPASmartClient.Compiler; using BPASmartClient.DATABUS; -using BPASmartClient.MessageCommunication; -using BPASmartClient.MessageCommunication.MsgControl; -using BPASmartClient.MessageName; -using BPASmartClient.MessageName.EnumHelp; -using BPASmartClient.MessageName.发送消息Model; -using BPASmartClient.MessageName.接收消息Model; -using BPASmartClient.MessageName.接收消息Model.物料仓; using Newtonsoft.Json; using System; using System.Collections; diff --git a/BPASmartClient.SCADAControl/EnumClass/DataTypeEnum.cs b/BPASmartClient.SCADAControl/EnumClass/DataTypeEnum.cs new file mode 100644 index 00000000..71fd801b --- /dev/null +++ b/BPASmartClient.SCADAControl/EnumClass/DataTypeEnum.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.SCADAControl.EnumClass +{ + /// + /// 数据来源类型 + /// + public enum DataTypeEnum + { + /// + /// POST接口,GET接口 + /// + API接口, + /// + /// 接收主题MQTT数据 + /// + MQTT, + /// + /// Redis拉取数据 + /// + Redis, + /// + /// 本地数据推送 + /// + 本地源, + /// + /// 特定服务推送数据 + /// + 服务推送, + /// + /// 静态数据 + /// + 静态数据 + } + + /// + /// 运行状态-枚举 + /// + public enum InterfaceModeEnum + { + POST, + GET, + PUT + } +} diff --git a/BeDesignerSCADA/BeDesignerSCADA.csproj b/BeDesignerSCADA/BeDesignerSCADA.csproj index fbf1f44f..3346dd8d 100644 --- a/BeDesignerSCADA/BeDesignerSCADA.csproj +++ b/BeDesignerSCADA/BeDesignerSCADA.csproj @@ -42,6 +42,7 @@ + diff --git a/BeDesignerSCADA/Controls/CanvasPanelNew.xaml b/BeDesignerSCADA/Controls/CanvasPanelNew.xaml new file mode 100644 index 00000000..572f3300 --- /dev/null +++ b/BeDesignerSCADA/Controls/CanvasPanelNew.xaml @@ -0,0 +1,513 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 分辨率:1920×1080 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs b/BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs new file mode 100644 index 00000000..15c618da --- /dev/null +++ b/BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs @@ -0,0 +1,513 @@ +using BeDesignerSCADA.Common; +using BeDesignerSCADA.View; +using BeDesignerSCADA.ViewModel; +using BPASmart.Model; +using BPASmartClient.Compiler; +using BPASmartClient.DATABUS; +using BPASmartClient.MessageName; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BeDesignerSCADA.Controls +{ + /// + /// CanvasPanelNew.xaml 的交互逻辑 + /// + public partial class CanvasPanelNew : System.Windows.Controls.UserControl + { + /// + /// 布局文件路径 + /// + public string Path = string.Empty; + MainViewModelNew viewModel = new MainViewModelNew(); + public CanvasPanelNew(string _Path) + { + InitializeComponent(); + EditorHelper.Register(); + Path = _Path; + viewModel.LayoutsPath = Path; + this.DataContext = viewModel; + viewModel.Loaded(cav, runCanvas); + //控件加载 + Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly(); + CtlList.ItemsSource = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o => o.Name)?.ToList(); + //读取文件 + FileRead(_Path); + } + #region 位置调整 + /// + /// 左对齐 + /// + /// + /// + private void AglinLeftBtn_Click(object sender, RoutedEventArgs e) + { + cav.AlignLeft(); + } + /// + /// 底部对齐 + /// + /// + /// + private void AglinBottomBtn_Click(object sender, RoutedEventArgs e) + { + cav.AlignBottom(); + } + /// + /// 顶部对齐 + /// + /// + /// + private void AglinTopBtn_Click(object sender, RoutedEventArgs e) + { + cav.AlignTop(); + } + /// + /// 右对齐 + /// + /// + /// + private void AglinRightBtn_Click(object sender, RoutedEventArgs e) + { + cav.AlignRight(); + } + /// + /// 居中 + /// + /// + /// + private void AglinCenterBtn_Click(object sender, RoutedEventArgs e) + { + cav.AlignCenter(); + } + /// + /// 垂直分布 + /// + /// + /// + private void VerticalLayoutBtn_Click(object sender, RoutedEventArgs e) + { + cav.VertialLayout(); + } + /// + /// 水平分布 + /// + /// + /// + private void HorizontalLayoutBtn_Click(object sender, RoutedEventArgs e) + { + cav.HorizontalLayout(); + } + #endregion + + #region 其他事件操作 + /// + /// 传入变量管理器地址 + /// + /// + private void LoadBtnValue_Click(object sender, RoutedEventArgs e) + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.Filter = "变量管理器文件|*.json"; + if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + viewModel.VariablePath = ofd.FileName; + bool isSucess = DataBusModel.GetInstance().RefreshVariableManager(ofd.FileName); + System.Windows.MessageBox.Show(isSucess ? "加载成功!" : "加载失败!"); + } + } + /// + /// 运行 + /// + /// + /// + private void RunBtn_Click(object sender, RoutedEventArgs e) + { + if (sender is System.Windows.Controls.Button btn) + { + if (btn.Tag.ToString() == "运行") + { + cav.ClearSelection(); + runCanvas.Run(cav.Generator()); + } + else if (btn.Tag.ToString() == "停止") + { + runCanvas.Destory(); + } + } + } + /// + /// 模拟运行 + /// + /// + /// + private void MNRunBtn_Click(object sender, RoutedEventArgs e) + { + cav.ClearSelection(); + RunWindows runWindows = new RunWindows(); + runWindows.LoadingData(cav.Generator()); + runWindows.Show(); + } + /// + /// 加载 + /// + /// + /// + private void LoadBtn_Click(object sender, RoutedEventArgs e) + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.Filter = "布局文件|*.lay"; + if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + cav.Load(ofd.FileName); + } + + DoubleAnimation da = new DoubleAnimation(-200, 0, new Duration(TimeSpan.FromMilliseconds(250))); + da.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; + CanvasTranslate.BeginAnimation(TranslateTransform.XProperty, da); + + DoubleAnimation daop = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(250))); + daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; + cav.BeginAnimation(OpacityProperty, daop); + } + /// + /// 读取文件 + /// + /// + public void FileRead(string path) + { + try + { + if (File.Exists(path)) + { + cav.Load(path); + + DoubleAnimation da = new DoubleAnimation(-200, 0, new Duration(TimeSpan.FromMilliseconds(250))); + da.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; + CanvasTranslate.BeginAnimation(TranslateTransform.XProperty, da); + + DoubleAnimation daop = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(250))); + daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; + cav.BeginAnimation(OpacityProperty, daop); + } + } + catch (Exception ex) + { + + } + } + /// + /// 根据流加载数据 + /// + public void LoadFrameworkElement(UIElementCollection frameworks) + { + try + { + cav.Children.Clear(); + foreach (FrameworkElement element in frameworks) + { + string xamlText = XamlWriter.Save(element); + FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement; + cav.Children.Add(item); + } + cav.SelectedItems?.Clear(); + } + catch (Exception ex) + { + + throw; + } + } + /// + /// 获取所有控件 + /// + /// + public List GetChildren() + { + List frameworks = new List(); + foreach (FrameworkElement child in cav.Children) + { + string xamlText = XamlWriter.Save(child); + FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement; + frameworks.Add(item); + } + return frameworks; + } + /// + /// 保存文件 + /// + public void FileSave() + { + SaveBtn_Click(null, null); + } + /// + /// 传入变量管理器地址 + /// + /// + public void VariableManagerPath(string path) + { + try + { + viewModel.VariablePath = path; + } + catch (Exception ex) + { + + } + } + /// + /// 运行程序 + /// + public void Run() + { + try + { + cav.ClearSelection(); + runCanvas.Run(cav.Generator()); + } + catch (Exception ex) + { + + } + } + /// + /// 停止运行程序 + /// + public void Destory() + { + try + { + runCanvas.Destory(); + } + catch (Exception ex) + { + + throw; + } + } + /// + /// 保存 + /// + /// + /// + private void SaveBtn_Click(object sender, RoutedEventArgs e) + { + if (File.Exists(Path)) + { + string str = cav.Save(); + File.WriteAllText(Path, str, Encoding.Unicode); + } + else + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.Filter = "布局文件|*.lay"; + + if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + string str = cav.Save(); + File.WriteAllText(sfd.FileName, str, Encoding.Unicode); + } + } + } + /// + /// 模拟消息发送 + /// + /// + /// + private void MNBtn_Click(object sender, RoutedEventArgs e) + { + + } + #endregion + + #region 左侧控件栏移动 + /// + /// 移动到右侧 + /// + /// + /// + private void CtlList_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e) + { + if (CtlList.SelectedItem != null && e.LeftButton == MouseButtonState.Pressed) + { + DragDrop.DoDragDrop(CtlList, CtlList.SelectedItem, System.Windows.DragDropEffects.Copy); + codeEditor.Text = cav.Save(); + } + } + /// + /// 显示代码 + /// + /// + /// + private void showCode_Click(object sender, RoutedEventArgs e) + { + codeEditor.Text = cav.Save(); + } + /// + /// 编辑 + /// + /// + /// + private void ToggleButton_Click(object sender, RoutedEventArgs e) + { + try + { + if (sender is ToggleButton) + { + ToggleButton toggle = (ToggleButton)sender; + Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; + if (propertyGridCommand != null) + { + viewModel.Edit(propertyGridCommand); + } + } + } + catch (Exception ex) + { + + } + } + /// + /// 路径资源选择 + /// + /// + /// + private void LJToggleButton_Click(object sender, RoutedEventArgs e) + { + try + { + if (sender is ToggleButton) + { + ToggleButton toggle = (ToggleButton)sender; + Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; + if (propertyGridCommand != null) + { + viewModel.SelectPath(propertyGridCommand); + } + } + } + catch (Exception ex) + { + + } + } + /// + /// 选择进程 + /// + /// + /// + private void XZToggleButton_Click(object sender, RoutedEventArgs e) + { + try + { + if (sender is ToggleButton) + { + ToggleButton toggle = (ToggleButton)sender; + Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; + if (propertyGridCommand != null) + { + viewModel.SelectValuePath(propertyGridCommand); + } + } + } + catch (Exception ex) + { + + } + } + /// + /// 设置子控件模板 + /// + /// + /// + private void ChildToggleButton_Click(object sender, RoutedEventArgs e) + { + try + { + if (sender is ToggleButton) + { + ToggleButton toggle = (ToggleButton)sender; + Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; + if (propertyGridCommand != null) + { + viewModel.ChildEdit(propertyGridCommand); + } + } + } + catch (Exception ex) + { + + } + } + /// + /// 数据绑定 + /// + /// + /// + private void BingToggleButton_Click(object sender, RoutedEventArgs e) + { + try + { + if (sender is ToggleButton) + { + + ToggleButton toggle = (ToggleButton)sender; + Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; + if (propertyGridCommand != null) + { + viewModel.BingEdit(propertyGridCommand); + } + } + } + catch (Exception ex) + { + + } + } + /// + /// 清除绑定 + /// + /// + /// + private void ClearBingToggleButton_Click(object sender, RoutedEventArgs e) + { + try + { + if (sender is ToggleButton) + { + + ToggleButton toggle = (ToggleButton)sender; + Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; + if (propertyGridCommand != null) + { + viewModel.ClearBingEdit(propertyGridCommand); + } + } + } + catch (Exception ex) + { + + } + } + #endregion + } +} diff --git a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs index 512a7651..a262efad 100644 --- a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs +++ b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs @@ -1,7 +1,6 @@ using BeDesignerSCADA.Common; using BeDesignerSCADA.View; using BeDesignerSCADA.ViewModel; -using BeDesignerSCADA.ViewModel; using BPASmart.Model; using BPASmartClient.Compiler; using BPASmartClient.DATABUS; diff --git a/BeDesignerSCADA/MainWindow.xaml.cs b/BeDesignerSCADA/MainWindow.xaml.cs index 2bfaceb7..d5c5e2cb 100644 --- a/BeDesignerSCADA/MainWindow.xaml.cs +++ b/BeDesignerSCADA/MainWindow.xaml.cs @@ -34,7 +34,7 @@ namespace BeDesignerSCADA /// public partial class MainWindow : Window { - MainCanvasPanel mainCanvas = new MainCanvasPanel(""); + CanvasPanelNew mainCanvas = new CanvasPanelNew(""); public MainWindow() { InitializeComponent(); diff --git a/BeDesignerSCADA/ViewModel/EventModel.cs b/BeDesignerSCADA/ViewModel/EventModel.cs deleted file mode 100644 index 0862c837..00000000 --- a/BeDesignerSCADA/ViewModel/EventModel.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeDesignerSCADA.ViewModel -{ - /// - /// 事件Model - /// - public class EventModel - { - /// - /// 事件id - /// - public string EventId { get; set; } - /// - /// 事件名称 - /// - public string EventName { get; set; } - /// - /// 事件值 - /// - public string EventValue { get; set; } - /// - /// 特性:分组 - /// - public string Category { get; set; } - /// - /// 特性:描述 - /// - public string Description { get; set; } - /// - /// 特性:是否启用 - /// - public bool Browsable { get; set; } - - public EventModel() - { - EventId=Guid.NewGuid().ToString(); - } - } - - /// - /// 数据Model - /// - public class ALLModel - { - /// - /// 数据id - /// - public string DataId { get; set; } - /// - /// 数据名称 - /// - public string DataName { get; set; } - /// - /// 数据值 - /// - public string DataValue { get; set; } - /// - /// 特性:分组 - /// - public string Category { get; set; } - /// - /// 特性:描述 - /// - public string Description { get; set; } - /// - /// 特性:是否启用 - /// - public bool Browsable { get; set; } - - public ALLModel() - { - DataId = Guid.NewGuid().ToString(); - } - } -} diff --git a/SmartClient.sln b/SmartClient.sln index ab803643..170eba0a 100644 --- a/SmartClient.sln +++ b/SmartClient.sln @@ -136,17 +136,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WPFDemo", "WPFDemo\WPFDemo. EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0.SCADA", "0.SCADA", "{7B0175AD-BB74-4A98-B9A7-1E289032485E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MessageName", "BPASmartClient.MessageName\BPASmartClient.MessageName.csproj", "{0D769B3B-0332-4DB9-A657-B739EDB28567}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.DATABUS", "BPASmartClient.DATABUS\BPASmartClient.DATABUS.csproj", "{7C1AF86E-867C-427E-90DB-6473D88F51EB}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.SCADAControl", "BPASmartClient.SCADAControl\BPASmartClient.SCADAControl.csproj", "{6A3FC66D-0B89-45E8-B39B-9D81538002D1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "1.可视化内存数据", "1.可视化内存数据", "{7BED8969-7EA7-409C-8BBC-D2777ECDA2F1}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2.消息名称管理", "2.消息名称管理", "{28BE5235-2399-4EBA-B1F0-88E0F32AC869}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3.可视化控件集", "3.可视化控件集", "{5300552F-560D-474A-8D96-0A2747D08F64}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2.可视化控件集", "2.可视化控件集", "{5300552F-560D-474A-8D96-0A2747D08F64}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.VariableManager", "BPASmart.VariableManager\BPASmart.VariableManager.csproj", "{2C17B9A9-B27B-4F07-AFB0-0F56A975D501}" EndProject @@ -160,7 +156,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.Server", "BPASmart EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerTestDemo", "ComputerTestDemo\ComputerTestDemo.csproj", "{8940F1E2-693D-407E-AD03-722718860609}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4.可视化配置工具", "4.可视化配置工具", "{06F0B369-0483-46DD-82D2-70431FB505C1}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3.可视化配置工具", "3.可视化配置工具", "{06F0B369-0483-46DD-82D2-70431FB505C1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeDesignerSCADA", "BeDesignerSCADA\BeDesignerSCADA.csproj", "{DF8B4C38-39DE-4220-AB60-885CAE6D1E47}" EndProject @@ -1336,26 +1332,6 @@ Global {A456D582-D910-4CA2-8620-6D8F63344B47}.Release|x64.Build.0 = Release|Any CPU {A456D582-D910-4CA2-8620-6D8F63344B47}.Release|x86.ActiveCfg = Release|Any CPU {A456D582-D910-4CA2-8620-6D8F63344B47}.Release|x86.Build.0 = Release|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Debug|ARM.ActiveCfg = Debug|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Debug|ARM.Build.0 = Debug|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Debug|ARM64.Build.0 = Debug|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Debug|x64.ActiveCfg = Debug|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Debug|x64.Build.0 = Debug|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Debug|x86.ActiveCfg = Debug|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Debug|x86.Build.0 = Debug|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Release|Any CPU.Build.0 = Release|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Release|ARM.ActiveCfg = Release|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Release|ARM.Build.0 = Release|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Release|ARM64.ActiveCfg = Release|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Release|ARM64.Build.0 = Release|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Release|x64.ActiveCfg = Release|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Release|x64.Build.0 = Release|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Release|x86.ActiveCfg = Release|Any CPU - {0D769B3B-0332-4DB9-A657-B739EDB28567}.Release|x86.Build.0 = Release|Any CPU {7C1AF86E-867C-427E-90DB-6473D88F51EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7C1AF86E-867C-427E-90DB-6473D88F51EB}.Debug|Any CPU.Build.0 = Debug|Any CPU {7C1AF86E-867C-427E-90DB-6473D88F51EB}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -1758,11 +1734,9 @@ Global {FA695D7E-6F12-4483-A16D-8494609FAE68} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} {D609C4CF-FA5C-4D39-B12F-07A60FFE5E40} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} {A456D582-D910-4CA2-8620-6D8F63344B47} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} - {0D769B3B-0332-4DB9-A657-B739EDB28567} = {28BE5235-2399-4EBA-B1F0-88E0F32AC869} {7C1AF86E-867C-427E-90DB-6473D88F51EB} = {7BED8969-7EA7-409C-8BBC-D2777ECDA2F1} {6A3FC66D-0B89-45E8-B39B-9D81538002D1} = {5300552F-560D-474A-8D96-0A2747D08F64} {7BED8969-7EA7-409C-8BBC-D2777ECDA2F1} = {7B0175AD-BB74-4A98-B9A7-1E289032485E} - {28BE5235-2399-4EBA-B1F0-88E0F32AC869} = {7B0175AD-BB74-4A98-B9A7-1E289032485E} {5300552F-560D-474A-8D96-0A2747D08F64} = {7B0175AD-BB74-4A98-B9A7-1E289032485E} {2C17B9A9-B27B-4F07-AFB0-0F56A975D501} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086} {00C5B45D-9799-43F1-B07B-9F638AA9FF72} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086}