From 7227da7af8828f13ffba1f5d9b8dd525de5cae08 Mon Sep 17 00:00:00 2001 From: fyf Date: Tue, 27 Sep 2022 18:05:07 +0800 Subject: [PATCH] 11 --- .../Servers/ServiceCenter.cs | 18 ++- BPASmart.Model/用户/UserManager.cs | 2 +- .../CustomerControls/TheButton.xaml.cs | 33 +++++ BeDesignerSCADA/Controls/MainCanvasPanel.xaml | 122 ++++++++++-------- .../Controls/MainCanvasPanel.xaml.cs | 122 ++++-------------- BeDesignerSCADA/ViewModel/MainViewModelNew.cs | 14 ++ 6 files changed, 151 insertions(+), 160 deletions(-) diff --git a/BPASmart.ConfigurationSoftware/Servers/ServiceCenter.cs b/BPASmart.ConfigurationSoftware/Servers/ServiceCenter.cs index e28f285b..61a8ce69 100644 --- a/BPASmart.ConfigurationSoftware/Servers/ServiceCenter.cs +++ b/BPASmart.ConfigurationSoftware/Servers/ServiceCenter.cs @@ -178,11 +178,19 @@ namespace BPASmart.ConfigurationSoftware /// private void RegisterOpenFileType() { - string icoFile = System.Windows.Forms.Application.StartupPath + $"\\Images\\fyf.ico"; - string DirectoryPath = $"{Json.Data.ProjectPath}\\Images"; - Directory.CreateDirectory(DirectoryPath); - File.Copy(icoFile, $"{DirectoryPath}\\fyf.ico"); - SystemHelper.GetInstance.RegisterOpenFileType("project", "HBL", System.Windows.Forms.Application.ExecutablePath, $"{DirectoryPath}\\fyf.ico"); + try + { + string icoFile = System.Windows.Forms.Application.StartupPath + $"\\Images\\fyf.ico"; + string DirectoryPath = $"{Json.Data.ProjectPath}\\Images"; + Directory.CreateDirectory(DirectoryPath); + File.Copy(icoFile, $"{DirectoryPath}\\fyf.ico"); + SystemHelper.GetInstance.RegisterOpenFileType("project", "HBL", System.Windows.Forms.Application.ExecutablePath, $"{DirectoryPath}\\fyf.ico"); + } + catch (Exception ex) + { + + } + } /// diff --git a/BPASmart.Model/用户/UserManager.cs b/BPASmart.Model/用户/UserManager.cs index a114ea6a..c2efa2e0 100644 --- a/BPASmart.Model/用户/UserManager.cs +++ b/BPASmart.Model/用户/UserManager.cs @@ -1,4 +1,4 @@ -using BPASmart.Model.用户; +using BPASmart.Model; using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs index 9de9eb43..3b08cec5 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs @@ -3,6 +3,8 @@ using BPASmartClient.DATABUS; using System; using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics; +using System.IO; using System.Linq; using System.Reflection; using System.Text; @@ -74,6 +76,27 @@ namespace BPASmartClient.SCADAControl.CustomerControls private void MyButton_Click(object sender, RoutedEventArgs e) { Config.GetInstance().RunJsScipt(ClickExec); + try + { + if (!string.IsNullOrEmpty(StartPath) && StartPath.Contains(".exe")) + { + string path = $"{System.AppDomain.CurrentDomain.BaseDirectory}{StartPath}"; + if (File.Exists(path)) + { + ProcessStartInfo info = new ProcessStartInfo(); + info.FileName = path; + info.Arguments = ""; + //info.WindowStyle = ProcessWindowStyle.Minimized; + Process pro = Process.Start(info); + pro.WaitForExit(); + } + } + } + catch (Exception ex) + { + + } + } #region 数据绑定模块 @@ -90,6 +113,16 @@ namespace BPASmartClient.SCADAControl.CustomerControls private static readonly DependencyProperty DataModelProperty = DependencyProperty.Register("DataModel", typeof(Dictionary), typeof(TheButton), new PropertyMetadata(new Dictionary())); /// + /// 启动路径 + /// + public string StartPath + { + get { return (string)GetValue(StartPathProperty); } + set { SetValue(StartPathProperty, value); } + } + public static readonly DependencyProperty StartPathProperty = + DependencyProperty.Register("StartPath", typeof(string), typeof(TheButton), new PropertyMetadata(string.Empty)); + /// /// 运行事件 /// public void Register() diff --git a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml index 32847b1f..252948af 100644 --- a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml +++ b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml @@ -221,35 +221,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -257,12 +256,16 @@ - - - - + + + + + + + + + - @@ -277,39 +280,28 @@ - - - - - + + - - - - - - + + - - - - - - - - + + + + - - - + + + @@ -329,13 +321,29 @@ - + + + + + + + + + + + + + + + + + diff --git a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs index 89825231..32649612 100644 --- a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs +++ b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs @@ -414,6 +414,30 @@ namespace BeDesignerSCADA.Controls } } /// + /// 选择进程 + /// + /// + /// + 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) + { + + } + } + /// /// 设置子控件模板 /// /// @@ -491,103 +515,7 @@ namespace BeDesignerSCADA.Controls #endregion - #region 不需要的 - ///// - ///// 变量选择 - ///// - ///// - ///// - //private void ComboBoxValue_TextChanged(object sender, TextChangedEventArgs e) - //{ - // try - // { - // if (sender is System.Windows.Controls.ComboBox) - // { - // System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; - // Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; - // if (toggle.Tag != null && !string.IsNullOrEmpty(toggle.Text)) - // propertyGridCommand.Value = "{" + $"Binding {toggle.Tag}.{toggle.Text}" + "}"; - // } - // } - // catch (Exception ex) - // { - // } - //} - ///// - ///// 变量下拉框打开事件 - ///// - ///// - ///// - //private void valuebox_DropDownOpened(object sender, EventArgs e) - //{ - // try - // { - // viewModel.DevValueList = new System.Collections.ObjectModel.ObservableCollection(); - // if (sender is System.Windows.Controls.ComboBox) - // { - // System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; - // if (toggle.Tag == null) return; - - // CommunicationPar communication = null; - // if (DataBusModel.GetInstance().KeyValues.ContainsKey(viewModel.VariablePath)) - // { - // communication = DataBusModel.GetInstance().KeyValues[viewModel.VariablePath]; - // } - // CommunicationModel mode = communication?.CommunicationDevices?.ToList().Find(par => par.DeviceName == toggle.Tag.ToString()); - // if (mode != null) - // { - // mode?.VarTableModels?.ToList().ForEach(par => { viewModel.DevValueList.Add(par.VarName); }); - // } - // } - // } - // catch (Exception ex) - // { - - // } - - //} - ///// - ///// 设备名称选择 - ///// - ///// - ///// - //private void ComboBoxName_TextChanged(object sender, TextChangedEventArgs e) - //{ - // try - // { - // if (sender is System.Windows.Controls.ComboBox) - // { - // System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; - // Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; - // if (toggle.Tag != null && !string.IsNullOrEmpty(toggle.Text)) - // propertyGridCommand.Value = "{" + $"Binding {toggle.Text}.{toggle.Tag}" + "}"; - // else if (!string.IsNullOrEmpty(toggle.Text)) - // propertyGridCommand.Value = "{" + $"Binding {toggle.Text}." + "}"; - - // } - // } - // catch (Exception ex) - // { - - // } - //} - ///// - ///// 设备名称下拉框打开事件 - ///// - ///// - ///// - //private void namebox_DropDownOpened(object sender, EventArgs e) - //{ - - // viewModel.DevNameList = new System.Collections.ObjectModel.ObservableCollection(); - // CommunicationPar communication = null; - // if (DataBusModel.GetInstance().KeyValues.ContainsKey(viewModel.VariablePath)) - // { - // communication = DataBusModel.GetInstance().KeyValues[viewModel.VariablePath]; - // } - // communication?.CommunicationDevices?.ToList().ForEach(x => { viewModel.DevNameList.Add(x.DeviceName); }); - //} - #endregion + } } diff --git a/BeDesignerSCADA/ViewModel/MainViewModelNew.cs b/BeDesignerSCADA/ViewModel/MainViewModelNew.cs index 60fb4508..3d9feebc 100644 --- a/BeDesignerSCADA/ViewModel/MainViewModelNew.cs +++ b/BeDesignerSCADA/ViewModel/MainViewModelNew.cs @@ -326,6 +326,20 @@ namespace BeDesignerSCADA.ViewModel ((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).Value = ofd.FileName; } } + + /// + /// 选择路径 + /// + /// + public void SelectValuePath(object obj) + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.Filter = "请选择|*.*"; + if (ofd.ShowDialog() == true) + { + ((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).Value = ofd.SafeFileName; + } + } #endregion