diff --git a/STranslate/MainWindow.xaml b/STranslate/MainWindow.xaml
index e8e23d3..3016b4f 100644
--- a/STranslate/MainWindow.xaml
+++ b/STranslate/MainWindow.xaml
@@ -368,17 +368,15 @@
Grid.Row="2"
HorizontalAlignment="Center"
Orientation="Horizontal">
-
+
-
+
/// 移动
diff --git a/STranslate/Model/TranslateInterface.cs b/STranslate/Model/TranslateInterface.cs
new file mode 100644
index 0000000..033ba89
--- /dev/null
+++ b/STranslate/Model/TranslateInterface.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace STranslate.Model
+{
+ public class TranslationInterface
+ {
+ public string Name { get; set; }
+ public string Api { get; set; }
+ }
+}
diff --git a/STranslate/Properties/AssemblyInfo.cs b/STranslate/Properties/AssemblyInfo.cs
index 03bbab8..43bc705 100644
--- a/STranslate/Properties/AssemblyInfo.cs
+++ b/STranslate/Properties/AssemblyInfo.cs
@@ -47,6 +47,6 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.0.7.0")]
-[assembly: AssemblyFileVersion("0.0.7.0")]
+[assembly: AssemblyVersion("0.0.8.0")]
+[assembly: AssemblyFileVersion("0.0.8.0")]
[assembly: Guid("CE252DD8-179F-4544-9989-453F5DEA378D")]
\ No newline at end of file
diff --git a/STranslate/STranslate.csproj b/STranslate/STranslate.csproj
index 2d58541..696b461 100644
--- a/STranslate/STranslate.csproj
+++ b/STranslate/STranslate.csproj
@@ -82,12 +82,14 @@
MSBuild:Compile
Designer
+
True
True
Resources.resx
+
@@ -182,5 +184,16 @@
false
+
+
+ {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}
+ 1
+ 0
+ 0
+ tlbimp
+ False
+ True
+
+
\ No newline at end of file
diff --git a/STranslate/Utils/AutoStart.cs b/STranslate/Utils/AutoStart.cs
new file mode 100644
index 0000000..42447a2
--- /dev/null
+++ b/STranslate/Utils/AutoStart.cs
@@ -0,0 +1,147 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using IWshRuntimeLibrary;
+
+namespace STranslate.Utils
+{
+ public class AutoStart
+ {
+ private static readonly string StartUpPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
+ private static readonly string appPath = Assembly.GetEntryAssembly().Location;
+ private static readonly string appShortcutPath = Path.Combine(StartUpPath, Path.GetFileNameWithoutExtension(appPath) + ".lnk");
+
+ ///
+ /// 设置开机自启
+ ///
+ public static void SetAutoStart()
+ {
+ ShortCutCreate();
+ }
+ ///
+ /// 检查是否已经设置开机自启
+ ///
+ /// true: 开机自启 false: 非开机自启
+ public static bool IsAutoStart()
+ {
+ return ShortCutExist(appPath, StartUpPath);
+ }
+ ///
+ /// 取消开机自启
+ ///
+ public static void UnSetAutoStart()
+ {
+ ShortCutDelete(appPath, StartUpPath);
+ }
+
+ ///
+ /// 获取指定文件夹下的所有快捷方式(不包括子文件夹)
+ ///
+ /// 目标文件夹(绝对路径)
+ ///
+ public static List GetDirectoryFileList(string target)
+ {
+ List list = new List();
+ list.Clear();
+ string[] files = Directory.GetFiles(target, "*.lnk");
+ if (files == null || files.Length == 0)
+ {
+ return list;
+ }
+ for (int i = 0; i < files.Length; i++)
+ {
+ list.Add(files[i]);
+ }
+ return list;
+ }
+
+ ///
+ /// 判断快捷方式是否存在
+ ///
+ /// 快捷方式目标(可执行文件的绝对路径)
+ /// 目标文件夹(绝对路径)
+ ///
+ public static bool ShortCutExist(string path, string target)
+ {
+ bool Result = false;
+ List list = GetDirectoryFileList(target);
+ foreach (var item in list)
+ {
+ if (path == GetAppPathViaShortCut(item))
+ {
+ Result = true;
+ }
+ }
+ return Result;
+ }
+
+ ///
+ /// 删除快捷方式(通过快捷方式目标进行删除)
+ ///
+ /// 快捷方式目标(可执行文件的绝对路径)
+ /// 目标文件夹(绝对路径)
+ ///
+ public static bool ShortCutDelete(string path, string target)
+ {
+ bool Result = false;
+ List list = GetDirectoryFileList(target);
+ foreach (var item in list)
+ {
+ if (path == GetAppPathViaShortCut(item))
+ {
+ System.IO.File.Delete(item);
+ Result = true;
+ }
+ }
+ return Result;
+ }
+ ///
+ /// 为本程序创建一个快捷方式。
+ ///
+ public static bool ShortCutCreate()
+ {
+ bool Result = false;
+ try
+ {
+ ShortCutDelete(appPath, StartUpPath);
+
+ var shellType = Type.GetTypeFromProgID("WScript.Shell");
+ dynamic shell = Activator.CreateInstance(shellType);
+ var shortcut = shell.CreateShortcut(appShortcutPath);
+ shortcut.TargetPath = Assembly.GetEntryAssembly().Location;
+ shortcut.Arguments = string.Empty;
+ shortcut.WorkingDirectory = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
+ shortcut.Save();
+ Result = true;
+ }
+ catch
+ {
+ Result = false;
+ }
+ return Result;
+ }
+
+ ///
+ /// 获取快捷方式中的目标(可执行文件的绝对路径)
+ ///
+ /// 快捷方式的绝对路径
+ ///
+ /// 需引入 COM 组件 Windows Script Host Object Model
+ public static string GetAppPathViaShortCut(string shortCutPath)
+ {
+ try
+ {
+ WshShell shell = new WshShell();
+ IWshShortcut shortct = (IWshShortcut)shell.CreateShortcut(shortCutPath);
+ //快捷方式文件指向的路径.Text = 当前快捷方式文件IWshShortcut类.TargetPath;
+ //快捷方式文件指向的目标目录.Text = 当前快捷方式文件IWshShortcut类.WorkingDirectory;
+ return shortct.TargetPath;
+ }
+ catch
+ {
+ return null;
+ }
+ }
+ }
+}
diff --git a/STranslate/ViewModel/MainVM.cs b/STranslate/ViewModel/MainVM.cs
index a8c9062..03a27fd 100644
--- a/STranslate/ViewModel/MainVM.cs
+++ b/STranslate/ViewModel/MainVM.cs
@@ -12,14 +12,6 @@ namespace STranslate.ViewModel
{
public class MainVM : BaseVM
{
- ///
- /// 引入Go项目库
- ///
- ///
- //[System.Runtime.InteropServices.DllImport("deepl.dll", EntryPoint = "run")]
- //extern static void run();
-
- private static Dictionary LanguageEnumDict { get => TranslateUtil.GetEnumList(); }
public MainVM()
{
@@ -264,14 +256,8 @@ namespace STranslate.ViewModel
public List TranslationInterface { get => _TranslationInterface; set => UpdateProperty(ref _TranslationInterface, value); }
private TranslationInterface _SelectedTranslationInterface;
public TranslationInterface SelectedTranslationInterface { get => _SelectedTranslationInterface; set => UpdateProperty(ref _SelectedTranslationInterface, value); }
-
+ private static Dictionary LanguageEnumDict { get => TranslateUtil.GetEnumList(); }
#endregion Params
}
-
- public class TranslationInterface
- {
- public string Name { get; set; }
- public string Api { get; set; }
- }
}
\ No newline at end of file