diff --git a/BPASmart.ConfigurationSoftware/App.xaml b/BPASmart.ConfigurationSoftware/App.xaml new file mode 100644 index 00000000..5537954f --- /dev/null +++ b/BPASmart.ConfigurationSoftware/App.xaml @@ -0,0 +1,7 @@ + + + diff --git a/BPASmart.ConfigurationSoftware/App.xaml.cs b/BPASmart.ConfigurationSoftware/App.xaml.cs new file mode 100644 index 00000000..cc3e269a --- /dev/null +++ b/BPASmart.ConfigurationSoftware/App.xaml.cs @@ -0,0 +1,42 @@ +using BPA.Helper; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace BPASmart.ConfigurationSoftware +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + if (e.Args != null && e.Args.Length == 1) + { + var res = e.Args[0]; + Json.Read(res); + + var rrr = Json.Data.Pages.OrderBy(p => p.Key).ToDictionary(p => p.Key, s => s.Value); + rrr?.ToList()?.ForEach(item => + { + MessageBox.Show(item.Key); + }); + + + } + MainWindow window = new MainWindow(); + window.Show(); + } + + protected override void OnExit(ExitEventArgs e) + { + base.OnExit(e); + } + } +} diff --git a/BPASmart.ConfigurationSoftware/AssemblyInfo.cs b/BPASmart.ConfigurationSoftware/AssemblyInfo.cs new file mode 100644 index 00000000..8b5504ec --- /dev/null +++ b/BPASmart.ConfigurationSoftware/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj b/BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj new file mode 100644 index 00000000..7378c67c --- /dev/null +++ b/BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj @@ -0,0 +1,39 @@ + + + + WinExe + net6.0-windows + enable + true + true + fyf.ico + + + + + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmart.ConfigurationSoftware/BasicInformation.cs b/BPASmart.ConfigurationSoftware/BasicInformation.cs new file mode 100644 index 00000000..99d2958d --- /dev/null +++ b/BPASmart.ConfigurationSoftware/BasicInformation.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmart.ConfigurationSoftware +{ + public class BasicInformation + { + /// + /// 项目上次保存的目录 + /// + public string ProjectDefaultPath { get; set; } = string.Empty; + + + } +} diff --git a/BPASmart.ConfigurationSoftware/FileHelper.cs b/BPASmart.ConfigurationSoftware/FileHelper.cs new file mode 100644 index 00000000..bd851deb --- /dev/null +++ b/BPASmart.ConfigurationSoftware/FileHelper.cs @@ -0,0 +1,88 @@ +using BPA.Helper; +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BPASmart.ConfigurationSoftware +{ + public class FileHelper + { + + private volatile static FileHelper _Instance; + public static FileHelper GetInstance => _Instance ?? (_Instance = new FileHelper()); + private FileHelper() { } + + public void RegisterOpenFileType() + { + string icoFile = System.Windows.Forms.Application.StartupPath + $"\\fyf.ico"; + string DirectoryPath = $"{Json.Data.ProjectPath}\\Images"; + Directory.CreateDirectory(DirectoryPath); + File.Copy(icoFile, $"{DirectoryPath}\\fyf.ico"); + RegisterFileType(".project", "HBL", ".project", System.Windows.Forms.Application.ExecutablePath, $"{DirectoryPath}\\fyf.ico"); + } + + private void RegisterFileType(string typeName, string fileType, string fileContent, string app, string ico) + { + string toolPath = app;//工具启动路径 + string extension = typeName;//fileType = "自定义文件类型"; + + //fileContent = "AAAA"; + //获取信息 + RegistryKey registryKey = Registry.ClassesRoot.OpenSubKey(extension); + if (registryKey != null) + { + try + { + RegistryKey _Regkey = Registry.ClassesRoot.OpenSubKey("", true); + + RegistryKey _VRPkey = _Regkey.OpenSubKey(extension); + if (_VRPkey != null) _Regkey.DeleteSubKeyTree(extension, true); + if (_VRPkey != null) _Regkey.DeleteSubKeyTree("Exec"); + } + catch (Exception e) + { + + } + } + + if (registryKey != null && registryKey.OpenSubKey("shell") != null && registryKey.OpenSubKey("shell").OpenSubKey("open") != null && + registryKey.OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command") != null) + { + var varSub = registryKey.OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command"); + var varValue = varSub.GetValue(""); + + if (Equals(varValue, toolPath + " \"%1\"")) + { + return; + } + } + + //文件注册 + registryKey = Registry.ClassesRoot.CreateSubKey(extension); + registryKey.SetValue("", fileType); + registryKey.SetValue("Content Type", fileContent); + //设置默认图标 + RegistryKey iconKey = registryKey.CreateSubKey("DefaultIcon"); + //iconKey.SetValue("", Application.StartupPath + $"\\{ico}.ico"); + iconKey.SetValue("", ico); + iconKey.Close(); + //设置默认打开程序路径 + registryKey = registryKey.CreateSubKey("shell\\open\\command"); + registryKey.SetValue("", toolPath + " \"%1\""); + //关闭 + registryKey.Close(); + SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero); + } + + [DllImport("shell32.dll")] + public static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2); + } + +} + diff --git a/BPASmart.ConfigurationSoftware/Global.cs b/BPASmart.ConfigurationSoftware/Global.cs new file mode 100644 index 00000000..f86d5c5e --- /dev/null +++ b/BPASmart.ConfigurationSoftware/Global.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmart.ConfigurationSoftware +{ + public class Global + { + /// + /// 页面文件夹名称 + /// + public const string PageDirectoryName = "Layouts"; + + + /// + /// 项目路径 + /// + public static string ProjectPath { get; set; } = string.Empty; + + /// + /// 项目名称 + /// + public static string ProjectName { get; set; } + + /// + /// 变量管理器路径 + /// + public static string VarManagerPath => $"{AppDomain.CurrentDomain.BaseDirectory}BPASmart.VariableManager.exe"; + } +} diff --git a/BPASmart.ConfigurationSoftware/MainCanvasPageModel.cs b/BPASmart.ConfigurationSoftware/MainCanvasPageModel.cs new file mode 100644 index 00000000..e0720a0d --- /dev/null +++ b/BPASmart.ConfigurationSoftware/MainCanvasPageModel.cs @@ -0,0 +1,16 @@ +using BeDesignerSCADA.Controls; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmart.ConfigurationSoftware +{ + public class MainCanvasPageModel + { + public MainCanvasPanel MainCanvasPanelModel { get; set; } + public string PageName { get; set; } + + } +} diff --git a/BPASmart.ConfigurationSoftware/MainWindow.xaml b/BPASmart.ConfigurationSoftware/MainWindow.xaml new file mode 100644 index 00000000..7fc8c07d --- /dev/null +++ b/BPASmart.ConfigurationSoftware/MainWindow.xaml @@ -0,0 +1,214 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +