diff --git a/VietTypeConfig/Form1.Designer.cs b/VietTypeConfig/Form1.Designer.cs
index 7afa972..76e449d 100644
--- a/VietTypeConfig/Form1.Designer.cs
+++ b/VietTypeConfig/Form1.Designer.cs
@@ -38,6 +38,7 @@ private void InitializeComponent() {
this.btnAbout = new System.Windows.Forms.Button();
this.lblOptimizeMultilang = new System.Windows.Forms.Label();
this.udOptimizeMultilang = new System.Windows.Forms.NumericUpDown();
+ this.cbVietnameseUI = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.settingsBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.udOptimizeMultilang)).BeginInit();
this.SuspendLayout();
@@ -138,12 +139,19 @@ private void InitializeComponent() {
0});
this.udOptimizeMultilang.Name = "udOptimizeMultilang";
//
+ // cbVietnameseUI
+ //
+ resources.ApplyResources(this.cbVietnameseUI, "cbVietnameseUI");
+ this.cbVietnameseUI.Name = "cbVietnameseUI";
+ this.cbVietnameseUI.UseVisualStyleBackColor = true;
+ //
// Form1
//
this.AcceptButton = this.btnOK;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
+ this.Controls.Add(this.cbVietnameseUI);
this.Controls.Add(this.udOptimizeMultilang);
this.Controls.Add(this.lblOptimizeMultilang);
this.Controls.Add(this.label1);
@@ -186,6 +194,7 @@ private void InitializeComponent() {
private System.Windows.Forms.Button btnAbout;
private System.Windows.Forms.Label lblOptimizeMultilang;
private System.Windows.Forms.NumericUpDown udOptimizeMultilang;
+ private System.Windows.Forms.CheckBox cbVietnameseUI;
}
}
diff --git a/VietTypeConfig/Form1.cs b/VietTypeConfig/Form1.cs
index 41f5d5d..2516a3d 100644
--- a/VietTypeConfig/Form1.cs
+++ b/VietTypeConfig/Form1.cs
@@ -1,16 +1,18 @@
// SPDX-FileCopyrightText: Copyright (c) 2022 Dinh Ngoc Tu
// SPDX-License-Identifier: GPL-3.0-only
+using Microsoft.Win32;
using System;
using System.Resources;
using System.Runtime.InteropServices;
+using System.Threading;
using System.Windows.Forms;
using static VietTypeConfig.VietTypeRegistrar;
namespace VietTypeConfig {
public partial class Form1 : Form {
private readonly ResourceManager rm = new ResourceManager(typeof(Form1));
- private bool oobe = false;
+ private readonly bool oobe = false;
public Form1(string[] args) {
if (args.Length > 0) {
@@ -30,6 +32,8 @@ private void Form1_Load(object sender, EventArgs e) {
MessageBox.Show(string.Format(rm.GetString("cannotFindLibraryMessage"), ex.Message), "VietType", MessageBoxButtons.OK, MessageBoxIcon.Error);
Close();
}
+ cbVietnameseUI.Checked = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName == "vi";
+ cbVietnameseUI.CheckedChanged += cbVietnameseUI_CheckedChanged;
}
private void CloseForm(object sender, EventArgs e) {
@@ -62,6 +66,17 @@ private void btnEnable_Click(object sender, EventArgs e) {
Activate(IsProfileActivated() != S_OK);
}
+ private void cbVietnameseUI_CheckedChanged(object sender, EventArgs e) {
+ try {
+ using (var regKey = Registry.CurrentUser.CreateSubKey(Settings.Subkey)) {
+ regKey.SetValue("ui_language", cbVietnameseUI.Checked ? "vi" : "en");
+ Application.Restart();
+ }
+ } catch (Exception ex) {
+ MessageBox.Show(string.Format(rm.GetString("cannotSaveSettingsMessage"), ex.Message), "VietType", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
private void Activate(bool newState) {
var result = newState ? ActivateProfiles() : DeactivateProfiles();
if (result == S_OK) {
diff --git a/VietTypeConfig/Form1.en.resx b/VietTypeConfig/Form1.en.resx
index 8ec874e..f99ecd1 100644
--- a/VietTypeConfig/Form1.en.resx
+++ b/VietTypeConfig/Form1.en.resx
@@ -167,6 +167,9 @@ VietType is free software, licensed under the GNU General Public License. VietTy
&Use "oà", "uý" instead of "òa", "úy"
+
+ Giao diện tiếng &Việt
+
Successfully disabled VietType.
diff --git a/VietTypeConfig/Form1.resx b/VietTypeConfig/Form1.resx
index d12b598..8e81825 100644
--- a/VietTypeConfig/Form1.resx
+++ b/VietTypeConfig/Form1.resx
@@ -129,14 +129,14 @@
- 12, 51
+ 12, 74
320, 17
- 1
+ 2
Vietnamese mode by de&fault
@@ -151,7 +151,7 @@
$this
- 11
+ 12
Top, Left, Right
@@ -160,13 +160,13 @@
NoControl
- 12, 74
+ 12, 97
320, 17
- 2
+ 3
&Use "oà", "uý" instead of "òa", "úy"
@@ -181,7 +181,7 @@
$this
- 10
+ 11
Top, Left, Right
@@ -190,13 +190,13 @@
NoControl
- 12, 97
+ 12, 120
320, 17
- 3
+ 4
Accept 'd' any&where
@@ -211,7 +211,7 @@
$this
- 9
+ 10
Top, Left, Right
@@ -220,13 +220,13 @@
NoControl
- 12, 120
+ 12, 143
320, 17
- 4
+ 5
Backspaced &invalid word stays invalid
@@ -241,7 +241,7 @@
$this
- 8
+ 9
Top, Left, Right
@@ -250,13 +250,13 @@
NoControl
- 12, 143
+ 12, 166
320, 17
- 5
+ 6
&Reconvert word on Backspace (Experimental)
@@ -271,7 +271,7 @@
$this
- 7
+ 8
NoControl
@@ -298,7 +298,7 @@
$this
- 3
+ 4
Top, Left, Right
@@ -307,13 +307,13 @@
NoControl
- 0, 42
+ 0, 64
344, 2
- 11
+ 12
label1
@@ -328,7 +328,7 @@
$this
- 2
+ 3
Bottom, Right
@@ -343,7 +343,7 @@
75, 23
- 8
+ 9
OK
@@ -358,7 +358,7 @@
$this
- 6
+ 7
Bottom, Right
@@ -373,7 +373,7 @@
75, 23
- 9
+ 10
Cancel
@@ -388,7 +388,7 @@
$this
- 5
+ 6
Bottom, Left
@@ -403,7 +403,7 @@
75, 23
- 10
+ 11
A&bout
@@ -418,7 +418,7 @@
$this
- 4
+ 5
True
@@ -427,13 +427,13 @@
NoControl
- 9, 168
+ 9, 191
176, 13
- 6
+ 7
Multilingual typing &optimization level:
@@ -448,19 +448,19 @@
$this
- 1
+ 2
Top, Left, Right
- 212, 166
+ 212, 189
120, 20
- 7
+ 8
udOptimizeMultilang
@@ -472,6 +472,36 @@
$this
+ 1
+
+
+ Top, Left, Right
+
+
+ True
+
+
+ 12, 41
+
+
+ 118, 17
+
+
+ 1
+
+
+ Giao diện tiếng &Việt
+
+
+ cbVietnameseUI
+
+
+ System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ $this
+
+
0
diff --git a/VietTypeConfig/Form1.vi.resx b/VietTypeConfig/Form1.vi.resx
index 9ac7b01..f298f0e 100644
--- a/VietTypeConfig/Form1.vi.resx
+++ b/VietTypeConfig/Form1.vi.resx
@@ -186,4 +186,7 @@ VietType là phần mềm tự do, bạn có thể cung cấp lại và/hoặc c
Đặt VietType làm bộ gõ mặc định?
+
+ &Vietnamese interface
+
\ No newline at end of file
diff --git a/VietTypeConfig/Program.cs b/VietTypeConfig/Program.cs
index b40820f..c0c434f 100644
--- a/VietTypeConfig/Program.cs
+++ b/VietTypeConfig/Program.cs
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2022 Dinh Ngoc Tu
// SPDX-License-Identifier: GPL-3.0-only
+using Microsoft.Win32;
using System;
using System.Globalization;
using System.Threading;
@@ -13,6 +14,14 @@ internal static class Program {
///
[STAThread]
static void Main(string[] args) {
+ using (var regKey = Registry.CurrentUser.CreateSubKey(Settings.Subkey)) {
+ var uiLanguage = regKey.GetValue("ui_language") as string;
+ if (uiLanguage != null) {
+ try {
+ Thread.CurrentThread.CurrentUICulture = new CultureInfo(uiLanguage);
+ } catch { }
+ }
+ }
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1(args));
diff --git a/VietTypeConfig/Settings.cs b/VietTypeConfig/Settings.cs
index 115f1f4..3496d10 100644
--- a/VietTypeConfig/Settings.cs
+++ b/VietTypeConfig/Settings.cs
@@ -7,7 +7,7 @@
namespace VietTypeConfig {
internal class Settings : INotifyPropertyChanged {
- private const string Subkey = "Software\\VietType";
+ public const string Subkey = "Software\\VietType";
private static readonly Guid GUID_SystemNotifyCompartment = Guid.Parse("{B2FBD2E7-922F-4996-BE77-21085B91A8F0}");
private static readonly Guid CLSID_TF_ThreadMgr = Guid.Parse("{529a9e6b-6587-4f23-ab9e-9c7d683e3c50}");
private static readonly Guid CLSID_TextService = Guid.Parse("{c0dd01a1-0deb-454b-8b42-d22ced1b4b23}");