|
|
@ -1,6 +1,7 @@
|
|
|
|
using STranslate.Utils;
|
|
|
|
using STranslate.Utils;
|
|
|
|
using STranslate.ViewModel;
|
|
|
|
using STranslate.ViewModel;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Windows;
|
|
|
|
using System.Windows;
|
|
|
|
using System.Windows.Input;
|
|
|
|
using System.Windows.Input;
|
|
|
|
using System.Windows.Interop;
|
|
|
|
using System.Windows.Interop;
|
|
|
@ -15,6 +16,7 @@ namespace STranslate
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private MainVM vm;
|
|
|
|
private MainVM vm;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Process process = new Process();
|
|
|
|
public MainWindow()
|
|
|
|
public MainWindow()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
InitializeComponent();
|
|
|
@ -23,12 +25,15 @@ namespace STranslate
|
|
|
|
|
|
|
|
|
|
|
|
InitialTray();
|
|
|
|
InitialTray();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DeepLStart();
|
|
|
|
|
|
|
|
|
|
|
|
//if (HotKeys.InputTranslate.Conflict || HotKeys.CrosswordTranslate.Conflict || HotKeys.ScreenShotTranslate.Conflict)
|
|
|
|
//if (HotKeys.InputTranslate.Conflict || HotKeys.CrosswordTranslate.Conflict || HotKeys.ScreenShotTranslate.Conflict)
|
|
|
|
//{
|
|
|
|
//{
|
|
|
|
// MessageBox.Show("全局快捷键有冲突,请您到设置中重新设置");
|
|
|
|
// MessageBox.Show("全局快捷键有冲突,请您到设置中重新设置");
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
vm = (MainVM)DataContext;
|
|
|
|
vm = (MainVM)DataContext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void InitialTray()
|
|
|
|
private void InitialTray()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//notifyIcon.BalloonTipText = "STranslate已运行";
|
|
|
|
//notifyIcon.BalloonTipText = "STranslate已运行";
|
|
|
@ -234,7 +239,9 @@ namespace STranslate
|
|
|
|
/// <param name="e"></param>
|
|
|
|
/// <param name="e"></param>
|
|
|
|
private void Exit_Click(object sender, EventArgs e)
|
|
|
|
private void Exit_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
notifyIcon.Dispose();
|
|
|
|
notifyIcon.Dispose();
|
|
|
|
|
|
|
|
DeepLStop();
|
|
|
|
Environment.Exit(0);
|
|
|
|
Environment.Exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void InitView()
|
|
|
|
private void InitView()
|
|
|
@ -247,5 +254,28 @@ namespace STranslate
|
|
|
|
private BitmapImage LockImgPath = new BitmapImage(new Uri("pack://application:,,,/Images/lock3.png"));
|
|
|
|
private BitmapImage LockImgPath = new BitmapImage(new Uri("pack://application:,,,/Images/lock3.png"));
|
|
|
|
private BitmapImage UnLockImgPath = new BitmapImage(new Uri("pack://application:,,,/Images/unlock3.png"));
|
|
|
|
private BitmapImage UnLockImgPath = new BitmapImage(new Uri("pack://application:,,,/Images/unlock3.png"));
|
|
|
|
private System.Windows.Forms.NotifyIcon notifyIcon = new System.Windows.Forms.NotifyIcon();
|
|
|
|
private System.Windows.Forms.NotifyIcon notifyIcon = new System.Windows.Forms.NotifyIcon();
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 新进程开启DeepL
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
private void DeepLStart()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string strPathExe = AppDomain.CurrentDomain.BaseDirectory + "\\Static\\deepl-x86_64-pc-windows-gnu.exe";
|
|
|
|
|
|
|
|
process.StartInfo.FileName = strPathExe;
|
|
|
|
|
|
|
|
process.StartInfo.Arguments = null;//-s -t 可以用来关机、开机或重启
|
|
|
|
|
|
|
|
process.StartInfo.UseShellExecute = false;
|
|
|
|
|
|
|
|
process.StartInfo.RedirectStandardInput = false; //true
|
|
|
|
|
|
|
|
process.StartInfo.RedirectStandardOutput = false; //true
|
|
|
|
|
|
|
|
process.StartInfo.RedirectStandardError = false;
|
|
|
|
|
|
|
|
process.StartInfo.CreateNoWindow = true;
|
|
|
|
|
|
|
|
process.Start();//启动
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 关闭DeepL进程
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
private void DeepLStop()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
process.Kill();//等待退出。
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|