@@ -47,8 +47,9 @@ namespace BPASmart.MenuLoad | |||||
this.Dispatcher.Invoke(() => { | this.Dispatcher.Invoke(() => { | ||||
if (File.Exists(_path)) | 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.LoadingData(_path); | ||||
run.Show(); | run.Show(); | ||||
isShow = true; | isShow = true; | ||||
@@ -5,7 +5,8 @@ | |||||
<TargetFramework>net6.0-windows</TargetFramework> | <TargetFramework>net6.0-windows</TargetFramework> | ||||
<Nullable>enable</Nullable> | <Nullable>enable</Nullable> | ||||
<UseWPF>true</UseWPF> | <UseWPF>true</UseWPF> | ||||
<ApplicationIcon>Images\fyf.ico</ApplicationIcon> | |||||
<ApplicationIcon>Images\配置.ico</ApplicationIcon> | |||||
<AssemblyName>可视化配置工具</AssemblyName> | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -74,10 +75,7 @@ | |||||
<None Remove="Images\wx.jpg" /> | <None Remove="Images\wx.jpg" /> | ||||
<None Remove="Images\zfb.jpg" /> | <None Remove="Images\zfb.jpg" /> | ||||
<None Remove="Images\光柱.png" /> | <None Remove="Images\光柱.png" /> | ||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<Content Include="Images\fyf.ico" /> | |||||
<None Remove="Images\配置.ico" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -109,7 +107,12 @@ | |||||
<Resource Include="Images\win.png" /> | <Resource Include="Images\win.png" /> | ||||
<Resource Include="Images\wx.jpg" /> | <Resource Include="Images\wx.jpg" /> | ||||
<Resource Include="Images\zfb.jpg" /> | <Resource Include="Images\zfb.jpg" /> | ||||
<Resource Include="Images\光柱.png" /> | |||||
<Resource Include="Images\光柱.png"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</Resource> | |||||
<Resource Include="Images\配置.ico"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</Resource> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -15,7 +15,8 @@ | |||||
<UserControl.Resources> | <UserControl.Resources> | ||||
<ResourceDictionary> | <ResourceDictionary> | ||||
<ResourceDictionary.MergedDictionaries> | <ResourceDictionary.MergedDictionaries> | ||||
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" /> | |||||
<!--<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" />--> | |||||
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"></ResourceDictionary> | |||||
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | <ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | ||||
</ResourceDictionary.MergedDictionaries> | </ResourceDictionary.MergedDictionaries> | ||||
</ResourceDictionary> | </ResourceDictionary> | ||||
@@ -16,7 +16,7 @@ | |||||
<UserControl.Resources> | <UserControl.Resources> | ||||
<ResourceDictionary> | <ResourceDictionary> | ||||
<ResourceDictionary.MergedDictionaries> | <ResourceDictionary.MergedDictionaries> | ||||
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" /> | |||||
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"/> | |||||
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | <ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | ||||
</ResourceDictionary.MergedDictionaries> | </ResourceDictionary.MergedDictionaries> | ||||
</ResourceDictionary> | </ResourceDictionary> | ||||
@@ -3,6 +3,7 @@ using Microsoft.Win32; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Diagnostics; | using System.Diagnostics; | ||||
using System.IO; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
using System.Text; | using System.Text; | ||||
@@ -33,67 +34,63 @@ namespace BeDesignerSCADA.Helper | |||||
/// 创建桌面快捷方式 | /// 创建桌面快捷方式 | ||||
/// </summary> | /// </summary> | ||||
/// <returns>成功或失败</returns> | /// <returns>成功或失败</returns> | ||||
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(); | |||||
} | } | ||||
} | } | ||||
@@ -14,7 +14,7 @@ | |||||
<Window.Resources> | <Window.Resources> | ||||
<ResourceDictionary> | <ResourceDictionary> | ||||
<ResourceDictionary.MergedDictionaries> | <ResourceDictionary.MergedDictionaries> | ||||
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" /> | |||||
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"></ResourceDictionary> | |||||
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | <ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | ||||
</ResourceDictionary.MergedDictionaries> | </ResourceDictionary.MergedDictionaries> | ||||
</ResourceDictionary> | </ResourceDictionary> | ||||
@@ -12,7 +12,7 @@ | |||||
<Window.Resources> | <Window.Resources> | ||||
<ResourceDictionary> | <ResourceDictionary> | ||||
<ResourceDictionary.MergedDictionaries> | <ResourceDictionary.MergedDictionaries> | ||||
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" /> | |||||
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"></ResourceDictionary> | |||||
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | <ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | ||||
</ResourceDictionary.MergedDictionaries> | </ResourceDictionary.MergedDictionaries> | ||||
</ResourceDictionary> | </ResourceDictionary> | ||||
@@ -11,7 +11,7 @@ | |||||
<Window.Resources> | <Window.Resources> | ||||
<ResourceDictionary> | <ResourceDictionary> | ||||
<ResourceDictionary.MergedDictionaries> | <ResourceDictionary.MergedDictionaries> | ||||
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" /> | |||||
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"></ResourceDictionary> | |||||
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | <ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | ||||
</ResourceDictionary.MergedDictionaries> | </ResourceDictionary.MergedDictionaries> | ||||
</ResourceDictionary> | </ResourceDictionary> | ||||