diff --git a/STranslate/App.xaml b/STranslate/App.xaml
index 3c9c4b5..d92fa00 100644
--- a/STranslate/App.xaml
+++ b/STranslate/App.xaml
@@ -3,6 +3,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/STranslate/Helper/GetWordsHelper.cs b/STranslate/Helper/GetWordsHelper.cs
new file mode 100644
index 0000000..52d99c1
--- /dev/null
+++ b/STranslate/Helper/GetWordsHelper.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Threading;
+using System.Windows.Input;
+
+namespace STranslate.Helper
+{
+ public class GetWordsHelper
+ {
+ public static String Get()
+ {
+ SendCtrlC();
+ Thread.Sleep(200);
+ return NativeMethodHelper.GetText();
+ }
+
+ private static void SendCtrlC()
+ {
+ //IntPtr hWnd = GetForegroundWindow();
+ //SetForegroundWindow(hWnd);
+ uint KEYEVENTF_KEYUP = 2;
+
+ NativeMethodHelper.keybd_event(System.Windows.Forms.Keys.ControlKey, 0, KEYEVENTF_KEYUP, 0);
+ NativeMethodHelper.keybd_event(KeyInterop.VirtualKeyFromKey(Key.LeftAlt), 0, KEYEVENTF_KEYUP, 0);
+ NativeMethodHelper.keybd_event(KeyInterop.VirtualKeyFromKey(Key.RightAlt), 0, KEYEVENTF_KEYUP, 0);
+ NativeMethodHelper.keybd_event(System.Windows.Forms.Keys.LWin, 0, KEYEVENTF_KEYUP, 0);
+ NativeMethodHelper.keybd_event(System.Windows.Forms.Keys.RWin, 0, KEYEVENTF_KEYUP, 0);
+ NativeMethodHelper.keybd_event(System.Windows.Forms.Keys.ShiftKey, 0, KEYEVENTF_KEYUP, 0);
+
+ NativeMethodHelper.keybd_event(System.Windows.Forms.Keys.ControlKey, 0, 0, 0);
+ NativeMethodHelper.keybd_event(System.Windows.Forms.Keys.C, 0, 0, 0);
+ NativeMethodHelper.keybd_event(System.Windows.Forms.Keys.C, 0, KEYEVENTF_KEYUP, 0);
+ NativeMethodHelper.keybd_event(System.Windows.Forms.Keys.ControlKey, 0, KEYEVENTF_KEYUP, 0);// 'Left Control Up
+ }
+ }
+}
diff --git a/STranslate/Utils/HotKeysUtil.cs b/STranslate/Helper/HotkeysHelper.cs
similarity index 50%
rename from STranslate/Utils/HotKeysUtil.cs
rename to STranslate/Helper/HotkeysHelper.cs
index b563fe6..2342246 100644
--- a/STranslate/Utils/HotKeysUtil.cs
+++ b/STranslate/Helper/HotkeysHelper.cs
@@ -1,9 +1,9 @@
using System;
-using static STranslate.Utils.NativeMethod;
+using static STranslate.Helper.NativeMethodHelper;
-namespace STranslate.Utils
+namespace STranslate.Helper
{
- public static class HotKeys
+ public static class Hotkeys
{
public static class InputTranslate
{
@@ -21,6 +21,7 @@ namespace STranslate.Utils
public static bool Conflict = false;
}
+#if false
public static class ScreenShotTranslate
{
public static byte Modifiers = (byte)KeyModifiers.MOD_ALT;
@@ -28,7 +29,7 @@ namespace STranslate.Utils
public static String Text = "S";
public static bool Conflict = false;
}
-
+#endif
public static class OpenMainWindow
{
public static byte Modifiers = (byte)KeyModifiers.MOD_ALT;
@@ -38,7 +39,7 @@ namespace STranslate.Utils
}
}
- internal class HotKeysUtil
+ internal class HotkeysHelper
{
public static IntPtr mainFormHandle;
@@ -48,9 +49,11 @@ namespace STranslate.Utils
public static int CrosswordTranslateId = 855;
public static byte CrosswordTranslateModifiers;
public static int CrosswordTranslateKey;
+#if false
public static int ScreenShotTranslateId = 856;
public static byte ScreenShotTranslateModifiers;
public static int ScreenShotTranslateKey;
+#endif
public static int OpenMainWindowId = 857;
public static byte OpenMainWindowModifiers;
public static int OpenMainWindowKey;
@@ -61,30 +64,33 @@ namespace STranslate.Utils
///
public static void RegisterHotKey(IntPtr mainFormHandle)
{
- HotKeysUtil.mainFormHandle = mainFormHandle;
+ HotkeysHelper.mainFormHandle = mainFormHandle;
- InputTranslateModifiers = HotKeys.InputTranslate.Modifiers;
- InputTranslateKey = HotKeys.InputTranslate.Key;
- CrosswordTranslateModifiers = HotKeys.CrosswordTranslate.Modifiers;
- CrosswordTranslateKey = HotKeys.CrosswordTranslate.Key;
- ScreenShotTranslateModifiers = HotKeys.ScreenShotTranslate.Modifiers;
- ScreenShotTranslateKey = HotKeys.ScreenShotTranslate.Key;
+ InputTranslateModifiers = Hotkeys.InputTranslate.Modifiers;
+ InputTranslateKey = Hotkeys.InputTranslate.Key;
+ CrosswordTranslateModifiers = Hotkeys.CrosswordTranslate.Modifiers;
+ CrosswordTranslateKey = Hotkeys.CrosswordTranslate.Key;
- if (HotKeys.InputTranslate.Key != 0)
+#if false
+ ScreenShotTranslateModifiers = Hotkeys.ScreenShotTranslate.Modifiers;
+ ScreenShotTranslateKey = Hotkeys.ScreenShotTranslate.Key;
+ if (Hotkeys.ScreenShotTranslate.Key != 0)
{
- HotKeys.InputTranslate.Conflict = !NativeMethod.RegisterHotKey(mainFormHandle, InputTranslateId, HotKeys.InputTranslate.Modifiers, HotKeys.InputTranslate.Key);
+ Hotkeys.ScreenShotTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, ScreenShotTranslateId, Hotkeys.ScreenShotTranslate.Modifiers, Hotkeys.ScreenShotTranslate.Key);
}
- if (HotKeys.CrosswordTranslate.Key != 0)
+#endif
+
+ if (Hotkeys.InputTranslate.Key != 0)
{
- HotKeys.CrosswordTranslate.Conflict = !NativeMethod.RegisterHotKey(mainFormHandle, CrosswordTranslateId, HotKeys.CrosswordTranslate.Modifiers, HotKeys.CrosswordTranslate.Key);
+ Hotkeys.InputTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, InputTranslateId, Hotkeys.InputTranslate.Modifiers, Hotkeys.InputTranslate.Key);
}
- if (HotKeys.ScreenShotTranslate.Key != 0)
+ if (Hotkeys.CrosswordTranslate.Key != 0)
{
- HotKeys.ScreenShotTranslate.Conflict = !NativeMethod.RegisterHotKey(mainFormHandle, ScreenShotTranslateId, HotKeys.ScreenShotTranslate.Modifiers, HotKeys.ScreenShotTranslate.Key);
+ Hotkeys.CrosswordTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, CrosswordTranslateId, Hotkeys.CrosswordTranslate.Modifiers, Hotkeys.CrosswordTranslate.Key);
}
- if (HotKeys.OpenMainWindow.Key != 0)
+ if (Hotkeys.OpenMainWindow.Key != 0)
{
- HotKeys.OpenMainWindow.Conflict = !NativeMethod.RegisterHotKey(mainFormHandle, OpenMainWindowId, HotKeys.OpenMainWindow.Modifiers, HotKeys.OpenMainWindow.Key);
+ Hotkeys.OpenMainWindow.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, OpenMainWindowId, Hotkeys.OpenMainWindow.Modifiers, Hotkeys.OpenMainWindow.Key);
}
}
@@ -95,7 +101,9 @@ namespace STranslate.Utils
{
UnregisterHotKey(mainFormHandle, InputTranslateId);
UnregisterHotKey(mainFormHandle, CrosswordTranslateId);
+#if false
UnregisterHotKey(mainFormHandle, ScreenShotTranslateId);
+#endif
UnregisterHotKey(mainFormHandle, OpenMainWindowId);
}
@@ -104,57 +112,59 @@ namespace STranslate.Utils
///
public static void ReRegisterHotKey()
{
- if (HotKeys.InputTranslate.Key == 0)
+ if (Hotkeys.InputTranslate.Key == 0)
{
UnregisterHotKey(mainFormHandle, InputTranslateId);
}
- else if (InputTranslateModifiers != HotKeys.InputTranslate.Modifiers || InputTranslateKey != HotKeys.InputTranslate.Key)
+ else if (InputTranslateModifiers != Hotkeys.InputTranslate.Modifiers || InputTranslateKey != Hotkeys.InputTranslate.Key)
{
{
UnregisterHotKey(mainFormHandle, InputTranslateId);
- HotKeys.InputTranslate.Conflict = !NativeMethod.RegisterHotKey(mainFormHandle, InputTranslateId, HotKeys.InputTranslate.Modifiers, HotKeys.InputTranslate.Key);
+ Hotkeys.InputTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, InputTranslateId, Hotkeys.InputTranslate.Modifiers, Hotkeys.InputTranslate.Key);
}
}
- InputTranslateModifiers = HotKeys.InputTranslate.Modifiers;
- InputTranslateKey = HotKeys.InputTranslate.Key;
+ InputTranslateModifiers = Hotkeys.InputTranslate.Modifiers;
+ InputTranslateKey = Hotkeys.InputTranslate.Key;
- if (HotKeys.CrosswordTranslate.Key == 0)
+ if (Hotkeys.CrosswordTranslate.Key == 0)
{
UnregisterHotKey(mainFormHandle, CrosswordTranslateId);
}
- else if (CrosswordTranslateModifiers != HotKeys.CrosswordTranslate.Modifiers || CrosswordTranslateKey != HotKeys.CrosswordTranslate.Key)
+ else if (CrosswordTranslateModifiers != Hotkeys.CrosswordTranslate.Modifiers || CrosswordTranslateKey != Hotkeys.CrosswordTranslate.Key)
{
{
UnregisterHotKey(mainFormHandle, CrosswordTranslateId);
- HotKeys.CrosswordTranslate.Conflict = !NativeMethod.RegisterHotKey(mainFormHandle, CrosswordTranslateId, HotKeys.CrosswordTranslate.Modifiers, HotKeys.CrosswordTranslate.Key);
+ Hotkeys.CrosswordTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, CrosswordTranslateId, Hotkeys.CrosswordTranslate.Modifiers, Hotkeys.CrosswordTranslate.Key);
}
}
- CrosswordTranslateModifiers = HotKeys.CrosswordTranslate.Modifiers;
- CrosswordTranslateKey = HotKeys.CrosswordTranslate.Key;
+ CrosswordTranslateModifiers = Hotkeys.CrosswordTranslate.Modifiers;
+ CrosswordTranslateKey = Hotkeys.CrosswordTranslate.Key;
- if (HotKeys.ScreenShotTranslate.Key == 0)
+#if false
+ if (Hotkeys.ScreenShotTranslate.Key == 0)
{
UnregisterHotKey(mainFormHandle, ScreenShotTranslateId);
}
- else if (ScreenShotTranslateModifiers != HotKeys.ScreenShotTranslate.Modifiers || ScreenShotTranslateKey != HotKeys.ScreenShotTranslate.Key)
+ else if (ScreenShotTranslateModifiers != Hotkeys.ScreenShotTranslate.Modifiers || ScreenShotTranslateKey != Hotkeys.ScreenShotTranslate.Key)
{
UnregisterHotKey(mainFormHandle, ScreenShotTranslateId);
- HotKeys.ScreenShotTranslate.Conflict = !NativeMethod.RegisterHotKey(mainFormHandle, ScreenShotTranslateId, HotKeys.ScreenShotTranslate.Modifiers, HotKeys.ScreenShotTranslate.Key);
+ Hotkeys.ScreenShotTranslate.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, ScreenShotTranslateId, Hotkeys.ScreenShotTranslate.Modifiers, Hotkeys.ScreenShotTranslate.Key);
}
- ScreenShotTranslateModifiers = HotKeys.ScreenShotTranslate.Modifiers;
- ScreenShotTranslateKey = HotKeys.ScreenShotTranslate.Key;
+ ScreenShotTranslateModifiers = Hotkeys.ScreenShotTranslate.Modifiers;
+ ScreenShotTranslateKey = Hotkeys.ScreenShotTranslate.Key;
+#endif
- if (HotKeys.OpenMainWindow.Key == 0)
+ if (Hotkeys.OpenMainWindow.Key == 0)
{
UnregisterHotKey(mainFormHandle, OpenMainWindowId);
}
- else if (OpenMainWindowModifiers != HotKeys.OpenMainWindow.Modifiers || OpenMainWindowKey != HotKeys.OpenMainWindow.Key)
+ else if (OpenMainWindowModifiers != Hotkeys.OpenMainWindow.Modifiers || OpenMainWindowKey != Hotkeys.OpenMainWindow.Key)
{
UnregisterHotKey(mainFormHandle, OpenMainWindowId);
- HotKeys.OpenMainWindow.Conflict = !NativeMethod.RegisterHotKey(mainFormHandle, OpenMainWindowId, HotKeys.OpenMainWindow.Modifiers, HotKeys.OpenMainWindow.Key);
+ Hotkeys.OpenMainWindow.Conflict = !NativeMethodHelper.RegisterHotKey(mainFormHandle, OpenMainWindowId, Hotkeys.OpenMainWindow.Modifiers, Hotkeys.OpenMainWindow.Key);
}
- OpenMainWindowModifiers = HotKeys.OpenMainWindow.Modifiers;
- OpenMainWindowKey = HotKeys.OpenMainWindow.Key;
+ OpenMainWindowModifiers = Hotkeys.OpenMainWindow.Modifiers;
+ OpenMainWindowKey = Hotkeys.OpenMainWindow.Key;
}
}
}
\ No newline at end of file
diff --git a/STranslate/Utils/MVVMUtil.cs b/STranslate/Helper/MvvmHelper.cs
similarity index 98%
rename from STranslate/Utils/MVVMUtil.cs
rename to STranslate/Helper/MvvmHelper.cs
index b6604e6..8919b8f 100644
--- a/STranslate/Utils/MVVMUtil.cs
+++ b/STranslate/Helper/MvvmHelper.cs
@@ -1,9 +1,9 @@
using System;
+using System.Windows.Input;
using System.ComponentModel;
using System.Runtime.CompilerServices;
-using System.Windows.Input;
-namespace STranslate.Utils
+namespace STranslate.Helper
{
///
/// 通知
@@ -56,4 +56,4 @@ namespace STranslate.Utils
_execute(parameter);
}
}
-}
\ No newline at end of file
+}
diff --git a/STranslate/Utils/NativeMethod.cs b/STranslate/Helper/NativeMethodHelper.cs
similarity index 99%
rename from STranslate/Utils/NativeMethod.cs
rename to STranslate/Helper/NativeMethodHelper.cs
index b8268bf..2901423 100644
--- a/STranslate/Utils/NativeMethod.cs
+++ b/STranslate/Helper/NativeMethodHelper.cs
@@ -2,9 +2,9 @@
using System.Runtime.InteropServices;
using System.Text;
-namespace STranslate.Utils
+namespace STranslate.Helper
{
- internal class NativeMethod
+ internal class NativeMethodHelper
{
///
/// 获取进程句柄
@@ -259,4 +259,4 @@ namespace STranslate.Utils
#endregion Clipboard
}
-}
\ No newline at end of file
+}
diff --git a/STranslate/Utils/AutoStart.cs b/STranslate/Helper/StartupHelper.cs
similarity index 96%
rename from STranslate/Utils/AutoStart.cs
rename to STranslate/Helper/StartupHelper.cs
index 012e2e5..96cacb3 100644
--- a/STranslate/Utils/AutoStart.cs
+++ b/STranslate/Helper/StartupHelper.cs
@@ -4,15 +4,16 @@ using System.IO;
using System.Reflection;
using IWshRuntimeLibrary;
-namespace STranslate.Utils
+namespace STranslate.Helper
{
- public class AutoStart
+ public class StartupHelper
{
+
#region public method
///
/// 设置开机自启
///
- public static void SetAutoStart()
+ public static void SetStartup()
{
ShortCutCreate();
}
@@ -20,14 +21,14 @@ namespace STranslate.Utils
/// 检查是否已经设置开机自启
///
/// true: 开机自启 false: 非开机自启
- public static bool IsAutoStart()
+ public static bool IsStartup()
{
return ShortCutExist(appPath, StartUpPath);
}
///
/// 取消开机自启
///
- public static void UnSetAutoStart()
+ public static void UnSetStartup()
{
ShortCutDelete(appPath, StartUpPath);
}
diff --git a/STranslate/Images/copy2.png b/STranslate/Images/Button_Default/copy_default.png
similarity index 100%
rename from STranslate/Images/copy2.png
rename to STranslate/Images/Button_Default/copy_default.png
diff --git a/STranslate/Images/copy_h2.png b/STranslate/Images/Button_Default/copy_large_hump.png
similarity index 100%
rename from STranslate/Images/copy_h2.png
rename to STranslate/Images/Button_Default/copy_large_hump.png
diff --git a/STranslate/Images/copy_h.png b/STranslate/Images/Button_Default/copy_small_hump.png
similarity index 100%
rename from STranslate/Images/copy_h.png
rename to STranslate/Images/Button_Default/copy_small_hump.png
diff --git a/STranslate/Images/copy_s.png b/STranslate/Images/Button_Default/copy_snake.png
similarity index 100%
rename from STranslate/Images/copy_s.png
rename to STranslate/Images/Button_Default/copy_snake.png
diff --git a/STranslate/Images/lock3.png b/STranslate/Images/Button_Default/lock.png
similarity index 100%
rename from STranslate/Images/lock3.png
rename to STranslate/Images/Button_Default/lock.png
diff --git a/STranslate/Images/unlock3.png b/STranslate/Images/Button_Default/unlock.png
similarity index 100%
rename from STranslate/Images/unlock3.png
rename to STranslate/Images/Button_Default/unlock.png
diff --git a/STranslate/Images/crossword.ico b/STranslate/Images/Tray/crossword.ico
similarity index 100%
rename from STranslate/Images/crossword.ico
rename to STranslate/Images/Tray/crossword.ico
diff --git a/STranslate/Images/input.ico b/STranslate/Images/Tray/input.ico
similarity index 100%
rename from STranslate/Images/input.ico
rename to STranslate/Images/Tray/input.ico
diff --git a/STranslate/Images/screenshot.ico b/STranslate/Images/Tray/screenshot.ico
similarity index 100%
rename from STranslate/Images/screenshot.ico
rename to STranslate/Images/Tray/screenshot.ico
diff --git a/STranslate/Images/window.ico b/STranslate/Images/Tray/window.ico
similarity index 100%
rename from STranslate/Images/window.ico
rename to STranslate/Images/Tray/window.ico
diff --git a/STranslate/MainWindow.xaml b/STranslate/MainWindow.xaml
index 6036d9d..240487d 100644
--- a/STranslate/MainWindow.xaml
+++ b/STranslate/MainWindow.xaml
@@ -26,243 +26,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
///
- internal static System.Drawing.Bitmap copy_h {
+ internal static System.Drawing.Bitmap _lock {
get {
- object obj = ResourceManager.GetObject("copy_h", resourceCulture);
+ object obj = ResourceManager.GetObject("_lock", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@@ -73,9 +73,9 @@ namespace STranslate.Properties {
///
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
///
- internal static System.Drawing.Bitmap copy_h2 {
+ internal static System.Drawing.Bitmap copy_default {
get {
- object obj = ResourceManager.GetObject("copy_h2", resourceCulture);
+ object obj = ResourceManager.GetObject("copy_default", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@@ -83,9 +83,9 @@ namespace STranslate.Properties {
///
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
///
- internal static System.Drawing.Bitmap copy_s {
+ internal static System.Drawing.Bitmap copy_large_hump {
get {
- object obj = ResourceManager.GetObject("copy_s", resourceCulture);
+ object obj = ResourceManager.GetObject("copy_large_hump", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@@ -93,40 +93,40 @@ namespace STranslate.Properties {
///
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
///
- internal static System.Drawing.Bitmap copy2 {
+ internal static System.Drawing.Bitmap copy_small_hump {
get {
- object obj = ResourceManager.GetObject("copy2", resourceCulture);
+ object obj = ResourceManager.GetObject("copy_small_hump", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
///
- /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
+ /// 查找 System.Drawing.Bitmap 类型的本地化资源。
///
- internal static System.Drawing.Icon crossword {
+ internal static System.Drawing.Bitmap copy_snake {
get {
- object obj = ResourceManager.GetObject("crossword", resourceCulture);
- return ((System.Drawing.Icon)(obj));
+ object obj = ResourceManager.GetObject("copy_snake", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
}
}
///
/// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
///
- internal static System.Drawing.Icon input {
+ internal static System.Drawing.Icon crossword {
get {
- object obj = ResourceManager.GetObject("input", resourceCulture);
+ object obj = ResourceManager.GetObject("crossword", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
///
- /// 查找 System.Drawing.Bitmap 类型的本地化资源。
+ /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
///
- internal static System.Drawing.Bitmap lock3 {
+ internal static System.Drawing.Icon input {
get {
- object obj = ResourceManager.GetObject("lock3", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
+ object obj = ResourceManager.GetObject("input", resourceCulture);
+ return ((System.Drawing.Icon)(obj));
}
}
@@ -153,9 +153,9 @@ namespace STranslate.Properties {
///
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
///
- internal static System.Drawing.Bitmap unlock3 {
+ internal static System.Drawing.Bitmap unlock {
get {
- object obj = ResourceManager.GetObject("unlock3", resourceCulture);
+ object obj = ResourceManager.GetObject("unlock", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
diff --git a/STranslate/Properties/Resources.resx b/STranslate/Properties/Resources.resx
index fdc2bb6..4d0554b 100644
--- a/STranslate/Properties/Resources.resx
+++ b/STranslate/Properties/Resources.resx
@@ -118,37 +118,37 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- ..\images\copy2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\images\button_default\copy_default.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\images\copy_h.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\images\button_default\copy_large_hump.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\images\copy_h2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\images\button_default\copy_small_hump.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\images\copy_s.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\images\button_default\copy_snake.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
- ..\images\crossword.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+ ..\images\tray\crossword.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
- ..\images\input.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- ..\images\lock3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+ ..\images\tray\input.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
- ..\images\screenshot.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+ ..\images\tray\screenshot.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
..\images\translate.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\images\unlock3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\images\button_default\unlock.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
- ..\images\window.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+ ..\images\tray\window.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\images\button_default\lock.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
\ No newline at end of file
diff --git a/STranslate/STranslate.csproj b/STranslate/STranslate.csproj
index 696b461..6cc0289 100644
--- a/STranslate/STranslate.csproj
+++ b/STranslate/STranslate.csproj
@@ -82,6 +82,11 @@
MSBuild:Compile
Designer
+
+
+
+
+
@@ -89,13 +94,7 @@
True
Resources.resx
-
-
-
-
-
-
-
+
MSBuild:Compile
@@ -109,10 +108,17 @@
MainWindow.xaml
Code
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
-
@@ -135,37 +141,37 @@
SettingsSingleFileGenerator
Settings.Designer.cs
-
+
PreserveNewest
-
+
PreserveNewest
-
+
PreserveNewest
-
+
PreserveNewest
-
+
PreserveNewest
-
+
PreserveNewest
PreserveNewest
-
+
PreserveNewest
-
+
PreserveNewest
-
+
PreserveNewest
-
+
PreserveNewest
@@ -195,5 +201,6 @@
True
+
\ No newline at end of file
diff --git a/STranslate/Style/DictionaryButtonDefault.xaml b/STranslate/Style/DictionaryButtonDefault.xaml
new file mode 100644
index 0000000..5b9c8bd
--- /dev/null
+++ b/STranslate/Style/DictionaryButtonDefault.xaml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/STranslate/Style/DictionaryComboBoxDefault.xaml b/STranslate/Style/DictionaryComboBoxDefault.xaml
new file mode 100644
index 0000000..13059d9
--- /dev/null
+++ b/STranslate/Style/DictionaryComboBoxDefault.xaml
@@ -0,0 +1,174 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/STranslate/Utils/TranslateUtil.cs b/STranslate/Util/Util.cs
similarity index 75%
rename from STranslate/Utils/TranslateUtil.cs
rename to STranslate/Util/Util.cs
index fe429d7..a3aa3d5 100644
--- a/STranslate/Utils/TranslateUtil.cs
+++ b/STranslate/Util/Util.cs
@@ -3,33 +3,17 @@ using STranslate.Model;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Web;
-namespace STranslate.Utils
+namespace STranslate.Util
{
- public class TranslateUtil
+ public class Util
{
- private static readonly string _url = "http://127.0.0.1:8000/translate";
-
- public static string Translate(string input, LanguageEnum source, LanguageEnum target)
- {
- var req = new DeeplReq()
- {
- Text = input,
- SourceLang = source.ToString(),
- TargetLang = target.ToString(),
- };
- var resp = HttpUtil.Post(_url, req);
- if (resp.Code == 200)
- {
- return resp.Data;
- }
- return string.Empty;
- }
-
+ #region 翻译接口
public static async Task TranslateDeepLAsync(string url, string text, LanguageEnum target, LanguageEnum source = LanguageEnum.AUTO)
{
var req = new DeeplReq()
@@ -48,7 +32,7 @@ namespace STranslate.Utils
req.TargetLang = LanguageEnum.AUTO.ToString().ToLower();
}
var reqStr = JsonConvert.SerializeObject(req);
- var respStr = await HttpUtil.PostAsync(url, reqStr);
+ var respStr = await PostAsync(url, reqStr);
var resp = JsonConvert.DeserializeObject(respStr);
if (resp == null || resp.Code != 200)
@@ -96,7 +80,7 @@ namespace STranslate.Utils
myResponseStream.Close();
#endif
- var retString = await HttpUtil.GetAsync(url);
+ var retString = await GetAsync(url);
var resp = JsonConvert.DeserializeObject(retString);
if (resp.From != null)
{
@@ -144,5 +128,52 @@ namespace STranslate.Utils
});
return dict;
}
+ #endregion
+
+ #region Http
+ ///
+ /// 异步Post请求
+ ///
+ ///
+ ///
+ ///
+ public static async Task PostAsync(string url, string req)
+ {
+ using (var client = new HttpClient())
+ {
+ var content = new StringContent(req, Encoding.UTF8, "application/json");
+
+ var respContent = await client.PostAsync(url, content);
+
+ string respStr = await respContent.Content.ReadAsStringAsync();
+ ;
+ return respStr;
+ }
+ }
+
+ ///
+ /// 异步Get请求
+ ///
+ ///
+ ///
+ public static async Task GetAsync(string urlpath)
+ {
+ using (var client = new HttpClient())
+ {
+ try
+ {
+ var respContent = await client.GetAsync(urlpath);
+
+ string respStr = await respContent.Content.ReadAsStringAsync();
+
+ return respStr;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+ }
+ #endregion
}
-}
\ No newline at end of file
+}
diff --git a/STranslate/Utils/GetWordsUtil.cs b/STranslate/Utils/GetWordsUtil.cs
deleted file mode 100644
index 9454d19..0000000
--- a/STranslate/Utils/GetWordsUtil.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-using System.Threading;
-using System.Windows;
-using System.Windows.Input;
-
-namespace STranslate.Utils
-{
- public class GetWords
- {
- public static String Get()
- {
- SendCtrlC();
- Thread.Sleep(200);
- return NativeMethod.GetText();
- }
-
- private static void SendCtrlC()
- {
- //IntPtr hWnd = GetForegroundWindow();
- //SetForegroundWindow(hWnd);
- uint KEYEVENTF_KEYUP = 2;
-
- NativeMethod.keybd_event(System.Windows.Forms.Keys.ControlKey, 0, KEYEVENTF_KEYUP, 0);
- NativeMethod.keybd_event(KeyInterop.VirtualKeyFromKey(Key.LeftAlt), 0, KEYEVENTF_KEYUP, 0);
- NativeMethod.keybd_event(KeyInterop.VirtualKeyFromKey(Key.RightAlt), 0, KEYEVENTF_KEYUP, 0);
- NativeMethod.keybd_event(System.Windows.Forms.Keys.LWin, 0, KEYEVENTF_KEYUP, 0);
- NativeMethod.keybd_event(System.Windows.Forms.Keys.RWin, 0, KEYEVENTF_KEYUP, 0);
- NativeMethod.keybd_event(System.Windows.Forms.Keys.ShiftKey, 0, KEYEVENTF_KEYUP, 0);
-
- NativeMethod.keybd_event(System.Windows.Forms.Keys.ControlKey, 0, 0, 0);
- NativeMethod.keybd_event(System.Windows.Forms.Keys.C, 0, 0, 0);
- NativeMethod.keybd_event(System.Windows.Forms.Keys.C, 0, KEYEVENTF_KEYUP, 0);
- NativeMethod.keybd_event(System.Windows.Forms.Keys.ControlKey, 0, KEYEVENTF_KEYUP, 0);// 'Left Control Up
- }
- }
-}
\ No newline at end of file
diff --git a/STranslate/Utils/HttpUtil.cs b/STranslate/Utils/HttpUtil.cs
deleted file mode 100644
index b858d0d..0000000
--- a/STranslate/Utils/HttpUtil.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using Newtonsoft.Json;
-using STranslate.Model;
-using System;
-using System.IO;
-using System.Net;
-using System.Net.Http;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace STranslate.Utils
-{
- public static class HttpUtil
- {
- public static DeeplResp Post(string url, DeeplReq req)
- {
- //json参数
- string jsonParam = JsonConvert.SerializeObject(req);
- var request = (HttpWebRequest)WebRequest.Create(url);
- request.Method = "POST";
- request.ContentType = "application/json;charset=UTF-8";
- byte[] byteData = Encoding.UTF8.GetBytes(jsonParam);
- int length = byteData.Length;
- request.ContentLength = length;
- Stream writer = request.GetRequestStream();
- writer.Write(byteData, 0, length);
- writer.Close();
- var response = (HttpWebResponse)request.GetResponse();
- var responseString = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")).ReadToEnd();
- var resp = JsonConvert.DeserializeObject(responseString);
- return resp;
- }
-
- ///
- /// 异步Post请求
- ///
- ///
- ///
- ///
- public static async Task PostAsync(string url, string req)
- {
- using (var client = new HttpClient())
- {
- var content = new StringContent(req, Encoding.UTF8, "application/json");
-
- var respContent = await client.PostAsync(url, content);
-
- string respStr = await respContent.Content.ReadAsStringAsync();
- ;
- return respStr;
- }
- }
-
- ///
- /// 异步Get请求
- ///
- ///
- ///
- public static async Task GetAsync(string urlpath)
- {
- using (var client = new HttpClient())
- {
- try
- {
- var respContent = await client.GetAsync(urlpath);
-
- string respStr = await respContent.Content.ReadAsStringAsync();
-
- return respStr;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/STranslate/ViewModel/MainVM.cs b/STranslate/ViewModel/MainVM.cs
index 03a27fd..ecc92bf 100644
--- a/STranslate/ViewModel/MainVM.cs
+++ b/STranslate/ViewModel/MainVM.cs
@@ -1,5 +1,5 @@
using STranslate.Model;
-using STranslate.Utils;
+using STranslate.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -22,7 +22,7 @@ namespace STranslate.ViewModel
OutputComboSelected = LanguageEnum.AUTO.GetDescription();
//初始化接口
- SelectedTranslationInterface = TranslationInterface[0];
+ SelectedTranslationInterface = TranslationInterface[1];
//复制输入
CopyInputCmd = new RelayCommand((_) => true, (_) =>
@@ -97,11 +97,11 @@ namespace STranslate.ViewModel
{
var autoRet = AutomaticLanguageRecognition(InputTxt);
IdentifyLanguage = autoRet.Item1;
- translateResp = await TranslateUtil.TranslateDeepLAsync(SelectedTranslationInterface.Api, InputTxt, LanguageEnumDict[autoRet.Item2], LanguageEnumDict[InputComboSelected]);
+ translateResp = await Util.Util.TranslateDeepLAsync(SelectedTranslationInterface.Api, InputTxt, LanguageEnumDict[autoRet.Item2], LanguageEnumDict[InputComboSelected]);
}
else
{
- translateResp = await TranslateUtil.TranslateDeepLAsync(SelectedTranslationInterface.Api, InputTxt, LanguageEnumDict[OutputComboSelected], LanguageEnumDict[InputComboSelected]);
+ translateResp = await Util.Util.TranslateDeepLAsync(SelectedTranslationInterface.Api, InputTxt, LanguageEnumDict[OutputComboSelected], LanguageEnumDict[InputComboSelected]);
}
//百度 Api
@@ -256,7 +256,7 @@ 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(); }
+ private static Dictionary LanguageEnumDict { get => Util.Util.GetEnumList(); }
#endregion Params
}