2014-03-11 21:40:25 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2014-07-04 15:12:22 +08:00
|
|
|
|
using System.Diagnostics;
|
2014-01-25 18:00:13 +08:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2014-07-18 20:00:55 +08:00
|
|
|
|
using System.Net;
|
2014-01-25 18:00:13 +08:00
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
2015-10-31 07:17:34 +08:00
|
|
|
|
using System.Windows.Data;
|
2014-07-04 12:08:37 +08:00
|
|
|
|
using System.Windows.Input;
|
2014-03-19 22:17:01 +08:00
|
|
|
|
using System.Windows.Media;
|
2014-03-26 15:30:59 +08:00
|
|
|
|
using System.Windows.Media.Imaging;
|
2015-01-14 22:19:44 +08:00
|
|
|
|
using Microsoft.Win32;
|
2016-02-23 05:43:37 +08:00
|
|
|
|
using NHotkey;
|
|
|
|
|
using NHotkey.Wpf;
|
2015-10-31 07:17:34 +08:00
|
|
|
|
using Wox.Core.Plugin;
|
2016-01-08 04:04:37 +08:00
|
|
|
|
using Wox.Core.Resource;
|
2015-01-27 21:51:29 +08:00
|
|
|
|
using Wox.Core.Updater;
|
2015-01-05 22:41:17 +08:00
|
|
|
|
using Wox.Core.UserSettings;
|
2015-10-31 07:17:34 +08:00
|
|
|
|
using Wox.Helper;
|
2016-02-23 05:43:37 +08:00
|
|
|
|
using Wox.Infrastructure.Hotkey;
|
2015-10-31 07:17:34 +08:00
|
|
|
|
using Wox.Plugin;
|
2016-02-23 05:43:37 +08:00
|
|
|
|
using Wox.ViewModel;
|
2015-10-31 07:17:34 +08:00
|
|
|
|
using Application = System.Windows.Forms.Application;
|
2015-11-05 05:49:36 +08:00
|
|
|
|
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
2014-01-25 18:00:13 +08:00
|
|
|
|
|
2014-01-29 18:33:24 +08:00
|
|
|
|
namespace Wox
|
2014-01-25 18:00:13 +08:00
|
|
|
|
{
|
2014-03-20 02:26:00 +08:00
|
|
|
|
public partial class SettingWindow : Window
|
2014-01-25 18:00:13 +08:00
|
|
|
|
{
|
2016-02-12 15:22:01 +08:00
|
|
|
|
public readonly IPublicAPI _api;
|
2016-01-07 05:34:42 +08:00
|
|
|
|
bool settingsLoaded;
|
2014-07-14 23:18:57 +08:00
|
|
|
|
private Dictionary<ISettingProvider, Control> featureControls = new Dictionary<ISettingProvider, Control>();
|
2016-01-07 05:34:42 +08:00
|
|
|
|
private bool themeTabLoaded;
|
2016-04-21 08:53:21 +08:00
|
|
|
|
private Settings _settings;
|
2014-01-25 18:00:13 +08:00
|
|
|
|
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public SettingWindow(IPublicAPI api, Settings settings)
|
2014-01-25 18:00:13 +08:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings = settings;
|
|
|
|
|
_api = api;
|
|
|
|
|
ResultListBoxPreview.DataContext = new ResultsViewModel(_settings, null);
|
2014-01-25 18:00:13 +08:00
|
|
|
|
Loaded += Setting_Loaded;
|
2014-02-22 15:52:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Setting_Loaded(object sender, RoutedEventArgs ev)
|
|
|
|
|
{
|
2014-12-14 23:16:29 +08:00
|
|
|
|
#region General
|
2014-04-13 10:08:33 +08:00
|
|
|
|
cbHideWhenDeactive.Checked += (o, e) =>
|
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.HideWhenDeactive = true;
|
2014-04-13 10:08:33 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cbHideWhenDeactive.Unchecked += (o, e) =>
|
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.HideWhenDeactive = false;
|
2014-04-13 10:08:33 +08:00
|
|
|
|
};
|
|
|
|
|
|
2015-02-20 21:45:42 +08:00
|
|
|
|
cbRememberLastLocation.Checked += (o, e) =>
|
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.RememberLastLaunchLocation = true;
|
2015-02-20 21:45:42 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cbRememberLastLocation.Unchecked += (o, e) =>
|
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.RememberLastLaunchLocation = false;
|
2015-02-20 21:45:42 +08:00
|
|
|
|
};
|
|
|
|
|
|
2014-12-14 23:16:29 +08:00
|
|
|
|
cbDontPromptUpdateMsg.Checked += (o, e) =>
|
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.DontPromptUpdateMsg = true;
|
2014-12-14 23:16:29 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cbDontPromptUpdateMsg.Unchecked += (o, e) =>
|
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.DontPromptUpdateMsg = false;
|
2014-12-14 23:16:29 +08:00
|
|
|
|
};
|
|
|
|
|
|
2015-10-08 07:02:36 +08:00
|
|
|
|
cbIgnoreHotkeysOnFullscreen.Checked += (o, e) =>
|
2015-10-08 06:17:37 +08:00
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.IgnoreHotkeysOnFullscreen = true;
|
2015-10-08 06:17:37 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2015-10-08 07:02:36 +08:00
|
|
|
|
cbIgnoreHotkeysOnFullscreen.Unchecked += (o, e) =>
|
2015-10-08 06:17:37 +08:00
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.IgnoreHotkeysOnFullscreen = false;
|
2015-10-08 06:17:37 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2015-01-14 22:19:44 +08:00
|
|
|
|
cbStartWithWindows.IsChecked = CheckApplicationIsStartupWithWindow();
|
2015-07-13 03:13:30 +08:00
|
|
|
|
comboMaxResultsToShow.SelectionChanged += (o, e) =>
|
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.MaxResultsToShow = (int)comboMaxResultsToShow.SelectedItem;
|
2016-02-18 19:32:48 +08:00
|
|
|
|
//MainWindow.pnlResult.lbResults.GetBindingExpression(MaxHeightProperty).UpdateTarget();
|
2015-07-13 03:13:30 +08:00
|
|
|
|
};
|
|
|
|
|
|
2016-03-28 10:09:57 +08:00
|
|
|
|
cbHideWhenDeactive.IsChecked = _settings.HideWhenDeactive;
|
|
|
|
|
cbDontPromptUpdateMsg.IsChecked = _settings.DontPromptUpdateMsg;
|
|
|
|
|
cbRememberLastLocation.IsChecked = _settings.RememberLastLaunchLocation;
|
|
|
|
|
cbIgnoreHotkeysOnFullscreen.IsChecked = _settings.IgnoreHotkeysOnFullscreen;
|
2014-06-30 21:31:13 +08:00
|
|
|
|
|
2015-01-02 16:16:09 +08:00
|
|
|
|
LoadLanguages();
|
2015-07-13 03:13:30 +08:00
|
|
|
|
comboMaxResultsToShow.ItemsSource = Enumerable.Range(2, 16);
|
2016-03-28 10:09:57 +08:00
|
|
|
|
var maxResults = _settings.MaxResultsToShow;
|
2015-07-13 03:13:30 +08:00
|
|
|
|
comboMaxResultsToShow.SelectedItem = maxResults == 0 ? 6 : maxResults;
|
2015-01-02 16:16:09 +08:00
|
|
|
|
|
2014-12-14 23:16:29 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
2014-07-18 20:00:55 +08:00
|
|
|
|
#region Proxy
|
|
|
|
|
|
|
|
|
|
cbEnableProxy.Checked += (o, e) => EnableProxy();
|
|
|
|
|
cbEnableProxy.Unchecked += (o, e) => DisableProxy();
|
2016-03-28 10:09:57 +08:00
|
|
|
|
cbEnableProxy.IsChecked = _settings.ProxyEnabled;
|
|
|
|
|
tbProxyServer.Text = _settings.ProxyServer;
|
|
|
|
|
if (_settings.ProxyPort != 0)
|
2015-11-06 10:29:32 +08:00
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
tbProxyPort.Text = _settings.ProxyPort.ToString();
|
2015-08-27 19:38:07 +08:00
|
|
|
|
}
|
2016-03-28 10:09:57 +08:00
|
|
|
|
tbProxyUserName.Text = _settings.ProxyUserName;
|
|
|
|
|
tbProxyPassword.Password = _settings.ProxyPassword;
|
|
|
|
|
if (_settings.ProxyEnabled)
|
2014-07-18 20:00:55 +08:00
|
|
|
|
{
|
|
|
|
|
EnableProxy();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DisableProxy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-12-16 22:25:22 +08:00
|
|
|
|
#region About
|
|
|
|
|
|
2015-01-27 21:51:29 +08:00
|
|
|
|
tbVersion.Text = UpdaterManager.Instance.CurrentVersion.ToString();
|
2015-01-23 21:52:46 +08:00
|
|
|
|
string activateTimes = string.Format(InternationalizationManager.Instance.GetTranslation("about_activate_times"),
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.ActivateTimes);
|
2015-01-23 21:52:46 +08:00
|
|
|
|
tbActivatedTimes.Text = activateTimes;
|
2014-12-16 22:25:22 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-03-25 13:25:43 +08:00
|
|
|
|
settingsLoaded = true;
|
2014-01-25 18:00:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-21 21:57:00 +08:00
|
|
|
|
public void SwitchTo(string tabName)
|
|
|
|
|
{
|
|
|
|
|
switch (tabName)
|
|
|
|
|
{
|
|
|
|
|
case "general":
|
|
|
|
|
settingTab.SelectedIndex = 0;
|
|
|
|
|
break;
|
|
|
|
|
case "plugin":
|
|
|
|
|
settingTab.SelectedIndex = 1;
|
|
|
|
|
break;
|
|
|
|
|
case "theme":
|
|
|
|
|
settingTab.SelectedIndex = 2;
|
|
|
|
|
break;
|
|
|
|
|
case "hotkey":
|
|
|
|
|
settingTab.SelectedIndex = 3;
|
|
|
|
|
break;
|
|
|
|
|
case "proxy":
|
|
|
|
|
settingTab.SelectedIndex = 4;
|
|
|
|
|
break;
|
|
|
|
|
case "about":
|
|
|
|
|
settingTab.SelectedIndex = 5;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-26 04:43:09 +08:00
|
|
|
|
private void settingTab_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Update controls inside the selected tab
|
2015-10-06 20:46:12 +08:00
|
|
|
|
if (e.OriginalSource != settingTab) return;
|
2015-09-26 04:43:09 +08:00
|
|
|
|
|
|
|
|
|
if (tabPlugin.IsSelected)
|
|
|
|
|
{
|
|
|
|
|
OnPluginTabSelected();
|
|
|
|
|
}
|
|
|
|
|
else if (tabTheme.IsSelected)
|
|
|
|
|
{
|
|
|
|
|
OnThemeTabSelected();
|
|
|
|
|
}
|
|
|
|
|
else if (tabHotkey.IsSelected)
|
|
|
|
|
{
|
|
|
|
|
OnHotkeyTabSelected();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-07 21:27:48 +08:00
|
|
|
|
#region General
|
|
|
|
|
|
2015-01-02 16:16:09 +08:00
|
|
|
|
private void LoadLanguages()
|
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
cbLanguages.ItemsSource = InternationalizationManager.Instance.LoadAvailableLanguages();
|
2015-01-03 15:20:34 +08:00
|
|
|
|
cbLanguages.DisplayMemberPath = "Display";
|
|
|
|
|
cbLanguages.SelectedValuePath = "LanguageCode";
|
2016-03-28 10:09:57 +08:00
|
|
|
|
cbLanguages.SelectedValue = _settings.Language;
|
2015-01-02 16:16:09 +08:00
|
|
|
|
cbLanguages.SelectionChanged += cbLanguages_SelectionChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void cbLanguages_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
InternationalizationManager.Instance.ChangeLanguage(cbLanguages.SelectedItem as Language);
|
2015-01-02 16:16:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-06 22:22:02 +08:00
|
|
|
|
private void CbStartWithWindows_OnChecked(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2015-01-14 22:19:44 +08:00
|
|
|
|
AddApplicationToStartup();
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.StartWoxOnSystemStartup = true;
|
2014-02-06 22:22:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CbStartWithWindows_OnUnchecked(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2015-01-14 22:19:44 +08:00
|
|
|
|
RemoveApplicationFromStartup();
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.StartWoxOnSystemStartup = false;
|
2015-01-14 22:19:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddApplicationToStartup()
|
|
|
|
|
{
|
|
|
|
|
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
|
2014-03-11 21:40:25 +08:00
|
|
|
|
{
|
2015-01-14 22:19:44 +08:00
|
|
|
|
key.SetValue("Wox", "\"" + Application.ExecutablePath + "\" --hidestart");
|
2014-03-11 21:40:25 +08:00
|
|
|
|
}
|
2015-01-14 22:19:44 +08:00
|
|
|
|
}
|
2014-03-19 01:20:51 +08:00
|
|
|
|
|
2015-01-14 22:19:44 +08:00
|
|
|
|
private void RemoveApplicationFromStartup()
|
|
|
|
|
{
|
|
|
|
|
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
|
|
|
|
|
{
|
|
|
|
|
key.DeleteValue("Wox", false);
|
|
|
|
|
}
|
2014-02-06 22:22:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-14 22:19:44 +08:00
|
|
|
|
private bool CheckApplicationIsStartupWithWindow()
|
2014-02-06 22:22:02 +08:00
|
|
|
|
{
|
2015-01-14 22:19:44 +08:00
|
|
|
|
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
|
|
|
|
|
{
|
|
|
|
|
return key.GetValue("Wox") != null;
|
|
|
|
|
}
|
2014-02-06 22:22:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-07 21:27:48 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Hotkey
|
|
|
|
|
|
2016-01-07 05:34:42 +08:00
|
|
|
|
void ctlHotkey_OnHotkeyChanged(object sender, EventArgs e)
|
2014-02-22 15:52:20 +08:00
|
|
|
|
{
|
|
|
|
|
if (ctlHotkey.CurrentHotkeyAvailable)
|
|
|
|
|
{
|
2016-02-12 15:22:01 +08:00
|
|
|
|
SetHotkey(ctlHotkey.CurrentHotkey, delegate
|
|
|
|
|
{
|
|
|
|
|
if (!App.Window.IsVisible)
|
|
|
|
|
{
|
2016-02-21 23:42:37 +08:00
|
|
|
|
_api.ShowApp();
|
2016-02-12 15:22:01 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-02-21 23:42:37 +08:00
|
|
|
|
_api.HideApp();
|
2016-02-12 15:22:01 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2016-03-28 10:09:57 +08:00
|
|
|
|
RemoveHotkey(_settings.Hotkey);
|
|
|
|
|
_settings.Hotkey = ctlHotkey.CurrentHotkey.ToString();
|
2014-02-22 15:52:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 15:22:01 +08:00
|
|
|
|
void SetHotkey(HotkeyModel hotkey, EventHandler<HotkeyEventArgs> action)
|
|
|
|
|
{
|
|
|
|
|
string hotkeyStr = hotkey.ToString();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
HotkeyManager.Current.AddOrReplace(hotkeyStr, hotkey.CharKey, hotkey.ModifierKeys, action);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
|
|
|
|
|
MessageBox.Show(errorMsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RemoveHotkey(string hotkeyStr)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(hotkeyStr))
|
|
|
|
|
{
|
|
|
|
|
HotkeyManager.Current.Remove(hotkeyStr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-07 21:27:48 +08:00
|
|
|
|
private void OnHotkeyTabSelected()
|
|
|
|
|
{
|
2015-06-07 11:45:06 +08:00
|
|
|
|
ctlHotkey.HotkeyChanged += ctlHotkey_OnHotkeyChanged;
|
2016-03-28 10:09:57 +08:00
|
|
|
|
ctlHotkey.SetHotkey(_settings.Hotkey, false);
|
|
|
|
|
lvCustomHotkey.ItemsSource = _settings.CustomPluginHotkeys;
|
2015-02-07 21:27:48 +08:00
|
|
|
|
}
|
2014-02-22 15:52:20 +08:00
|
|
|
|
|
|
|
|
|
private void BtnDeleteCustomHotkey_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey;
|
2015-01-02 16:16:09 +08:00
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
|
2015-01-02 16:16:09 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-21 23:00:56 +08:00
|
|
|
|
string deleteWarning = string.Format(InternationalizationManager.Instance.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey);
|
|
|
|
|
if (MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
2014-02-22 15:52:20 +08:00
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.CustomPluginHotkeys.Remove(item);
|
2014-02-22 15:52:20 +08:00
|
|
|
|
lvCustomHotkey.Items.Refresh();
|
2016-02-12 15:22:01 +08:00
|
|
|
|
RemoveHotkey(item.Hotkey);
|
2014-02-22 15:52:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnEditCustomHotkey_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey;
|
|
|
|
|
if (item != null)
|
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
CustomQueryHotkeySetting window = new CustomQueryHotkeySetting(this, _settings);
|
2014-02-22 15:52:20 +08:00
|
|
|
|
window.UpdateItem(item);
|
|
|
|
|
window.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
|
2014-02-22 15:52:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnAddCustomeHotkey_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
new CustomQueryHotkeySetting(this, _settings).ShowDialog();
|
2014-02-22 15:52:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ReloadCustomPluginHotkeyView()
|
|
|
|
|
{
|
|
|
|
|
lvCustomHotkey.Items.Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-03-19 22:17:01 +08:00
|
|
|
|
#region Theme
|
2015-02-07 21:27:48 +08:00
|
|
|
|
|
|
|
|
|
private void tbMoreThemes_MouseUp(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Process.Start("http://www.getwox.com/theme");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnThemeTabSelected()
|
|
|
|
|
{
|
2015-11-05 05:49:36 +08:00
|
|
|
|
Stopwatch.Debug("theme load", () =>
|
2015-02-08 10:38:32 +08:00
|
|
|
|
{
|
|
|
|
|
var s = Fonts.SystemFontFamilies;
|
2015-11-05 05:35:04 +08:00
|
|
|
|
});
|
2015-02-08 10:38:32 +08:00
|
|
|
|
|
2015-02-07 21:27:48 +08:00
|
|
|
|
if (themeTabLoaded) return;
|
|
|
|
|
|
|
|
|
|
themeTabLoaded = true;
|
2016-03-28 10:09:57 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(_settings.QueryBoxFont) &&
|
|
|
|
|
Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(_settings.QueryBoxFont)) > 0)
|
2015-02-07 21:27:48 +08:00
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
cbQueryBoxFont.Text = _settings.QueryBoxFont;
|
2015-02-07 21:27:48 +08:00
|
|
|
|
|
|
|
|
|
cbQueryBoxFontFaces.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)cbQueryBoxFont.SelectedItem).ConvertFromInvariantStringsOrNormal(
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.QueryBoxFontStyle,
|
|
|
|
|
_settings.QueryBoxFontWeight,
|
|
|
|
|
_settings.QueryBoxFontStretch
|
2015-02-07 21:27:48 +08:00
|
|
|
|
));
|
|
|
|
|
}
|
2016-03-28 10:09:57 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(_settings.ResultFont) &&
|
|
|
|
|
Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(_settings.ResultFont)) > 0)
|
2015-02-07 21:27:48 +08:00
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
ResultFontComboBox.Text = _settings.ResultFont;
|
2015-02-07 21:27:48 +08:00
|
|
|
|
|
2016-02-21 23:19:42 +08:00
|
|
|
|
ResultFontFacesComboBox.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)ResultFontComboBox.SelectedItem).ConvertFromInvariantStringsOrNormal(
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.ResultFontStyle,
|
|
|
|
|
_settings.ResultFontWeight,
|
|
|
|
|
_settings.ResultFontStretch
|
2015-02-07 21:27:48 +08:00
|
|
|
|
));
|
|
|
|
|
}
|
2015-02-08 10:38:32 +08:00
|
|
|
|
|
2016-02-21 22:22:34 +08:00
|
|
|
|
ResultListBoxPreview.AddResults(new List<Result>
|
2015-02-07 21:27:48 +08:00
|
|
|
|
{
|
2016-01-07 05:34:42 +08:00
|
|
|
|
new Result
|
2015-02-07 21:27:48 +08:00
|
|
|
|
{
|
|
|
|
|
Title = "Wox is an effective launcher for windows",
|
|
|
|
|
SubTitle = "Wox provide bundles of features let you access infomations quickly.",
|
|
|
|
|
IcoPath = "Images/app.png",
|
2016-01-07 05:34:42 +08:00
|
|
|
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
2015-02-07 21:27:48 +08:00
|
|
|
|
},
|
2016-01-07 05:34:42 +08:00
|
|
|
|
new Result
|
2015-02-07 21:27:48 +08:00
|
|
|
|
{
|
|
|
|
|
Title = "Search applications",
|
|
|
|
|
SubTitle = "Search applications, files (via everything plugin) and browser bookmarks",
|
|
|
|
|
IcoPath = "Images/app.png",
|
2016-01-07 05:34:42 +08:00
|
|
|
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
2015-02-07 21:27:48 +08:00
|
|
|
|
},
|
2016-01-07 05:34:42 +08:00
|
|
|
|
new Result
|
2015-02-07 21:27:48 +08:00
|
|
|
|
{
|
|
|
|
|
Title = "Search web contents with shortcuts",
|
|
|
|
|
SubTitle = "e.g. search google with g keyword or youtube keyword)",
|
|
|
|
|
IcoPath = "Images/app.png",
|
|
|
|
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
|
|
|
|
},
|
2016-01-07 05:34:42 +08:00
|
|
|
|
new Result
|
2015-02-07 21:27:48 +08:00
|
|
|
|
{
|
|
|
|
|
Title = "clipboard history ",
|
|
|
|
|
IcoPath = "Images/app.png",
|
|
|
|
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
|
|
|
|
},
|
2016-01-07 05:34:42 +08:00
|
|
|
|
new Result
|
2015-02-07 21:27:48 +08:00
|
|
|
|
{
|
|
|
|
|
Title = "Themes support",
|
|
|
|
|
SubTitle = "get more themes from http://www.getwox.com/theme",
|
|
|
|
|
IcoPath = "Images/app.png",
|
|
|
|
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
|
|
|
|
},
|
2016-01-07 05:34:42 +08:00
|
|
|
|
new Result
|
2015-02-07 21:27:48 +08:00
|
|
|
|
{
|
|
|
|
|
Title = "Plugins support",
|
|
|
|
|
SubTitle = "get more plugins from http://www.getwox.com/plugin",
|
|
|
|
|
IcoPath = "Images/app.png",
|
|
|
|
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
|
|
|
|
},
|
2016-01-07 05:34:42 +08:00
|
|
|
|
new Result
|
2015-02-07 21:27:48 +08:00
|
|
|
|
{
|
|
|
|
|
Title = "Wox is an open-source software",
|
|
|
|
|
SubTitle = "Wox benefits from the open-source community a lot",
|
|
|
|
|
IcoPath = "Images/app.png",
|
|
|
|
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
|
|
|
|
}
|
2016-03-28 10:09:57 +08:00
|
|
|
|
});
|
2015-02-07 21:27:48 +08:00
|
|
|
|
|
2016-03-28 10:09:57 +08:00
|
|
|
|
foreach (string theme in ThemeManager.Instance.LoadAvailableThemes())
|
2015-02-07 21:27:48 +08:00
|
|
|
|
{
|
2016-01-07 05:34:42 +08:00
|
|
|
|
string themeName = Path.GetFileNameWithoutExtension(theme);
|
2015-02-07 21:27:48 +08:00
|
|
|
|
themeComboBox.Items.Add(themeName);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-28 10:09:57 +08:00
|
|
|
|
themeComboBox.SelectedItem = _settings.Theme;
|
2015-02-07 21:27:48 +08:00
|
|
|
|
|
|
|
|
|
var wallpaper = WallpaperPathRetrieval.GetWallpaperPath();
|
|
|
|
|
if (wallpaper != null && File.Exists(wallpaper))
|
|
|
|
|
{
|
2015-12-14 04:43:58 +08:00
|
|
|
|
var memStream = new MemoryStream(File.ReadAllBytes(wallpaper));
|
|
|
|
|
var bitmap = new BitmapImage();
|
|
|
|
|
bitmap.BeginInit();
|
|
|
|
|
bitmap.StreamSource = memStream;
|
|
|
|
|
bitmap.EndInit();
|
|
|
|
|
var brush = new ImageBrush(bitmap);
|
2015-02-07 21:27:48 +08:00
|
|
|
|
brush.Stretch = Stretch.UniformToFill;
|
|
|
|
|
PreviewPanel.Background = brush;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var wallpaperColor = WallpaperPathRetrieval.GetWallpaperColor();
|
|
|
|
|
PreviewPanel.Background = new SolidColorBrush(wallpaperColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-19 22:17:01 +08:00
|
|
|
|
private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string themeName = themeComboBox.SelectedItem.ToString();
|
2016-03-28 10:09:57 +08:00
|
|
|
|
ThemeManager.Instance.ChangeTheme(themeName);
|
2014-03-19 22:17:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CbQueryBoxFont_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
2014-03-25 13:25:43 +08:00
|
|
|
|
if (!settingsLoaded) return;
|
2014-03-19 22:17:01 +08:00
|
|
|
|
string queryBoxFontName = cbQueryBoxFont.SelectedItem.ToString();
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.QueryBoxFont = queryBoxFontName;
|
2016-01-07 05:34:42 +08:00
|
|
|
|
cbQueryBoxFontFaces.SelectedItem = ((FontFamily)cbQueryBoxFont.SelectedItem).ChooseRegularFamilyTypeface();
|
2016-03-28 10:09:57 +08:00
|
|
|
|
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
2015-02-08 10:38:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-25 13:25:43 +08:00
|
|
|
|
private void CbQueryBoxFontFaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!settingsLoaded) return;
|
2014-07-14 23:18:57 +08:00
|
|
|
|
FamilyTypeface typeface = (FamilyTypeface)cbQueryBoxFontFaces.SelectedItem;
|
2014-03-26 15:30:59 +08:00
|
|
|
|
if (typeface == null)
|
|
|
|
|
{
|
|
|
|
|
if (cbQueryBoxFontFaces.Items.Count > 0)
|
|
|
|
|
cbQueryBoxFontFaces.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.QueryBoxFontStretch = typeface.Stretch.ToString();
|
|
|
|
|
_settings.QueryBoxFontWeight = typeface.Weight.ToString();
|
|
|
|
|
_settings.QueryBoxFontStyle = typeface.Style.ToString();
|
|
|
|
|
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
2014-03-26 15:30:59 +08:00
|
|
|
|
}
|
2014-03-19 22:17:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-21 23:19:42 +08:00
|
|
|
|
private void OnResultFontSelectionChanged(object sender, SelectionChangedEventArgs e)
|
2014-03-19 22:17:01 +08:00
|
|
|
|
{
|
2014-03-25 13:25:43 +08:00
|
|
|
|
if (!settingsLoaded) return;
|
2016-02-21 23:19:42 +08:00
|
|
|
|
string resultItemFont = ResultFontComboBox.SelectedItem.ToString();
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.ResultFont = resultItemFont;
|
2016-02-21 23:19:42 +08:00
|
|
|
|
ResultFontFacesComboBox.SelectedItem = ((FontFamily)ResultFontComboBox.SelectedItem).ChooseRegularFamilyTypeface();
|
2016-03-28 10:09:57 +08:00
|
|
|
|
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
2014-03-19 22:17:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-21 23:19:42 +08:00
|
|
|
|
private void OnResultFontFacesSelectionChanged(object sender, SelectionChangedEventArgs e)
|
2014-03-25 13:25:43 +08:00
|
|
|
|
{
|
|
|
|
|
if (!settingsLoaded) return;
|
2016-02-21 23:19:42 +08:00
|
|
|
|
FamilyTypeface typeface = (FamilyTypeface)ResultFontFacesComboBox.SelectedItem;
|
2014-03-26 15:30:59 +08:00
|
|
|
|
if (typeface == null)
|
|
|
|
|
{
|
2016-02-21 23:19:42 +08:00
|
|
|
|
if (ResultFontFacesComboBox.Items.Count > 0)
|
|
|
|
|
ResultFontFacesComboBox.SelectedIndex = 0;
|
2014-03-26 15:30:59 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.ResultFontStretch = typeface.Stretch.ToString();
|
|
|
|
|
_settings.ResultFontWeight = typeface.Weight.ToString();
|
|
|
|
|
_settings.ResultFontStyle = typeface.Style.ToString();
|
|
|
|
|
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
2014-03-26 15:30:59 +08:00
|
|
|
|
}
|
2014-03-25 13:25:43 +08:00
|
|
|
|
}
|
2014-03-26 17:34:19 +08:00
|
|
|
|
|
2014-03-19 22:17:01 +08:00
|
|
|
|
#endregion
|
2014-03-26 17:34:19 +08:00
|
|
|
|
|
2015-02-07 21:27:48 +08:00
|
|
|
|
#region Plugin
|
2014-03-26 17:34:19 +08:00
|
|
|
|
|
2015-11-09 11:20:02 +08:00
|
|
|
|
private void lbPlugins_OnSelectionChanged(object sender, SelectionChangedEventArgs _)
|
2014-03-28 22:42:28 +08:00
|
|
|
|
{
|
2015-11-09 11:20:02 +08:00
|
|
|
|
|
2014-06-30 18:12:45 +08:00
|
|
|
|
var pair = lbPlugins.SelectedItem as PluginPair;
|
2014-07-01 22:19:46 +08:00
|
|
|
|
string pluginId = string.Empty;
|
2015-11-09 11:20:02 +08:00
|
|
|
|
List<string> actionKeywords = null;
|
|
|
|
|
if (pair == null) return;
|
|
|
|
|
actionKeywords = pair.Metadata.ActionKeywords;
|
|
|
|
|
pluginAuthor.Visibility = Visibility.Visible;
|
|
|
|
|
pluginInitTime.Text =
|
|
|
|
|
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_init_time"), pair.InitTime);
|
|
|
|
|
pluginQueryTime.Text =
|
|
|
|
|
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_query_time"), pair.AvgQueryTime);
|
|
|
|
|
if (actionKeywords.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
pluginActionKeywordsTitle.Visibility = Visibility.Collapsed;
|
|
|
|
|
pluginActionKeywords.Visibility = Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
else
|
2014-03-29 15:52:57 +08:00
|
|
|
|
{
|
2015-11-09 11:20:02 +08:00
|
|
|
|
pluginActionKeywordsTitle.Visibility = Visibility.Visible;
|
|
|
|
|
pluginActionKeywords.Visibility = Visibility.Visible;
|
2014-03-29 15:52:57 +08:00
|
|
|
|
}
|
2015-11-09 11:20:02 +08:00
|
|
|
|
tbOpenPluginDirecoty.Visibility = Visibility.Visible;
|
|
|
|
|
pluginTitle.Text = pair.Metadata.Name;
|
|
|
|
|
pluginTitle.Cursor = Cursors.Hand;
|
|
|
|
|
pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, actionKeywords.ToArray());
|
|
|
|
|
pluginAuthor.Text = InternationalizationManager.Instance.GetTranslation("author") + ": " + pair.Metadata.Author;
|
|
|
|
|
pluginSubTitle.Text = pair.Metadata.Description;
|
|
|
|
|
pluginId = pair.Metadata.ID;
|
2016-04-22 06:37:40 +08:00
|
|
|
|
pluginIcon.Source = App.ImageLoader.Load(pair.Metadata.FullIcoPath);
|
2014-03-29 15:52:57 +08:00
|
|
|
|
|
2016-04-21 08:53:21 +08:00
|
|
|
|
var customizedPluginConfig = _settings.PluginSettings[pluginId];
|
2014-07-01 22:19:46 +08:00
|
|
|
|
cbDisablePlugin.IsChecked = customizedPluginConfig != null && customizedPluginConfig.Disabled;
|
|
|
|
|
|
|
|
|
|
PluginContentPanel.Content = null;
|
2015-11-09 11:20:02 +08:00
|
|
|
|
var settingProvider = pair.Plugin as ISettingProvider;
|
|
|
|
|
if (settingProvider != null)
|
2014-03-29 15:52:57 +08:00
|
|
|
|
{
|
2015-11-09 11:20:02 +08:00
|
|
|
|
Control control;
|
|
|
|
|
if (!featureControls.TryGetValue(settingProvider, out control))
|
|
|
|
|
{
|
|
|
|
|
var multipleActionKeywordsProvider = settingProvider as IMultipleActionKeywords;
|
|
|
|
|
if (multipleActionKeywordsProvider != null)
|
|
|
|
|
{
|
|
|
|
|
multipleActionKeywordsProvider.ActionKeywordsChanged += (o, e) =>
|
|
|
|
|
{
|
|
|
|
|
// update in-memory data
|
|
|
|
|
PluginManager.UpdateActionKeywordForPlugin(pair, e.OldActionKeyword, e.NewActionKeyword);
|
|
|
|
|
// update persistant data
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.UpdateActionKeyword(pair.Metadata);
|
2015-11-09 11:20:02 +08:00
|
|
|
|
|
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed"));
|
|
|
|
|
};
|
|
|
|
|
}
|
2014-03-29 15:52:57 +08:00
|
|
|
|
|
2015-11-09 11:20:02 +08:00
|
|
|
|
featureControls.Add(settingProvider, control = settingProvider.CreateSettingPanel());
|
|
|
|
|
}
|
2014-03-29 15:52:57 +08:00
|
|
|
|
PluginContentPanel.Content = control;
|
|
|
|
|
control.HorizontalAlignment = HorizontalAlignment.Stretch;
|
|
|
|
|
control.VerticalAlignment = VerticalAlignment.Stretch;
|
|
|
|
|
control.Width = Double.NaN;
|
|
|
|
|
control.Height = Double.NaN;
|
|
|
|
|
}
|
2014-03-28 22:42:28 +08:00
|
|
|
|
}
|
2014-07-01 22:19:46 +08:00
|
|
|
|
|
|
|
|
|
private void CbDisablePlugin_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CheckBox cbDisabled = e.Source as CheckBox;
|
|
|
|
|
if (cbDisabled == null) return;
|
|
|
|
|
|
|
|
|
|
var pair = lbPlugins.SelectedItem as PluginPair;
|
|
|
|
|
if (pair != null)
|
|
|
|
|
{
|
2016-04-21 08:53:21 +08:00
|
|
|
|
var id = pair.Metadata.ID;
|
|
|
|
|
var customizedPluginConfig = _settings.PluginSettings[id];
|
|
|
|
|
if (customizedPluginConfig.Disabled)
|
2014-07-01 22:19:46 +08:00
|
|
|
|
{
|
2016-04-21 08:53:21 +08:00
|
|
|
|
PluginManager.DisablePlugin(pair);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PluginManager.EnablePlugin(pair);
|
|
|
|
|
}
|
2014-07-01 22:19:46 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-04 12:08:37 +08:00
|
|
|
|
|
2015-11-05 06:49:40 +08:00
|
|
|
|
private void PluginActionKeywords_OnMouseUp(object sender, MouseButtonEventArgs e)
|
2014-07-04 12:08:37 +08:00
|
|
|
|
{
|
|
|
|
|
if (e.ChangedButton == MouseButton.Left)
|
|
|
|
|
{
|
|
|
|
|
var pair = lbPlugins.SelectedItem as PluginPair;
|
|
|
|
|
if (pair != null)
|
|
|
|
|
{
|
|
|
|
|
//third-party plugin
|
|
|
|
|
string id = pair.Metadata.ID;
|
2016-03-28 10:09:57 +08:00
|
|
|
|
ActionKeywords changeKeywordsWindow = new ActionKeywords(id, _settings);
|
2015-11-05 06:49:40 +08:00
|
|
|
|
changeKeywordsWindow.ShowDialog();
|
2015-11-06 04:44:14 +08:00
|
|
|
|
PluginPair plugin = PluginManager.GetPluginForId(id);
|
2015-11-06 10:29:32 +08:00
|
|
|
|
if (plugin != null) pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, pair.Metadata.ActionKeywords.ToArray());
|
2014-07-04 12:08:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-04 15:12:22 +08:00
|
|
|
|
|
|
|
|
|
private void PluginTitle_OnMouseUp(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
2014-07-14 23:18:57 +08:00
|
|
|
|
if (e.ChangedButton == MouseButton.Left)
|
2014-07-04 15:12:22 +08:00
|
|
|
|
{
|
|
|
|
|
var pair = lbPlugins.SelectedItem as PluginPair;
|
|
|
|
|
if (pair != null)
|
|
|
|
|
{
|
|
|
|
|
//third-party plugin
|
|
|
|
|
if (!string.IsNullOrEmpty(pair.Metadata.Website))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Process.Start(pair.Metadata.Website);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{ }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-14 23:18:57 +08:00
|
|
|
|
|
|
|
|
|
private void tbOpenPluginDirecoty_MouseUp(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.ChangedButton == MouseButton.Left)
|
|
|
|
|
{
|
|
|
|
|
var pair = lbPlugins.SelectedItem as PluginPair;
|
|
|
|
|
if (pair != null)
|
|
|
|
|
{
|
|
|
|
|
//third-party plugin
|
|
|
|
|
if (!string.IsNullOrEmpty(pair.Metadata.Website))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2014-07-16 20:17:51 +08:00
|
|
|
|
Process.Start(pair.Metadata.PluginDirectory);
|
2014-07-14 23:18:57 +08:00
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{ }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-16 20:17:51 +08:00
|
|
|
|
|
|
|
|
|
private void tbMorePlugins_MouseUp(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Process.Start("http://www.getwox.com/plugin");
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-07 21:27:48 +08:00
|
|
|
|
private void OnPluginTabSelected()
|
2014-07-16 20:17:51 +08:00
|
|
|
|
{
|
2015-02-07 21:27:48 +08:00
|
|
|
|
var plugins = new CompositeCollection
|
|
|
|
|
{
|
|
|
|
|
new CollectionContainer
|
|
|
|
|
{
|
|
|
|
|
Collection = PluginManager.AllPlugins
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
lbPlugins.ItemsSource = plugins;
|
|
|
|
|
lbPlugins.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Proxy
|
2014-07-18 20:00:55 +08:00
|
|
|
|
private void btnSaveProxy_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.ProxyEnabled = cbEnableProxy.IsChecked ?? false;
|
2014-07-18 20:00:55 +08:00
|
|
|
|
|
|
|
|
|
int port = 80;
|
2016-03-28 10:09:57 +08:00
|
|
|
|
if (_settings.ProxyEnabled)
|
2014-07-18 20:00:55 +08:00
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(tbProxyServer.Text))
|
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty"));
|
2014-07-18 20:00:55 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(tbProxyPort.Text))
|
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("portCantBeEmpty"));
|
2014-07-18 20:00:55 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!int.TryParse(tbProxyPort.Text, out port))
|
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPortFormat"));
|
2014-07-18 20:00:55 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings.ProxyServer = tbProxyServer.Text;
|
|
|
|
|
_settings.ProxyPort = port;
|
|
|
|
|
_settings.ProxyUserName = tbProxyUserName.Text;
|
|
|
|
|
_settings.ProxyPassword = tbProxyPassword.Password;
|
2014-07-18 20:00:55 +08:00
|
|
|
|
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("saveProxySuccessfully"));
|
2014-07-18 20:00:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnTestProxy_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(tbProxyServer.Text))
|
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty"));
|
2014-07-18 20:00:55 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(tbProxyPort.Text))
|
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("portCantBeEmpty"));
|
2014-07-18 20:00:55 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int port;
|
|
|
|
|
if (!int.TryParse(tbProxyPort.Text, out port))
|
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPortFormat"));
|
2014-07-18 20:00:55 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.baidu.com");
|
|
|
|
|
request.Timeout = 1000 * 5;
|
|
|
|
|
request.ReadWriteTimeout = 1000 * 5;
|
|
|
|
|
if (string.IsNullOrEmpty(tbProxyUserName.Text))
|
|
|
|
|
{
|
|
|
|
|
request.Proxy = new WebProxy(tbProxyServer.Text, port);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
request.Proxy = new WebProxy(tbProxyServer.Text, port);
|
|
|
|
|
request.Proxy.Credentials = new NetworkCredential(tbProxyUserName.Text, tbProxyPassword.Password);
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
2015-01-02 16:16:09 +08:00
|
|
|
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
2014-07-18 20:00:55 +08:00
|
|
|
|
if (response.StatusCode == HttpStatusCode.OK)
|
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("proxyIsCorrect"));
|
2014-07-18 20:00:55 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("proxyConnectFailed"));
|
2014-07-18 20:00:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("proxyConnectFailed"));
|
2014-07-18 20:00:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-12-16 22:25:22 +08:00
|
|
|
|
|
2015-02-07 21:27:48 +08:00
|
|
|
|
private void EnableProxy()
|
|
|
|
|
{
|
|
|
|
|
tbProxyPassword.IsEnabled = true;
|
|
|
|
|
tbProxyServer.IsEnabled = true;
|
|
|
|
|
tbProxyUserName.IsEnabled = true;
|
|
|
|
|
tbProxyPort.IsEnabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DisableProxy()
|
|
|
|
|
{
|
|
|
|
|
tbProxyPassword.IsEnabled = false;
|
|
|
|
|
tbProxyServer.IsEnabled = false;
|
|
|
|
|
tbProxyUserName.IsEnabled = false;
|
|
|
|
|
tbProxyPort.IsEnabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region About
|
|
|
|
|
|
2014-12-16 22:25:22 +08:00
|
|
|
|
private void tbWebsite_MouseUp(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Process.Start("http://www.getwox.com");
|
|
|
|
|
}
|
2015-02-07 21:27:48 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
2015-09-26 05:50:22 +08:00
|
|
|
|
|
2016-01-07 05:34:42 +08:00
|
|
|
|
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
|
2015-09-26 05:50:22 +08:00
|
|
|
|
{
|
|
|
|
|
// Hide window with ESC, but make sure it is not pressed as a hotkey
|
|
|
|
|
if (e.Key == Key.Escape && !ctlHotkey.IsFocused)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-25 18:00:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|