diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml
index 1db2782b90..feb5b61f50 100644
--- a/Wox/SettingWindow.xaml
+++ b/Wox/SettingWindow.xaml
@@ -14,7 +14,7 @@
Height="600" Width="800" PreviewKeyDown="Window_PreviewKeyDown"
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}">
-
+
@@ -61,9 +61,11 @@
-
+
+
+
+
+
@@ -160,9 +162,12 @@
-
+
+
+
+
+
+
@@ -287,53 +292,33 @@
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
+
@@ -354,34 +339,27 @@
-
-
-
-
-
-
- https://github.com/Wox-launcher/Wox
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
- https://github.com/Wox-launcher/Wox/releases/latest
+
-
-
-
-
+
+
diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs
index 9f48eeece9..ee4e595972 100644
--- a/Wox/SettingWindow.xaml.cs
+++ b/Wox/SettingWindow.xaml.cs
@@ -26,8 +26,6 @@ namespace Wox
private const string StartupPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
public readonly IPublicAPI _api;
- bool settingsLoaded;
- private bool themeTabLoaded;
private Settings _settings;
private SettingWindowViewModel _viewModel;
@@ -38,39 +36,6 @@ namespace Wox
DataContext = viewModel;
_viewModel = viewModel;
_api = api;
- Loaded += Setting_Loaded;
- }
-
- private void ProxyToggled(object sender, RoutedEventArgs e)
- {
- _settings.ProxyEnabled = ToggleProxy.IsChecked ?? false;
- }
-
- private void Setting_Loaded(object sender, RoutedEventArgs ev)
- {
- #region Proxy
-
- ToggleProxy.IsChecked = _settings.ProxyEnabled;
- ProxyServer.Text = _settings.ProxyServer;
- if (_settings.ProxyPort != 0)
- {
- ProxyPort.Text = _settings.ProxyPort.ToString();
- }
- ProxyUserName.Text = _settings.ProxyUserName;
- ProxyPassword.Password = _settings.ProxyPassword;
-
- #endregion
-
- #region About
-
- string activateTimes = string.Format(
- InternationalizationManager.Instance.GetTranslation("about_activate_times"), _settings.ActivateTimes);
- ActivatedTimes.Text = activateTimes;
- Version.Text = Infrastructure.Constant.Version;
-
- #endregion
-
- settingsLoaded = true;
}
#region General
@@ -245,14 +210,6 @@ namespace Wox
#endregion
- #region Theme
-
- private void OnMoreThemesClick(object sender, MouseButtonEventArgs e)
- {
- Process.Start("http://www.getwox.com/theme");
- }
- #endregion
-
#region Plugin
private void OnPluginToggled(object sender, RoutedEventArgs e)
@@ -301,82 +258,40 @@ namespace Wox
}
}
}
-
- private void OnMorePluginsClicked(object sender, MouseButtonEventArgs e)
- {
- Process.Start("http://www.getwox.com/plugin");
- }
-
#endregion
#region Proxy
- private void btnSaveProxy_Click(object sender, RoutedEventArgs e)
+ private void OnTestProxyClick(object sender, RoutedEventArgs e)
{
- _settings.ProxyEnabled = ToggleProxy.IsChecked ?? false;
-
- int port = 80;
- if (_settings.ProxyEnabled)
- {
- if (string.IsNullOrEmpty(ProxyServer.Text))
- {
- MessageBox.Show(InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty"));
- return;
- }
- if (string.IsNullOrEmpty(ProxyPort.Text))
- {
- MessageBox.Show(InternationalizationManager.Instance.GetTranslation("portCantBeEmpty"));
- return;
- }
- if (!int.TryParse(ProxyPort.Text, out port))
- {
- MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPortFormat"));
- return;
- }
- }
-
- _settings.ProxyServer = ProxyServer.Text;
- _settings.ProxyPort = port;
- _settings.ProxyUserName = ProxyUserName.Text;
- _settings.ProxyPassword = ProxyPassword.Password;
-
- MessageBox.Show(InternationalizationManager.Instance.GetTranslation("saveProxySuccessfully"));
- }
-
- private void btnTestProxy_Click(object sender, RoutedEventArgs e)
- {
- if (string.IsNullOrEmpty(ProxyServer.Text))
+ if (string.IsNullOrEmpty(_settings.ProxyServer))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty"));
return;
}
- if (string.IsNullOrEmpty(ProxyPort.Text))
+ if (_settings.ProxyPort > 0)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("portCantBeEmpty"));
return;
}
- int port;
- if (!int.TryParse(ProxyPort.Text, out port))
- {
- MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPortFormat"));
- return;
- }
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.baidu.com");
+ HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Infrastructure.Constant.Github);
request.Timeout = 1000 * 5;
request.ReadWriteTimeout = 1000 * 5;
- if (string.IsNullOrEmpty(ProxyUserName.Text))
+ if (string.IsNullOrEmpty(_settings.ProxyUserName) || string.IsNullOrEmpty(_settings.ProxyPassword))
{
- request.Proxy = new WebProxy(ProxyServer.Text, port);
+ request.Proxy = new WebProxy(_settings.ProxyServer, _settings.ProxyPort);
}
else
{
- request.Proxy = new WebProxy(ProxyServer.Text, port);
- request.Proxy.Credentials = new NetworkCredential(ProxyUserName.Text, ProxyPassword.Password);
+ request.Proxy = new WebProxy(_settings.ProxyServer, _settings.ProxyPort)
+ {
+ Credentials = new NetworkCredential(_settings.ProxyUserName, _settings.ProxyPassword)
+ };
}
try
{
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
+ var response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("proxyIsCorrect"));
@@ -412,9 +327,8 @@ namespace Wox
var oldVersion = Updater.NumericVersion(Infrastructure.Constant.Version);
if (newVersion > oldVersion)
{
- NewVersionTips.Text = string.Format(NewVersionTips.Text, version);
- NewVersionTips.Visibility = Visibility.Visible;
Updater.UpdateApp();
+ _viewModel.NewVersionTips = version;
}
}
}
@@ -424,7 +338,5 @@ namespace Wox
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
e.Handled = true;
}
-
-
}
}
diff --git a/Wox/ViewModel/SettingWindowViewModel.cs b/Wox/ViewModel/SettingWindowViewModel.cs
index 96936396e0..21958cceb7 100644
--- a/Wox/ViewModel/SettingWindowViewModel.cs
+++ b/Wox/ViewModel/SettingWindowViewModel.cs
@@ -21,14 +21,15 @@ namespace Wox.ViewModel
public class SettingWindowViewModel
{
public Settings Settings { get; set; }
-
private readonly JsonStrorage _storage;
#region general
- public List Languages => InternationalizationManager.Instance.LoadAvailableLanguages();
+ public List Languages => _translater.LoadAvailableLanguages();
+ private Internationalization _translater => InternationalizationManager.Instance;
public IEnumerable MaxResultsRange => Enumerable.Range(2, 16);
#endregion
#region plugin
+ public static string Plugin => "http://www.getwox.com/plugin";
public PluginViewModel SelectedPlugin { get; set; }
public IList PluginViewModels
{
@@ -72,13 +73,13 @@ namespace Wox.ViewModel
{
multipleActionKeywordsProvider.ActionKeywordsChanged += (o, e) =>
{
- // update in-memory data
- PluginManager.UpdateActionKeywordForPlugin(SelectedPlugin.PluginPair, e.OldActionKeyword,
- e.NewActionKeyword);
- // update persistant data
- Settings.PluginSettings.UpdateActionKeyword(SelectedPlugin.Metadata);
+ // update in-memory data
+ PluginManager.UpdateActionKeywordForPlugin(SelectedPlugin.PluginPair, e.OldActionKeyword,
+ e.NewActionKeyword);
+ // update persistant data
+ Settings.PluginSettings.UpdateActionKeyword(SelectedPlugin.Metadata);
- MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed"));
+ MessageBox.Show(_translater.GetTranslation("succeed"));
};
}
var control = settingProvider.CreateSettingPanel();
@@ -95,6 +96,7 @@ namespace Wox.ViewModel
#endregion
#region theme
+ public static string Theme => @"http://www.getwox.com/theme";
public string SelectedTheme
{
get
@@ -139,8 +141,7 @@ namespace Wox.ViewModel
{
const string image = "app.png";
- const string theme = "http://www.getwox.com/theme/builder";
- const string plugin = "http://www.getwox.com/plugin";
+
List results = new List
{
new Result
@@ -164,12 +165,12 @@ namespace Wox.ViewModel
new Result
{
Title = "Build custom themes at: ",
- SubTitle = theme,
+ SubTitle = Theme,
},
new Result
{
Title = "Install plugins from: ",
- SubTitle = plugin,
+ SubTitle = Plugin,
IcoPath = image,
},
new Result
@@ -278,8 +279,25 @@ namespace Wox.ViewModel
#endregion
#region hotkey
+ public CustomPluginHotkey SelectedCustomPluginHotkey { get; set; }
+ #endregion
+ #region about
- public CustomPluginHotkey SelectedCustomPluginHotkey {get;set;}
+ public static string Github => Infrastructure.Constant.Github;
+ public static string ReleaseNotes => @"https://github.com/Wox-launcher/Wox/releases/latest";
+ public static string Version => Infrastructure.Constant.Version;
+ public string ActivatedTimes => Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
+ private string _newVersionTips;
+ public string NewVersionTips
+ {
+ get { return _newVersionTips; }
+ set
+ {
+ _newVersionTips = Format(_translater.GetTranslation("newVersionTips"), value);
+ NewVersionTipsVisibility = Visibility.Visible;
+ }
+ }
+ public Visibility NewVersionTipsVisibility { get; set; }
#endregion
public SettingWindowViewModel()
{