2014-03-11 21:40:25 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2014-12-16 22:25:22 +08:00
|
|
|
|
using System.Configuration;
|
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;
|
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;
|
2014-03-11 21:40:25 +08:00
|
|
|
|
using IWshRuntimeLibrary;
|
2014-03-23 16:17:41 +08:00
|
|
|
|
using Wox.Infrastructure.Storage.UserSettings;
|
2014-03-19 22:17:01 +08:00
|
|
|
|
using Wox.Plugin;
|
2014-03-25 13:25:43 +08:00
|
|
|
|
using Wox.Helper;
|
2014-03-29 15:52:57 +08:00
|
|
|
|
using Wox.Plugin.SystemPlugins;
|
2014-07-01 22:19:46 +08:00
|
|
|
|
using Wox.PluginLoader;
|
2014-12-16 22:25:22 +08:00
|
|
|
|
using Wox.Update;
|
2014-03-11 21:40:25 +08:00
|
|
|
|
using Application = System.Windows.Forms.Application;
|
|
|
|
|
using File = System.IO.File;
|
2014-02-06 22:22:02 +08:00
|
|
|
|
using MessageBox = System.Windows.MessageBox;
|
2014-03-28 22:42:28 +08:00
|
|
|
|
using System.Windows.Data;
|
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
|
|
|
|
{
|
2014-03-11 21:40:25 +08:00
|
|
|
|
string woxLinkPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "wox.lnk");
|
2014-02-22 15:52:20 +08:00
|
|
|
|
public MainWindow MainWindow;
|
2014-06-30 21:31:13 +08:00
|
|
|
|
bool settingsLoaded = false;
|
2014-07-14 23:18:57 +08:00
|
|
|
|
private Dictionary<ISettingProvider, Control> featureControls = new Dictionary<ISettingProvider, Control>();
|
2014-01-25 18:00:13 +08:00
|
|
|
|
|
2014-03-20 02:26:00 +08:00
|
|
|
|
public SettingWindow(MainWindow mainWindow)
|
2014-01-25 18:00:13 +08:00
|
|
|
|
{
|
2014-02-22 15:52:20 +08:00
|
|
|
|
this.MainWindow = mainWindow;
|
2014-01-25 18:00:13 +08:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
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-11 05:44:57 +08:00
|
|
|
|
|
2014-04-13 10:08:33 +08:00
|
|
|
|
cbHideWhenDeactive.Checked += (o, e) =>
|
|
|
|
|
{
|
|
|
|
|
UserSettingStorage.Instance.HideWhenDeactive = true;
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cbHideWhenDeactive.Unchecked += (o, e) =>
|
|
|
|
|
{
|
|
|
|
|
UserSettingStorage.Instance.HideWhenDeactive = false;
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-14 23:16:29 +08:00
|
|
|
|
cbDontPromptUpdateMsg.Checked += (o, e) =>
|
|
|
|
|
{
|
|
|
|
|
UserSettingStorage.Instance.DontPromptUpdateMsg = true;
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cbDontPromptUpdateMsg.Unchecked += (o, e) =>
|
|
|
|
|
{
|
|
|
|
|
UserSettingStorage.Instance.DontPromptUpdateMsg = false;
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
|
|
|
};
|
|
|
|
|
|
2015-07-13 03:13:30 +08:00
|
|
|
|
comboMaxResultsToShow.SelectionChanged += (o, e) =>
|
|
|
|
|
{
|
|
|
|
|
UserSettingStorage.Instance.MaxResultsToShow = (int)comboMaxResultsToShow.SelectedItem;
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
|
|
|
MainWindow.pnlResult.lbResults.GetBindingExpression(MaxHeightProperty).UpdateTarget();
|
|
|
|
|
};
|
|
|
|
|
|
2014-06-30 21:31:13 +08:00
|
|
|
|
cbStartWithWindows.IsChecked = File.Exists(woxLinkPath);
|
|
|
|
|
cbHideWhenDeactive.IsChecked = UserSettingStorage.Instance.HideWhenDeactive;
|
2014-12-14 23:16:29 +08:00
|
|
|
|
cbDontPromptUpdateMsg.IsChecked = UserSettingStorage.Instance.DontPromptUpdateMsg;
|
2014-06-30 21:31:13 +08:00
|
|
|
|
|
2015-07-13 03:13:30 +08:00
|
|
|
|
comboMaxResultsToShow.ItemsSource = Enumerable.Range(2, 16);
|
|
|
|
|
var maxResults = UserSettingStorage.Instance.MaxResultsToShow;
|
|
|
|
|
comboMaxResultsToShow.SelectedItem = maxResults == 0 ? 6 : maxResults;
|
|
|
|
|
|
2014-12-14 23:16:29 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Theme
|
2014-03-19 22:17:01 +08:00
|
|
|
|
|
2014-03-23 16:17:41 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(UserSettingStorage.Instance.QueryBoxFont) &&
|
|
|
|
|
Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(UserSettingStorage.Instance.QueryBoxFont)) > 0)
|
2014-03-19 22:17:01 +08:00
|
|
|
|
{
|
2014-03-23 16:17:41 +08:00
|
|
|
|
cbQueryBoxFont.Text = UserSettingStorage.Instance.QueryBoxFont;
|
2014-03-25 13:25:43 +08:00
|
|
|
|
|
|
|
|
|
cbQueryBoxFontFaces.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)cbQueryBoxFont.SelectedItem).ConvertFromInvariantStringsOrNormal(
|
|
|
|
|
UserSettingStorage.Instance.QueryBoxFontStyle,
|
|
|
|
|
UserSettingStorage.Instance.QueryBoxFontWeight,
|
|
|
|
|
UserSettingStorage.Instance.QueryBoxFontStretch
|
|
|
|
|
));
|
2014-03-19 22:17:01 +08:00
|
|
|
|
}
|
2014-03-23 16:17:41 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(UserSettingStorage.Instance.ResultItemFont) &&
|
2014-03-25 13:25:43 +08:00
|
|
|
|
Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(UserSettingStorage.Instance.ResultItemFont)) > 0)
|
2014-03-19 22:17:01 +08:00
|
|
|
|
{
|
2014-03-23 16:17:41 +08:00
|
|
|
|
cbResultItemFont.Text = UserSettingStorage.Instance.ResultItemFont;
|
2014-03-25 13:25:43 +08:00
|
|
|
|
|
|
|
|
|
cbResultItemFontFaces.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)cbResultItemFont.SelectedItem).ConvertFromInvariantStringsOrNormal(
|
|
|
|
|
UserSettingStorage.Instance.ResultItemFontStyle,
|
|
|
|
|
UserSettingStorage.Instance.ResultItemFontWeight,
|
|
|
|
|
UserSettingStorage.Instance.ResultItemFontStretch
|
|
|
|
|
));
|
2014-03-19 22:17:01 +08:00
|
|
|
|
}
|
|
|
|
|
resultPanelPreview.AddResults(new List<Result>()
|
|
|
|
|
{
|
|
|
|
|
new Result()
|
|
|
|
|
{
|
|
|
|
|
Title = "Wox is an effective launcher for windows",
|
|
|
|
|
SubTitle = "Wox provide bundles of features let you access infomations quickly.",
|
|
|
|
|
IcoPath = "Images/work.png",
|
2014-03-23 16:33:05 +08:00
|
|
|
|
PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)
|
2014-03-19 22:17:01 +08:00
|
|
|
|
},
|
|
|
|
|
new Result()
|
|
|
|
|
{
|
|
|
|
|
Title = "Search applications",
|
2014-03-26 15:30:59 +08:00
|
|
|
|
SubTitle = "Search applications, files (via everything plugin) and browser bookmarks",
|
2014-03-19 22:17:01 +08:00
|
|
|
|
IcoPath = "Images/work.png",
|
2014-03-23 16:33:05 +08:00
|
|
|
|
PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)
|
2014-03-19 22:17:01 +08:00
|
|
|
|
},
|
|
|
|
|
new Result()
|
|
|
|
|
{
|
|
|
|
|
Title = "Search web contents with shortcuts",
|
|
|
|
|
SubTitle = "e.g. search google with g keyword or youtube keyword)",
|
|
|
|
|
IcoPath = "Images/work.png",
|
2014-06-30 21:31:13 +08:00
|
|
|
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
2014-03-19 22:17:01 +08:00
|
|
|
|
},
|
|
|
|
|
new Result()
|
|
|
|
|
{
|
|
|
|
|
Title = "clipboard history ",
|
|
|
|
|
IcoPath = "Images/work.png",
|
2014-06-30 21:31:13 +08:00
|
|
|
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
2014-03-19 22:17:01 +08:00
|
|
|
|
},
|
|
|
|
|
new Result()
|
|
|
|
|
{
|
|
|
|
|
Title = "Themes support",
|
|
|
|
|
SubTitle = "get more themes from http://www.getwox.com/theme",
|
|
|
|
|
IcoPath = "Images/work.png",
|
2014-06-30 21:31:13 +08:00
|
|
|
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
2014-03-26 15:30:59 +08:00
|
|
|
|
},
|
|
|
|
|
new Result()
|
|
|
|
|
{
|
|
|
|
|
Title = "Plugins support",
|
|
|
|
|
SubTitle = "get more plugins from http://www.getwox.com/plugin",
|
|
|
|
|
IcoPath = "Images/work.png",
|
2014-06-30 21:31:13 +08:00
|
|
|
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
2014-03-26 15:30:59 +08:00
|
|
|
|
},
|
|
|
|
|
new Result()
|
|
|
|
|
{
|
|
|
|
|
Title = "Wox is an open-source software",
|
|
|
|
|
SubTitle = "Wox benefits from the open-source community a lot",
|
|
|
|
|
IcoPath = "Images/work.png",
|
2014-06-30 21:31:13 +08:00
|
|
|
|
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
2014-03-19 22:17:01 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2014-01-25 18:00:13 +08:00
|
|
|
|
foreach (string theme in LoadAvailableThemes())
|
|
|
|
|
{
|
2014-03-19 20:16:20 +08:00
|
|
|
|
string themeName = System.IO.Path.GetFileNameWithoutExtension(theme);
|
2014-01-25 18:00:13 +08:00
|
|
|
|
themeComboBox.Items.Add(themeName);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-23 16:17:41 +08:00
|
|
|
|
themeComboBox.SelectedItem = UserSettingStorage.Instance.Theme;
|
2014-06-30 21:31:13 +08:00
|
|
|
|
slOpacity.Value = UserSettingStorage.Instance.Opacity;
|
|
|
|
|
CbOpacityMode.SelectedItem = UserSettingStorage.Instance.OpacityMode;
|
|
|
|
|
|
|
|
|
|
var wallpaper = WallpaperPathRetrieval.GetWallpaperPath();
|
|
|
|
|
if (wallpaper != null && File.Exists(wallpaper))
|
|
|
|
|
{
|
|
|
|
|
var brush = new ImageBrush(new BitmapImage(new Uri(wallpaper)));
|
|
|
|
|
brush.Stretch = Stretch.UniformToFill;
|
|
|
|
|
PreviewPanel.Background = brush;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var wallpaperColor = WallpaperPathRetrieval.GetWallpaperColor();
|
|
|
|
|
PreviewPanel.Background = new SolidColorBrush(wallpaperColor);
|
|
|
|
|
}
|
2014-12-14 23:16:29 +08:00
|
|
|
|
|
|
|
|
|
//PreviewPanel
|
|
|
|
|
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
|
|
|
|
|
|
2014-06-30 21:31:13 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
2014-12-14 23:16:29 +08:00
|
|
|
|
#region Plugin
|
|
|
|
|
|
|
|
|
|
ctlHotkey.OnHotkeyChanged += ctlHotkey_OnHotkeyChanged;
|
|
|
|
|
ctlHotkey.SetHotkey(UserSettingStorage.Instance.Hotkey, false);
|
|
|
|
|
lvCustomHotkey.ItemsSource = UserSettingStorage.Instance.CustomPluginHotkeys;
|
2014-03-25 13:25:43 +08:00
|
|
|
|
|
2014-06-30 21:31:13 +08:00
|
|
|
|
var plugins = new CompositeCollection
|
2014-03-28 22:42:28 +08:00
|
|
|
|
{
|
2014-06-30 21:31:13 +08:00
|
|
|
|
new CollectionContainer
|
2014-03-28 22:42:28 +08:00
|
|
|
|
{
|
|
|
|
|
Collection =
|
|
|
|
|
PluginLoader.Plugins.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System)
|
|
|
|
|
.Select(o => o.Plugin)
|
2014-06-30 21:31:13 +08:00
|
|
|
|
.Cast<ISystemPlugin>()
|
2014-03-28 22:42:28 +08:00
|
|
|
|
},
|
|
|
|
|
FindResource("FeatureBoxSeperator"),
|
2014-06-30 21:31:13 +08:00
|
|
|
|
new CollectionContainer
|
2014-03-28 22:42:28 +08:00
|
|
|
|
{
|
|
|
|
|
Collection =
|
|
|
|
|
PluginLoader.Plugins.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.ThirdParty)
|
|
|
|
|
}
|
|
|
|
|
};
|
2014-06-30 21:31:13 +08:00
|
|
|
|
lbPlugins.ItemsSource = plugins;
|
|
|
|
|
lbPlugins.SelectedIndex = 0;
|
2014-03-26 17:34:19 +08:00
|
|
|
|
|
2014-06-30 21:31:13 +08:00
|
|
|
|
#endregion
|
2014-03-26 15:30:59 +08:00
|
|
|
|
|
2014-07-18 20:00:55 +08:00
|
|
|
|
#region Proxy
|
|
|
|
|
|
|
|
|
|
cbEnableProxy.Checked += (o, e) => EnableProxy();
|
|
|
|
|
cbEnableProxy.Unchecked += (o, e) => DisableProxy();
|
|
|
|
|
cbEnableProxy.IsChecked = UserSettingStorage.Instance.ProxyEnabled;
|
|
|
|
|
tbProxyServer.Text = UserSettingStorage.Instance.ProxyServer;
|
|
|
|
|
tbProxyPort.Text = UserSettingStorage.Instance.ProxyPort.ToString();
|
|
|
|
|
tbProxyUserName.Text = UserSettingStorage.Instance.ProxyUserName;
|
|
|
|
|
tbProxyPassword.Password = UserSettingStorage.Instance.ProxyPassword;
|
|
|
|
|
if (UserSettingStorage.Instance.ProxyEnabled)
|
|
|
|
|
{
|
|
|
|
|
EnableProxy();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DisableProxy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-12-16 22:25:22 +08:00
|
|
|
|
#region About
|
|
|
|
|
|
|
|
|
|
tbVersion.Text = ConfigurationManager.AppSettings["version"];
|
|
|
|
|
Release newRelease = new UpdateChecker().CheckUpgrade();
|
|
|
|
|
if (newRelease == null)
|
|
|
|
|
{
|
|
|
|
|
tbNewVersionAvailable.Visibility = Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tbNewVersionAvailable.Text = newRelease.version + " available";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-03-25 13:25:43 +08:00
|
|
|
|
settingsLoaded = true;
|
2014-01-25 18:00:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-18 20:00:55 +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;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-25 18:00:13 +08:00
|
|
|
|
private List<string> LoadAvailableThemes()
|
|
|
|
|
{
|
2014-06-30 21:31:13 +08:00
|
|
|
|
string themePath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Themes");
|
2014-03-15 00:17:37 +08:00
|
|
|
|
return Directory.GetFiles(themePath).Where(filePath => filePath.EndsWith(".xaml") && !filePath.EndsWith("Default.xaml")).ToList();
|
2014-01-25 18:00:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-06 22:22:02 +08:00
|
|
|
|
private void CbStartWithWindows_OnChecked(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2014-03-11 21:40:25 +08:00
|
|
|
|
CreateStartupFolderShortcut();
|
2014-03-23 16:17:41 +08:00
|
|
|
|
UserSettingStorage.Instance.StartWoxOnSystemStartup = true;
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
2014-02-06 22:22:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CbStartWithWindows_OnUnchecked(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2014-03-11 21:40:25 +08:00
|
|
|
|
if (File.Exists(woxLinkPath))
|
|
|
|
|
{
|
|
|
|
|
File.Delete(woxLinkPath);
|
|
|
|
|
}
|
2014-03-19 01:20:51 +08:00
|
|
|
|
|
2014-03-23 16:17:41 +08:00
|
|
|
|
UserSettingStorage.Instance.StartWoxOnSystemStartup = false;
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
2014-02-06 22:22:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-11 21:40:25 +08:00
|
|
|
|
private void CreateStartupFolderShortcut()
|
2014-02-06 22:22:02 +08:00
|
|
|
|
{
|
2014-03-11 21:40:25 +08:00
|
|
|
|
WshShellClass wshShell = new WshShellClass();
|
2014-02-06 22:22:02 +08:00
|
|
|
|
|
2014-03-11 21:40:25 +08:00
|
|
|
|
IWshShortcut shortcut = (IWshShortcut)wshShell.CreateShortcut(woxLinkPath);
|
|
|
|
|
shortcut.TargetPath = Application.ExecutablePath;
|
|
|
|
|
shortcut.Arguments = "hideStart";
|
2014-03-22 16:50:47 +08:00
|
|
|
|
shortcut.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath);
|
2014-03-11 21:40:25 +08:00
|
|
|
|
shortcut.Description = "Launch Wox";
|
2014-03-22 16:50:47 +08:00
|
|
|
|
shortcut.IconLocation = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "App.ico");
|
2014-03-11 21:40:25 +08:00
|
|
|
|
shortcut.Save();
|
2014-02-06 22:22:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-22 15:52:20 +08:00
|
|
|
|
void ctlHotkey_OnHotkeyChanged(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (ctlHotkey.CurrentHotkeyAvailable)
|
|
|
|
|
{
|
|
|
|
|
MainWindow.SetHotkey(ctlHotkey.CurrentHotkey.ToString(), delegate
|
|
|
|
|
{
|
|
|
|
|
if (!MainWindow.IsVisible)
|
|
|
|
|
{
|
|
|
|
|
MainWindow.ShowApp();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MainWindow.HideApp();
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-03-23 16:17:41 +08:00
|
|
|
|
MainWindow.RemoveHotkey(UserSettingStorage.Instance.Hotkey);
|
|
|
|
|
UserSettingStorage.Instance.Hotkey = ctlHotkey.CurrentHotkey.ToString();
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
2014-02-22 15:52:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Custom Plugin Hotkey
|
|
|
|
|
|
|
|
|
|
private void BtnDeleteCustomHotkey_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey;
|
|
|
|
|
if (item != null &&
|
2014-03-11 21:40:25 +08:00
|
|
|
|
MessageBox.Show("Are your sure to delete " + item.Hotkey + " plugin hotkey?", "Delete Custom Plugin Hotkey",
|
2014-02-22 15:52:20 +08:00
|
|
|
|
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
|
|
|
|
{
|
2014-03-23 16:17:41 +08:00
|
|
|
|
UserSettingStorage.Instance.CustomPluginHotkeys.Remove(item);
|
2014-02-22 15:52:20 +08:00
|
|
|
|
lvCustomHotkey.Items.Refresh();
|
2014-03-23 16:17:41 +08:00
|
|
|
|
UserSettingStorage.Instance.Save();
|
2014-02-22 15:52:20 +08:00
|
|
|
|
MainWindow.RemoveHotkey(item.Hotkey);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Please select an item");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnEditCustomHotkey_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey;
|
|
|
|
|
if (item != null)
|
|
|
|
|
{
|
|
|
|
|
CustomPluginHotkeySetting window = new CustomPluginHotkeySetting(this);
|
|
|
|
|
window.UpdateItem(item);
|
|
|
|
|
window.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Please select an item");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnAddCustomeHotkey_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
new CustomPluginHotkeySetting(this).ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ReloadCustomPluginHotkeyView()
|
|
|
|
|
{
|
|
|
|
|
lvCustomHotkey.Items.Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-03-19 22:17:01 +08:00
|
|
|
|
#region Theme
|
|
|
|
|
private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string themeName = themeComboBox.SelectedItem.ToString();
|
|
|
|
|
MainWindow.SetTheme(themeName);
|
2014-03-23 16:17:41 +08:00
|
|
|
|
UserSettingStorage.Instance.Theme = themeName;
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
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();
|
2014-03-23 16:17:41 +08:00
|
|
|
|
UserSettingStorage.Instance.QueryBoxFont = queryBoxFontName;
|
2014-03-25 13:25:43 +08:00
|
|
|
|
this.cbQueryBoxFontFaces.SelectedItem = ((FontFamily)cbQueryBoxFont.SelectedItem).ChooseRegularFamilyTypeface();
|
|
|
|
|
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
|
|
|
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
UserSettingStorage.Instance.QueryBoxFontStretch = typeface.Stretch.ToString();
|
|
|
|
|
UserSettingStorage.Instance.QueryBoxFontWeight = typeface.Weight.ToString();
|
|
|
|
|
UserSettingStorage.Instance.QueryBoxFontStyle = typeface.Style.ToString();
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
|
|
|
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
|
|
|
|
|
}
|
2014-03-19 22:17:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CbResultItemFont_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 resultItemFont = cbResultItemFont.SelectedItem.ToString();
|
2014-03-23 16:17:41 +08:00
|
|
|
|
UserSettingStorage.Instance.ResultItemFont = resultItemFont;
|
2014-03-25 13:25:43 +08:00
|
|
|
|
this.cbResultItemFontFaces.SelectedItem = ((FontFamily)cbResultItemFont.SelectedItem).ChooseRegularFamilyTypeface();
|
|
|
|
|
|
2014-03-23 16:17:41 +08:00
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
|
|
|
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
|
2014-03-19 22:17:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-25 13:25:43 +08:00
|
|
|
|
private void CbResultItemFontFaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!settingsLoaded) return;
|
|
|
|
|
FamilyTypeface typeface = (FamilyTypeface)cbResultItemFontFaces.SelectedItem;
|
2014-03-26 15:30:59 +08:00
|
|
|
|
if (typeface == null)
|
|
|
|
|
{
|
|
|
|
|
if (cbResultItemFontFaces.Items.Count > 0)
|
|
|
|
|
cbResultItemFontFaces.SelectedIndex = 0;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
UserSettingStorage.Instance.ResultItemFontStretch = typeface.Stretch.ToString();
|
|
|
|
|
UserSettingStorage.Instance.ResultItemFontWeight = typeface.Weight.ToString();
|
|
|
|
|
UserSettingStorage.Instance.ResultItemFontStyle = typeface.Style.ToString();
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
|
|
|
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
|
|
|
|
|
}
|
2014-03-25 13:25:43 +08:00
|
|
|
|
}
|
2014-03-26 17:34:19 +08:00
|
|
|
|
|
|
|
|
|
private void slOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
|
|
|
|
{
|
|
|
|
|
UserSettingStorage.Instance.Opacity = slOpacity.Value;
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
|
|
|
|
|
|
|
|
if (UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow)
|
|
|
|
|
PreviewMainPanel.Opacity = UserSettingStorage.Instance.Opacity;
|
|
|
|
|
else
|
|
|
|
|
PreviewMainPanel.Opacity = 1;
|
|
|
|
|
|
|
|
|
|
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
|
|
|
|
|
}
|
2014-03-19 22:17:01 +08:00
|
|
|
|
#endregion
|
2014-03-26 17:34:19 +08:00
|
|
|
|
|
|
|
|
|
private void CbOpacityMode_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
2014-07-14 23:18:57 +08:00
|
|
|
|
UserSettingStorage.Instance.OpacityMode = (OpacityMode)CbOpacityMode.SelectedItem;
|
2014-03-26 17:34:19 +08:00
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
|
|
|
|
2014-07-17 18:42:11 +08:00
|
|
|
|
spOpacity.Visibility = UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow ? Visibility.Visible : Visibility.Collapsed;
|
2014-03-26 17:34:19 +08:00
|
|
|
|
|
|
|
|
|
if (UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow)
|
|
|
|
|
PreviewMainPanel.Opacity = UserSettingStorage.Instance.Opacity;
|
|
|
|
|
else
|
|
|
|
|
PreviewMainPanel.Opacity = 1;
|
|
|
|
|
}
|
2014-03-28 22:42:28 +08:00
|
|
|
|
|
2014-06-30 18:12:45 +08:00
|
|
|
|
private void lbPlugins_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
2014-03-28 22:42:28 +08:00
|
|
|
|
{
|
2014-03-29 15:52:57 +08:00
|
|
|
|
ISettingProvider provider = null;
|
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;
|
|
|
|
|
|
2014-03-29 15:52:57 +08:00
|
|
|
|
if (pair != null)
|
|
|
|
|
{
|
2014-06-30 21:31:13 +08:00
|
|
|
|
//third-party plugin
|
2014-03-29 15:52:57 +08:00
|
|
|
|
provider = pair.Plugin as ISettingProvider;
|
2014-06-30 21:31:13 +08:00
|
|
|
|
pluginAuthor.Visibility = Visibility.Visible;
|
|
|
|
|
pluginActionKeyword.Visibility = Visibility.Visible;
|
2014-07-04 15:12:22 +08:00
|
|
|
|
pluginActionKeywordTitle.Visibility = Visibility.Visible;
|
2014-07-14 23:18:57 +08:00
|
|
|
|
tbOpenPluginDirecoty.Visibility = Visibility.Visible;
|
2014-03-29 15:52:57 +08:00
|
|
|
|
pluginTitle.Text = pair.Metadata.Name;
|
2014-07-04 15:12:22 +08:00
|
|
|
|
pluginTitle.Cursor = Cursors.Hand;
|
2014-07-04 12:08:37 +08:00
|
|
|
|
pluginActionKeyword.Text = pair.Metadata.ActionKeyword;
|
2014-07-04 15:12:22 +08:00
|
|
|
|
pluginAuthor.Text = "By: " + pair.Metadata.Author;
|
2014-03-29 15:52:57 +08:00
|
|
|
|
pluginSubTitle.Text = pair.Metadata.Description;
|
2014-07-01 22:19:46 +08:00
|
|
|
|
pluginId = pair.Metadata.ID;
|
2014-12-18 19:22:47 +08:00
|
|
|
|
pluginIcon.Source = ImageLoader.ImageLoader.Load(pair.Metadata.FullIcoPath);
|
2014-03-29 15:52:57 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-30 21:31:13 +08:00
|
|
|
|
//system plugin
|
2014-06-30 18:12:45 +08:00
|
|
|
|
provider = lbPlugins.SelectedItem as ISettingProvider;
|
|
|
|
|
var sys = lbPlugins.SelectedItem as BaseSystemPlugin;
|
2014-03-29 15:52:57 +08:00
|
|
|
|
if (sys != null)
|
|
|
|
|
{
|
|
|
|
|
pluginTitle.Text = sys.Name;
|
2014-07-01 22:19:46 +08:00
|
|
|
|
pluginId = sys.ID;
|
2014-03-29 15:52:57 +08:00
|
|
|
|
pluginSubTitle.Text = sys.Description;
|
2014-06-30 21:31:13 +08:00
|
|
|
|
pluginAuthor.Visibility = Visibility.Collapsed;
|
|
|
|
|
pluginActionKeyword.Visibility = Visibility.Collapsed;
|
2014-07-14 23:18:57 +08:00
|
|
|
|
tbOpenPluginDirecoty.Visibility = Visibility.Collapsed;
|
2014-07-04 15:12:22 +08:00
|
|
|
|
pluginActionKeywordTitle.Visibility = Visibility.Collapsed;
|
|
|
|
|
pluginTitle.Cursor = Cursors.Arrow;
|
2014-12-18 19:22:47 +08:00
|
|
|
|
pluginIcon.Source = ImageLoader.ImageLoader.Load(sys.FullIcoPath);
|
2014-03-29 15:52:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-01 22:19:46 +08:00
|
|
|
|
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pluginId);
|
|
|
|
|
cbDisablePlugin.IsChecked = customizedPluginConfig != null && customizedPluginConfig.Disabled;
|
|
|
|
|
|
|
|
|
|
PluginContentPanel.Content = null;
|
2014-03-29 15:52:57 +08:00
|
|
|
|
if (provider != null)
|
|
|
|
|
{
|
|
|
|
|
Control control = null;
|
|
|
|
|
if (!featureControls.TryGetValue(provider, out control))
|
|
|
|
|
featureControls.Add(provider, control = provider.CreateSettingPanel());
|
|
|
|
|
|
|
|
|
|
PluginContentPanel.Content = control;
|
|
|
|
|
control.HorizontalAlignment = HorizontalAlignment.Stretch;
|
|
|
|
|
control.VerticalAlignment = VerticalAlignment.Stretch;
|
|
|
|
|
control.Width = Double.NaN;
|
|
|
|
|
control.Height = Double.NaN;
|
|
|
|
|
}
|
|
|
|
|
// featureControls
|
2014-03-28 22:42:28 +08:00
|
|
|
|
// throw new NotImplementedException();
|
|
|
|
|
}
|
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;
|
|
|
|
|
var id = string.Empty;
|
|
|
|
|
var name = string.Empty;
|
|
|
|
|
if (pair != null)
|
|
|
|
|
{
|
|
|
|
|
//third-party plugin
|
|
|
|
|
id = pair.Metadata.ID;
|
|
|
|
|
name = pair.Metadata.Name;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//system plugin
|
|
|
|
|
var sys = lbPlugins.SelectedItem as BaseSystemPlugin;
|
|
|
|
|
if (sys != null)
|
|
|
|
|
{
|
|
|
|
|
id = sys.ID;
|
|
|
|
|
name = sys.Name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == id);
|
|
|
|
|
if (customizedPluginConfig == null)
|
|
|
|
|
{
|
|
|
|
|
UserSettingStorage.Instance.CustomizedPluginConfigs.Add(new CustomizedPluginConfig()
|
|
|
|
|
{
|
|
|
|
|
Disabled = cbDisabled.IsChecked ?? true,
|
|
|
|
|
ID = id,
|
|
|
|
|
Name = name,
|
|
|
|
|
Actionword = string.Empty
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
customizedPluginConfig.Disabled = cbDisabled.IsChecked ?? true;
|
|
|
|
|
}
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
|
|
|
}
|
2014-07-04 12:08:37 +08:00
|
|
|
|
|
|
|
|
|
private void PluginActionKeyword_OnMouseUp(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.ChangedButton == MouseButton.Left)
|
|
|
|
|
{
|
|
|
|
|
var pair = lbPlugins.SelectedItem as PluginPair;
|
|
|
|
|
if (pair != null)
|
|
|
|
|
{
|
|
|
|
|
//third-party plugin
|
|
|
|
|
string id = pair.Metadata.ID;
|
|
|
|
|
ActionKeyword changeKeywordWindow = new ActionKeyword(id);
|
|
|
|
|
changeKeywordWindow.ShowDialog();
|
|
|
|
|
PluginPair plugin = Plugins.AllPlugins.FirstOrDefault(o => o.Metadata.ID == id);
|
|
|
|
|
if (plugin != null) pluginActionKeyword.Text = plugin.Metadata.ActionKeyword;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tbMoreThemes_MouseUp(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Process.Start("http://www.getwox.com/theme");
|
|
|
|
|
}
|
2014-07-18 20:00:55 +08:00
|
|
|
|
|
|
|
|
|
private void btnSaveProxy_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UserSettingStorage.Instance.ProxyEnabled = cbEnableProxy.IsChecked ?? false;
|
|
|
|
|
|
|
|
|
|
int port = 80;
|
|
|
|
|
if (UserSettingStorage.Instance.ProxyEnabled)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(tbProxyServer.Text))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Server can't be empty");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(tbProxyPort.Text))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Server port can't be empty");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!int.TryParse(tbProxyPort.Text, out port))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Invalid port format");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UserSettingStorage.Instance.ProxyServer = tbProxyServer.Text;
|
|
|
|
|
UserSettingStorage.Instance.ProxyPort = port;
|
|
|
|
|
UserSettingStorage.Instance.ProxyUserName = tbProxyUserName.Text;
|
|
|
|
|
UserSettingStorage.Instance.ProxyPassword = tbProxyPassword.Password;
|
|
|
|
|
UserSettingStorage.Instance.Save();
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("Save Proxy Successfully");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnTestProxy_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(tbProxyServer.Text))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Server can't be empty");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(tbProxyPort.Text))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Server port can't be empty");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int port;
|
|
|
|
|
if (!int.TryParse(tbProxyPort.Text, out port))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Invalid port format");
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
|
|
|
|
|
if (response.StatusCode == HttpStatusCode.OK)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Proxy is ok");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Proxy connect failed.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Proxy connect failed.");
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-12-16 22:25:22 +08:00
|
|
|
|
|
|
|
|
|
private void tbWebsite_MouseUp(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Process.Start("http://www.getwox.com");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tbNewVersionAvailable_MouseUp(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Release newRelease = new UpdateChecker().CheckUpgrade();
|
|
|
|
|
if (newRelease != null)
|
|
|
|
|
{
|
2014-12-16 23:29:25 +08:00
|
|
|
|
Process.Start("http://www.getwox.com/release/version/" + newRelease.version);
|
2014-12-16 22:25:22 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-25 18:00:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|