diff --git a/BPASmart.MenuLoad/App.xaml.cs b/BPASmart.MenuLoad/App.xaml.cs
index 27f00a03..8f138296 100644
--- a/BPASmart.MenuLoad/App.xaml.cs
+++ b/BPASmart.MenuLoad/App.xaml.cs
@@ -47,8 +47,9 @@ namespace BPASmart.MenuLoad
this.Dispatcher.Invoke(() => {
if (File.Exists(_path))
{
- SystemHelperNew.GetInstance.CreateDesktopShortcut("BeDesignerSCADA.exe");
- SystemHelperNew.GetInstance.CreateDesktopShortcut();
+ SystemHelperNew.GetInstance.CreateShortcutOnDesktop();
+ SystemHelperNew.GetInstance.CreateShortcutOnDesktop("可视化配置工具");
+ //SystemHelperNew.GetInstance.CreateDesktopShortcut();
run.LoadingData(_path);
run.Show();
isShow = true;
diff --git a/BeDesignerSCADA/BeDesignerSCADA.csproj b/BeDesignerSCADA/BeDesignerSCADA.csproj
index 3b2ea24f..59a1df02 100644
--- a/BeDesignerSCADA/BeDesignerSCADA.csproj
+++ b/BeDesignerSCADA/BeDesignerSCADA.csproj
@@ -5,7 +5,8 @@
net6.0-windows
enable
true
- Images\fyf.ico
+ Images\配置.ico
+ 可视化配置工具
@@ -74,10 +75,7 @@
-
-
-
-
+
@@ -109,7 +107,12 @@
-
+
+ Always
+
+
+ Always
+
diff --git a/BeDesignerSCADA/Controls/CanvasPanelNew.xaml b/BeDesignerSCADA/Controls/CanvasPanelNew.xaml
index 39d4fdf2..acfceaa1 100644
--- a/BeDesignerSCADA/Controls/CanvasPanelNew.xaml
+++ b/BeDesignerSCADA/Controls/CanvasPanelNew.xaml
@@ -15,7 +15,8 @@
-
+
+
diff --git a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml
index b40e5ee4..7eaf2de9 100644
--- a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml
+++ b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml
@@ -16,7 +16,7 @@
-
+
diff --git a/BeDesignerSCADA/Helper/SystemHelper.cs b/BeDesignerSCADA/Helper/SystemHelper.cs
index f643c342..f48189fb 100644
--- a/BeDesignerSCADA/Helper/SystemHelper.cs
+++ b/BeDesignerSCADA/Helper/SystemHelper.cs
@@ -3,6 +3,7 @@ using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
@@ -33,67 +34,63 @@ namespace BeDesignerSCADA.Helper
/// 创建桌面快捷方式
///
/// 成功或失败
- public bool CreateDesktopShortcut()
+ public void CreateShortcutOnDesktop()
{
- //1、在COM对象中找到 Windows Script Host Object Model
- //2、添加引用 using IWshRuntimeLibrary;
- string deskTop = string.Empty;
- try
+ //添加引用 (com->Windows Script Host Object Model),using IWshRuntimeLibrary;
+ String shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), $"{AppDomain.CurrentDomain.FriendlyName}.lnk");
+ if (!System.IO.File.Exists(shortcutPath))
{
- deskTop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\";
- if (System.IO.File.Exists(deskTop + GetApplicationName + ".lnk")) //
+ // 获取当前应用程序目录地址
+ String exePath = Process.GetCurrentProcess().MainModule.FileName;
+ IWshShell shell = new WshShell();
+ // 确定是否已经创建的快捷键被改名了
+ foreach (var item in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "*.lnk"))
{
- return true;
+ WshShortcut tempShortcut = (WshShortcut)shell.CreateShortcut(item);
+ if (tempShortcut.TargetPath == exePath)
+ {
+ return;
+ }
}
- WshShell shell = new WshShell();
- //快捷键方式创建的位置、名称
- IWshShortcut shortcut = shell.CreateShortcut(deskTop + GetApplicationName + ".lnk") as IWshShortcut;
- shortcut.TargetPath = GetApplicationPath; //目标文件
- //该属性指定应用程序的工作目录,当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。
- shortcut.WorkingDirectory = System.Environment.CurrentDirectory;
- shortcut.WindowStyle = 1; //目标应用程序的窗口状态分为普通、最大化、最小化【1,3,7】
- shortcut.Description = GetApplicationName; //描述
- //shortcut.IconLocation = exePath + "\\logo.ico"; //快捷方式图标
- shortcut.Arguments = "";
- //shortcut.Hotkey = "CTRL+ALT+F11"; // 快捷键
- shortcut.Save(); //必须调用保存快捷才成创建成功
- return true;
- }
- catch (Exception ex)
- {
- return false;
+ WshShortcut shortcut = (WshShortcut)shell.CreateShortcut(shortcutPath);
+ shortcut.TargetPath = exePath;
+ shortcut.Arguments = "";// 参数
+ shortcut.Description = AppDomain.CurrentDomain.FriendlyName;
+ shortcut.WorkingDirectory = Environment.CurrentDirectory;//程序所在文件夹,在快捷方式图标点击右键可以看到此属性
+ shortcut.IconLocation = exePath;//图标,该图标是应用程序的资源文件
+ //shortcut.Hotkey = "CTRL+SHIFT+W";//热键,发现没作用,大概需要注册一下
+ shortcut.WindowStyle = 1;
+ shortcut.Save();
}
}
- public bool CreateDesktopShortcut(string Name)
+ public void CreateShortcutOnDesktop(string Name)
{
- //1、在COM对象中找到 Windows Script Host Object Model
- //2、添加引用 using IWshRuntimeLibrary;
- string deskTop = string.Empty;
- try
+ //添加引用 (com->Windows Script Host Object Model),using IWshRuntimeLibrary;
+ String shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), $"{Name}.lnk");
+ if (!System.IO.File.Exists(shortcutPath))
{
- deskTop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\";
- if (System.IO.File.Exists(deskTop + Name + ".lnk")) //
+ // 获取当前应用程序目录地址
+ String exePath = $"{AppDomain.CurrentDomain.BaseDirectory}{Name}.exe";// Process.GetCurrentProcess().MainModule.FileName;
+ IWshShell shell = new WshShell();
+ // 确定是否已经创建的快捷键被改名了
+ foreach (var item in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "*.lnk"))
{
- return true;
+ WshShortcut tempShortcut = (WshShortcut)shell.CreateShortcut(item);
+ if (tempShortcut.TargetPath == exePath)
+ {
+ return;
+ }
}
- WshShell shell = new WshShell();
- //快捷键方式创建的位置、名称
- IWshShortcut shortcut = shell.CreateShortcut(deskTop + Name + ".lnk") as IWshShortcut;
- shortcut.TargetPath = GetApplicationPath; //目标文件
- //该属性指定应用程序的工作目录,当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。
- shortcut.WorkingDirectory = System.Environment.CurrentDirectory;
- shortcut.WindowStyle = 1; //目标应用程序的窗口状态分为普通、最大化、最小化【1,3,7】
- shortcut.Description = Name; //描述
- //shortcut.IconLocation = exePath + "\\logo.ico"; //快捷方式图标
- shortcut.Arguments = "";
- //shortcut.Hotkey = "CTRL+ALT+F11"; // 快捷键
- shortcut.Save(); //必须调用保存快捷才成创建成功
- return true;
- }
- catch (Exception ex)
- {
- return false;
+ WshShortcut shortcut = (WshShortcut)shell.CreateShortcut(shortcutPath);
+ shortcut.TargetPath = exePath;
+ shortcut.Arguments = "";// 参数
+ shortcut.Description = AppDomain.CurrentDomain.FriendlyName;
+ shortcut.WorkingDirectory = Environment.CurrentDirectory;//程序所在文件夹,在快捷方式图标点击右键可以看到此属性
+ shortcut.IconLocation = exePath;//图标,该图标是应用程序的资源文件
+ //shortcut.Hotkey = "CTRL+SHIFT+W";//热键,发现没作用,大概需要注册一下
+ shortcut.WindowStyle = 1;
+ shortcut.Save();
}
}
diff --git a/BeDesignerSCADA/Images/配置.ico b/BeDesignerSCADA/Images/配置.ico
new file mode 100644
index 00000000..0c00208f
Binary files /dev/null and b/BeDesignerSCADA/Images/配置.ico differ
diff --git a/BeDesignerSCADA/View/ChildEditWindow.xaml b/BeDesignerSCADA/View/ChildEditWindow.xaml
index 5f50bd14..3e90c316 100644
--- a/BeDesignerSCADA/View/ChildEditWindow.xaml
+++ b/BeDesignerSCADA/View/ChildEditWindow.xaml
@@ -14,7 +14,7 @@
-
+
diff --git a/BeDesignerSCADA/View/RunWindows.xaml b/BeDesignerSCADA/View/RunWindows.xaml
index 611c1d3d..1866a3fb 100644
--- a/BeDesignerSCADA/View/RunWindows.xaml
+++ b/BeDesignerSCADA/View/RunWindows.xaml
@@ -12,7 +12,7 @@
-
+
diff --git a/BeDesignerSCADA/View/RunWindowsLao.xaml b/BeDesignerSCADA/View/RunWindowsLao.xaml
index 247d4663..76b99164 100644
--- a/BeDesignerSCADA/View/RunWindowsLao.xaml
+++ b/BeDesignerSCADA/View/RunWindowsLao.xaml
@@ -11,7 +11,7 @@
-
+