mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 19:49:15 +08:00
Misc
This commit is contained in:
parent
6ac33b0568
commit
08571d51fa
@ -66,6 +66,7 @@ namespace Wox
|
|||||||
private async void Setting_Loaded(object sender, RoutedEventArgs ev)
|
private async void Setting_Loaded(object sender, RoutedEventArgs ev)
|
||||||
{
|
{
|
||||||
#region General
|
#region General
|
||||||
|
|
||||||
cbHideWhenDeactive.Checked += (o, e) =>
|
cbHideWhenDeactive.Checked += (o, e) =>
|
||||||
{
|
{
|
||||||
_settings.HideWhenDeactive = true;
|
_settings.HideWhenDeactive = true;
|
||||||
@ -143,6 +144,7 @@ namespace Wox
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region About
|
#region About
|
||||||
|
|
||||||
string activateTimes = string.Format(
|
string activateTimes = string.Format(
|
||||||
InternationalizationManager.Instance.GetTranslation("about_activate_times"), _settings.ActivateTimes);
|
InternationalizationManager.Instance.GetTranslation("about_activate_times"), _settings.ActivateTimes);
|
||||||
ActivatedTimes.Text = activateTimes;
|
ActivatedTimes.Text = activateTimes;
|
||||||
@ -227,7 +229,9 @@ namespace Wox
|
|||||||
|
|
||||||
private void AddApplicationToStartup()
|
private void AddApplicationToStartup()
|
||||||
{
|
{
|
||||||
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
|
using (
|
||||||
|
RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
|
||||||
|
true))
|
||||||
{
|
{
|
||||||
key.SetValue("Wox", "\"" + Application.ExecutablePath + "\" --hidestart");
|
key.SetValue("Wox", "\"" + Application.ExecutablePath + "\" --hidestart");
|
||||||
}
|
}
|
||||||
@ -235,7 +239,9 @@ namespace Wox
|
|||||||
|
|
||||||
private void RemoveApplicationFromStartup()
|
private void RemoveApplicationFromStartup()
|
||||||
{
|
{
|
||||||
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
|
using (
|
||||||
|
RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
|
||||||
|
true))
|
||||||
{
|
{
|
||||||
key.DeleteValue("Wox", false);
|
key.DeleteValue("Wox", false);
|
||||||
}
|
}
|
||||||
@ -243,7 +249,9 @@ namespace Wox
|
|||||||
|
|
||||||
private bool CheckApplicationIsStartupWithWindow()
|
private bool CheckApplicationIsStartupWithWindow()
|
||||||
{
|
{
|
||||||
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
|
using (
|
||||||
|
RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
|
||||||
|
true))
|
||||||
{
|
{
|
||||||
return key.GetValue("Wox") != null;
|
return key.GetValue("Wox") != null;
|
||||||
}
|
}
|
||||||
@ -276,6 +284,7 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Hotkey
|
#region Hotkey
|
||||||
@ -309,7 +318,8 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
|
string errorMsg =
|
||||||
|
string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
|
||||||
MessageBox.Show(errorMsg);
|
MessageBox.Show(errorMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,8 +348,12 @@ namespace Wox
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string deleteWarning = string.Format(InternationalizationManager.Instance.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey);
|
string deleteWarning =
|
||||||
if (MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
string.Format(InternationalizationManager.Instance.GetTranslation("deleteCustomHotkeyWarning"),
|
||||||
|
item.Hotkey);
|
||||||
|
if (
|
||||||
|
MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"),
|
||||||
|
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||||
{
|
{
|
||||||
_settings.CustomPluginHotkeys.Remove(item);
|
_settings.CustomPluginHotkeys.Remove(item);
|
||||||
lvCustomHotkey.Items.Refresh();
|
lvCustomHotkey.Items.Refresh();
|
||||||
@ -396,7 +410,9 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
cbQueryBoxFont.Text = _settings.QueryBoxFont;
|
cbQueryBoxFont.Text = _settings.QueryBoxFont;
|
||||||
|
|
||||||
cbQueryBoxFontFaces.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)cbQueryBoxFont.SelectedItem).ConvertFromInvariantStringsOrNormal(
|
cbQueryBoxFontFaces.SelectedItem =
|
||||||
|
SyntaxSugars.CallOrRescueDefault(
|
||||||
|
() => ((FontFamily)cbQueryBoxFont.SelectedItem).ConvertFromInvariantStringsOrNormal(
|
||||||
_settings.QueryBoxFontStyle,
|
_settings.QueryBoxFontStyle,
|
||||||
_settings.QueryBoxFontWeight,
|
_settings.QueryBoxFontWeight,
|
||||||
_settings.QueryBoxFontStretch
|
_settings.QueryBoxFontStretch
|
||||||
@ -407,7 +423,9 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
ResultFontComboBox.Text = _settings.ResultFont;
|
ResultFontComboBox.Text = _settings.ResultFont;
|
||||||
|
|
||||||
ResultFontFacesComboBox.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)ResultFontComboBox.SelectedItem).ConvertFromInvariantStringsOrNormal(
|
ResultFontFacesComboBox.SelectedItem =
|
||||||
|
SyntaxSugars.CallOrRescueDefault(
|
||||||
|
() => ((FontFamily)ResultFontComboBox.SelectedItem).ConvertFromInvariantStringsOrNormal(
|
||||||
_settings.ResultFontStyle,
|
_settings.ResultFontStyle,
|
||||||
_settings.ResultFontWeight,
|
_settings.ResultFontWeight,
|
||||||
_settings.ResultFontStretch
|
_settings.ResultFontStretch
|
||||||
@ -532,7 +550,8 @@ namespace Wox
|
|||||||
if (!settingsLoaded) return;
|
if (!settingsLoaded) return;
|
||||||
string resultItemFont = ResultFontComboBox.SelectedItem.ToString();
|
string resultItemFont = ResultFontComboBox.SelectedItem.ToString();
|
||||||
_settings.ResultFont = resultItemFont;
|
_settings.ResultFont = resultItemFont;
|
||||||
ResultFontFacesComboBox.SelectedItem = ((FontFamily)ResultFontComboBox.SelectedItem).ChooseRegularFamilyTypeface();
|
ResultFontFacesComboBox.SelectedItem =
|
||||||
|
((FontFamily)ResultFontComboBox.SelectedItem).ChooseRegularFamilyTypeface();
|
||||||
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,7 +589,8 @@ namespace Wox
|
|||||||
pluginInitTime.Text =
|
pluginInitTime.Text =
|
||||||
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_init_time"), pair.InitTime);
|
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_init_time"), pair.InitTime);
|
||||||
pluginQueryTime.Text =
|
pluginQueryTime.Text =
|
||||||
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_query_time"), pair.AvgQueryTime);
|
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_query_time"),
|
||||||
|
pair.AvgQueryTime);
|
||||||
if (actionKeywords.Count > 1)
|
if (actionKeywords.Count > 1)
|
||||||
{
|
{
|
||||||
pluginActionKeywordsTitle.Visibility = Visibility.Collapsed;
|
pluginActionKeywordsTitle.Visibility = Visibility.Collapsed;
|
||||||
@ -585,7 +605,8 @@ namespace Wox
|
|||||||
pluginTitle.Text = pair.Metadata.Name;
|
pluginTitle.Text = pair.Metadata.Name;
|
||||||
pluginTitle.Cursor = Cursors.Hand;
|
pluginTitle.Cursor = Cursors.Hand;
|
||||||
pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, actionKeywords.ToArray());
|
pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, actionKeywords.ToArray());
|
||||||
pluginAuthor.Text = InternationalizationManager.Instance.GetTranslation("author") + ": " + pair.Metadata.Author;
|
pluginAuthor.Text = InternationalizationManager.Instance.GetTranslation("author") + ": " +
|
||||||
|
pair.Metadata.Author;
|
||||||
pluginSubTitle.Text = pair.Metadata.Description;
|
pluginSubTitle.Text = pair.Metadata.Description;
|
||||||
pluginId = pair.Metadata.ID;
|
pluginId = pair.Metadata.ID;
|
||||||
pluginIcon.Source = ImageLoader.Load(pair.Metadata.IcoPath);
|
pluginIcon.Source = ImageLoader.Load(pair.Metadata.IcoPath);
|
||||||
@ -657,7 +678,9 @@ namespace Wox
|
|||||||
ActionKeywords changeKeywordsWindow = new ActionKeywords(id, _settings);
|
ActionKeywords changeKeywordsWindow = new ActionKeywords(id, _settings);
|
||||||
changeKeywordsWindow.ShowDialog();
|
changeKeywordsWindow.ShowDialog();
|
||||||
PluginPair plugin = PluginManager.GetPluginForId(id);
|
PluginPair plugin = PluginManager.GetPluginForId(id);
|
||||||
if (plugin != null) pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, pair.Metadata.ActionKeywords.ToArray());
|
if (plugin != null)
|
||||||
|
pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater,
|
||||||
|
pair.Metadata.ActionKeywords.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -677,7 +700,8 @@ namespace Wox
|
|||||||
Process.Start(pair.Metadata.Website);
|
Process.Start(pair.Metadata.Website);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -698,7 +722,8 @@ namespace Wox
|
|||||||
Process.Start(pair.Metadata.PluginDirectory);
|
Process.Start(pair.Metadata.PluginDirectory);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -725,6 +750,7 @@ namespace Wox
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Proxy
|
#region Proxy
|
||||||
|
|
||||||
private void btnSaveProxy_Click(object sender, RoutedEventArgs e)
|
private void btnSaveProxy_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
_settings.ProxyEnabled = ToggleProxy.IsChecked ?? false;
|
_settings.ProxyEnabled = ToggleProxy.IsChecked ?? false;
|
||||||
@ -827,8 +853,6 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void OnCheckUpdates(object sender, RoutedEventArgs e)
|
private async void OnCheckUpdates(object sender, RoutedEventArgs e)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var version = await NewVersion();
|
var version = await NewVersion();
|
||||||
if (!string.IsNullOrEmpty(version))
|
if (!string.IsNullOrEmpty(version))
|
||||||
@ -839,20 +863,26 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
NewVersionTips.Text = string.Format(NewVersionTips.Text, version);
|
NewVersionTips.Text = string.Format(NewVersionTips.Text, version);
|
||||||
NewVersionTips.Visibility = Visibility.Visible;
|
NewVersionTips.Visibility = Visibility.Visible;
|
||||||
|
UpdateApp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void UpdateApp()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
using (var updater = await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github, prerelease: true))
|
using (var updater = await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github, prerelease: true))
|
||||||
{
|
{
|
||||||
// todo 5/9 the return value of UpdateApp() is NULL, fucking useless!
|
// todo 5/9 the return value of UpdateApp() is NULL, fucking useless!
|
||||||
await updater.UpdateApp();
|
await updater.UpdateApp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Error(ex);
|
Log.Error(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> NewVersion()
|
private async Task<string> NewVersion()
|
||||||
{
|
{
|
||||||
const string githubAPI = @"https://api.github.com/repos/wox-launcher/wox/releases/latest";
|
const string githubAPI = @"https://api.github.com/repos/wox-launcher/wox/releases/latest";
|
||||||
@ -863,7 +893,7 @@ namespace Wox
|
|||||||
JContainer json;
|
JContainer json;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
json = (JContainer) JsonConvert.DeserializeObject(response);
|
json = (JContainer)JsonConvert.DeserializeObject(response);
|
||||||
}
|
}
|
||||||
catch (JsonSerializationException e)
|
catch (JsonSerializationException e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user