diff --git a/PreferencesDialog.xeto b/PreferencesDialog.xeto index 68d5d4f..a64b56f 100644 --- a/PreferencesDialog.xeto +++ b/PreferencesDialog.xeto @@ -168,7 +168,7 @@ - + @@ -176,7 +176,16 @@ - + + + + + + + + + + diff --git a/PreferencesDialog.xeto.cs b/PreferencesDialog.xeto.cs index 6cdbe82..4f7a98e 100644 --- a/PreferencesDialog.xeto.cs +++ b/PreferencesDialog.xeto.cs @@ -20,6 +20,11 @@ public partial class PreferencesDialog : Dialog public PreferencesDialog() { XamlReader.Load(this); + ApplyUserSettings(); + } + + private void ApplyUserSettings() + { foreach (var setting in userSettings.GetType().GetProperties()) { TextBox settingTextBox = this.FindChild(setting.Name); @@ -81,7 +86,7 @@ private void SaveButton_Click(object sender, EventArgs e) Close(); } - private void HandleSelectMMDB(object sender, EventArgs e) + private void HandleMMDBSelect(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filters.Add(new FileFilter("MaxMind DB", ".mmdb")); @@ -97,7 +102,7 @@ private void HandleSelectMMDB(object sender, EventArgs e) } } - private void HandlePreviewMMDB(object sender, EventArgs e) + private void HandleMMDBPreview(object sender, EventArgs e) { TextBox settingTextBox = this.FindChild("localDBPath"); if (settingTextBox == null || settingTextBox.Text == "") @@ -163,5 +168,41 @@ private void reduceResult(int depth, List result) i++; } } + + private void HandleMMDBPreset(object sender, EventArgs e) + { + + var setting = this.FindChild("localDBPreset"); + switch (setting.SelectedKey) + { + case "geoip2-city": + UserSettings.localDBAddr = "{.country.names.zh-CN} {.subdivisions.0.names.zh-CN} {.city.names.zh-CN}"; + UserSettings.localDBOrg = ""; + UserSettings.localDBLat = "{.location.latitude}"; + UserSettings.localDBLon = "{.location.longitude}"; + UserSettings.localDBASN = ""; + UserSettings.localDBHostname = ""; + break; + case "ipinfo-loc": + UserSettings.localDBAddr = "{.country} {.region} {.city}"; + UserSettings.localDBOrg = ""; + UserSettings.localDBLat = "{.lat}"; + UserSettings.localDBLon = "{.lng}"; + UserSettings.localDBASN = ""; + UserSettings.localDBHostname = ""; + break; + case "ipinfo-org": + UserSettings.localDBAddr = ""; + UserSettings.localDBOrg = "{.name} {.hosting} {.domain}"; + UserSettings.localDBLat = ""; + UserSettings.localDBLon = ""; + UserSettings.localDBASN = ""; + UserSettings.localDBHostname = ""; + break; + default: + return; + } + ApplyUserSettings(); + } } } diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 654c423..d1324f2 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -509,7 +509,7 @@ public static string LINKLOCAL_ADDR { } /// - /// 查找类似 Local MMDB 的本地化字符串。 + /// 查找类似 Local MMDB Overwrite 的本地化字符串。 /// public static string LOCAL_MMDB { get { @@ -580,6 +580,15 @@ public static string LOCAL_MMDB_PATH { } } + /// + /// 查找类似 Presets 的本地化字符串。 + /// + public static string LOCAL_MMDB_PRESETS { + get { + return ResourceManager.GetString("LOCAL_MMDB_PRESETS", resourceCulture); + } + } + /// /// 查找类似 Preview MMDB File 的本地化字符串。 /// @@ -608,8 +617,9 @@ public static string LOCAL_MMDB_SELECT { } /// - /// 查找类似 Template Example: {.country}-{.city} - ///Leave empty to avoid overwrite field 的本地化字符串。 + /// 查找类似 Use MMDB query result overwrite original result + ///Leave empty to avoid overwrite field + ///Template Example: {.country}-{.city} 的本地化字符串。 /// public static string LOCAL_MMDB_TIPS { get { diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 87704d1..ad35c3b 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -259,7 +259,7 @@ Would you like to add a firewall rule to allow needed ICMP for NextTrace?Link-local Address - Local MMDB + Local MMDB Overwrite Address Template @@ -282,6 +282,9 @@ Would you like to add a firewall rule to allow needed ICMP for NextTrace? Local MMDB Path + + Presets + Preview MMDB File @@ -292,8 +295,9 @@ Would you like to add a firewall rule to allow needed ICMP for NextTrace?Select MMDB File - Template Example: {.country}-{.city} -Leave empty to avoid overwrite field + Use MMDB query result overwrite original result +Leave empty to avoid overwrite field +Template Example: {.country}-{.city} Loopback Address diff --git a/Properties/Resources.zh-CN.resx b/Properties/Resources.zh-CN.resx index c727dcb..e29ff7f 100644 --- a/Properties/Resources.zh-CN.resx +++ b/Properties/Resources.zh-CN.resx @@ -255,7 +255,7 @@ 链路本地地址 - 本地 MMDB + 本地 MMDB 覆写 地理位置模板 @@ -278,6 +278,9 @@ 本地 MMDB 路径 + + 预设配置 + 预览 MMDB @@ -288,8 +291,10 @@ 选择 MMDB 文件 - 模板举例: {.country}-{.city} -留空以避免覆写对应字段 + 此功能用本地 MMDB 查询的结果覆盖原查询结果 +留空以避免覆写对应字段 +模板举例: {.country}-{.city} + 本地回环地址 diff --git a/Properties/Resources.zh-HK.resx b/Properties/Resources.zh-HK.resx index e799cf7..49c3f72 100644 --- a/Properties/Resources.zh-HK.resx +++ b/Properties/Resources.zh-HK.resx @@ -278,6 +278,9 @@ 本地 MMDB 路徑 + + 預設配置 + 預覽 MMDB @@ -288,8 +291,9 @@ 選擇 MMDB 文件 - 模板舉例: {.country}-{.city} -留空以避免覆寫對應字段 + 此功能用本地 MMDB 查詢的結果覆蓋原查詢結果 +留空以避免覆寫對應字段 +模板舉例: {.country}-{.city} 本地迴環地址 diff --git a/Properties/Resources.zh-TW.resx b/Properties/Resources.zh-TW.resx index c3af065..c43e3aa 100644 --- a/Properties/Resources.zh-TW.resx +++ b/Properties/Resources.zh-TW.resx @@ -278,6 +278,9 @@ 本地 MMDB 路徑 + + 預設配置 + 預覽 MMDB @@ -288,8 +291,9 @@ 選擇 MMDB 檔案 - 模板舉例: {.country}-{.city} -留空以避免覆寫對應欄位 + 此功能用本地 MMDB 查詢的結果覆蓋原查詢結果 +留空以避免覆寫對應欄位 +模板舉例: {.country}-{.city} 本地迴環地址