Refactoring proxy, part 2

This commit is contained in:
bao-qian
2016-06-19 16:18:43 +01:00
parent 764a372e9f
commit 3efeb4a0a6
41 changed files with 98 additions and 146 deletions

View File

@@ -1,8 +1,8 @@
using System.Windows;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Exception;
using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
namespace Wox

View File

@@ -4,10 +4,10 @@ using System.Timers;
using System.Windows;
using Wox.Core;
using Wox.Core.Plugin;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure.Image;
using Wox.Infrastructure.Logger;
using Wox.Infrastructure.UserSettings;
using Wox.ViewModel;
using Stopwatch = Wox.Infrastructure.Stopwatch;

View File

@@ -6,8 +6,8 @@ using System.Windows;
using NHotkey;
using NHotkey.Wpf;
using Wox.Core.Resource;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.UserSettings;
namespace Wox
{

View File

@@ -59,9 +59,9 @@
<system:String x:Key="deleteCustomHotkeyWarning">Wollen Sie die {0} Plugin Tastenkombination wirklich löschen?</system:String>
<!--Setting Proxy-->
<system:String x:Key="proxy">Proxy</system:String>
<system:String x:Key="enableProxy">Aktiviere Proxy</system:String>
<system:String x:Key="server">Server</system:String>
<system:String x:Key="proxy">HTTP Proxy</system:String>
<system:String x:Key="enableProxy">Aktiviere HTTP Proxy</system:String>
<system:String x:Key="server">HTTP Server</system:String>
<system:String x:Key="port">Port</system:String>
<system:String x:Key="userName">Benutzername</system:String>
<system:String x:Key="password">Passwort</system:String>

View File

@@ -59,9 +59,9 @@
<system:String x:Key="deleteCustomHotkeyWarning">Are you sure you want to delete {0} plugin hotkey?</system:String>
<!--Setting Proxy-->
<system:String x:Key="proxy">Proxy</system:String>
<system:String x:Key="enableProxy">Enable Proxy</system:String>
<system:String x:Key="server">Server</system:String>
<system:String x:Key="proxy">HTTP Proxy</system:String>
<system:String x:Key="enableProxy">Enable HTTP Proxy</system:String>
<system:String x:Key="server">HTTP Server</system:String>
<system:String x:Key="port">Port</system:String>
<system:String x:Key="userName">User Name</system:String>
<system:String x:Key="password">Password</system:String>

View File

@@ -59,9 +59,9 @@
<system:String x:Key="deleteCustomHotkeyWarning">Voulez-vous vraiment supprimer {0} raccourci(s) ?</system:String>
<!--Setting Proxy-->
<system:String x:Key="proxy">Proxy</system:String>
<system:String x:Key="enableProxy">Activer le proxy</system:String>
<system:String x:Key="server">Serveur</system:String>
<system:String x:Key="proxy">HTTP Proxy</system:String>
<system:String x:Key="enableProxy">Activer le HTTP proxy</system:String>
<system:String x:Key="server">HTTP Serveur</system:String>
<system:String x:Key="port">Port</system:String>
<system:String x:Key="userName">Utilisateur</system:String>
<system:String x:Key="password">Mot de passe</system:String>

View File

@@ -59,9 +59,9 @@
<system:String x:Key="deleteCustomHotkeyWarning">{0} プラグインのホットキーを本当に削除しますか?</system:String>
<!--Setting Proxy-->
<system:String x:Key="proxy">プロキシ</system:String>
<system:String x:Key="enableProxy">プロキシを有効化</system:String>
<system:String x:Key="server">サーバ</system:String>
<system:String x:Key="proxy">HTTP プロキシ</system:String>
<system:String x:Key="enableProxy">HTTP プロキシを有効化</system:String>
<system:String x:Key="server">HTTP サーバ</system:String>
<system:String x:Key="port">ポート</system:String>
<system:String x:Key="userName">ユーザ名</system:String>
<system:String x:Key="password">パスワード</system:String>

View File

@@ -59,9 +59,9 @@
<system:String x:Key="deleteCustomHotkeyWarning">Weet u zeker dat je {0} plugin sneltoets wilt verwijderen?</system:String>
<!--Setting Proxy-->
<system:String x:Key="proxy">Proxy</system:String>
<system:String x:Key="enableProxy">Enable Proxy</system:String>
<system:String x:Key="server">Server</system:String>
<system:String x:Key="proxy">HTTP Proxy</system:String>
<system:String x:Key="enableProxy">Enable HTTP Proxy</system:String>
<system:String x:Key="server">HTTP Server</system:String>
<system:String x:Key="port">Poort</system:String>
<system:String x:Key="userName">Gebruikersnaam</system:String>
<system:String x:Key="password">Wachtwoord</system:String>

View File

@@ -59,9 +59,9 @@
<system:String x:Key="deleteCustomHotkeyWarning">Czy jesteś pewien że chcesz usunąć skrót klawiszowy {0} wtyczki?</system:String>
<!--Setting Proxy-->
<system:String x:Key="proxy">Serwer proxy</system:String>
<system:String x:Key="enableProxy">Używaj proxy</system:String>
<system:String x:Key="server">Serwer</system:String>
<system:String x:Key="proxy">Serwer proxy HTTP</system:String>
<system:String x:Key="enableProxy">Używaj HTTP proxy</system:String>
<system:String x:Key="server">HTTP Serwer</system:String>
<system:String x:Key="port">Port</system:String>
<system:String x:Key="userName">Nazwa użytkownika</system:String>
<system:String x:Key="password">Hasło</system:String>

View File

@@ -59,9 +59,9 @@
<system:String x:Key="deleteCustomHotkeyWarning">Вы уверены что хотите удалить горячую клавишу для плагина {0}?</system:String>
<!--Setting Proxy-->
<system:String x:Key="proxy">Прокси</system:String>
<system:String x:Key="enableProxy">Включить прокси</system:String>
<system:String x:Key="server">Сервер</system:String>
<system:String x:Key="proxy">HTTP Прокси</system:String>
<system:String x:Key="enableProxy">Включить HTTP прокси</system:String>
<system:String x:Key="server">HTTP Сервер</system:String>
<system:String x:Key="port">Порт</system:String>
<system:String x:Key="userName">Логин</system:String>
<system:String x:Key="password">Пароль</system:String>

View File

@@ -59,9 +59,9 @@
<system:String x:Key="deleteCustomHotkeyWarning">你确定要删除插件 {0} 的热键吗?</system:String>
<!--设置,代理-->
<system:String x:Key="proxy">代理</system:String>
<system:String x:Key="enableProxy">启用代理</system:String>
<system:String x:Key="server">服务器</system:String>
<system:String x:Key="proxy">HTTP 代理</system:String>
<system:String x:Key="enableProxy">启用 HTTP 代理</system:String>
<system:String x:Key="server">HTTP 服务器</system:String>
<system:String x:Key="port">端口</system:String>
<system:String x:Key="userName">用户名</system:String>
<system:String x:Key="password">密码</system:String>

View File

@@ -59,9 +59,9 @@
<system:String x:Key="deleteCustomHotkeyWarning">確定要刪除外掛 {0} 的熱鍵嗎?</system:String>
<!--設置,代理-->
<system:String x:Key="proxy">代理</system:String>
<system:String x:Key="enableProxy">啟用代理</system:String>
<system:String x:Key="server">伺服器</system:String>
<system:String x:Key="proxy">HTTP 代理</system:String>
<system:String x:Key="enableProxy">啟用 HTTP 代理</system:String>
<system:String x:Key="server">HTTP 伺服器</system:String>
<system:String x:Key="Port">Port</system:String>
<system:String x:Key="userName">使用者</system:String>
<system:String x:Key="password">密碼</system:String>

View File

@@ -6,8 +6,8 @@ using System.Windows.Media.Animation;
using System.Windows.Controls;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure.UserSettings;
using Wox.ViewModel;
using Screen = System.Windows.Forms.Screen;
using ContextMenu = System.Windows.Forms.ContextMenu;

View File

@@ -3,8 +3,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:wox="clr-namespace:Wox"
xmlns:s="clr-namespace:Wox.Core.UserSettings;assembly=Wox.Core"
xmlns:vm="clr-namespace:Wox.ViewModel"
xmlns:userSettings="clr-namespace:Wox.Infrastructure.UserSettings;assembly=Wox.Infrastructure"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
x:Class="Wox.SettingWindow"
mc:Ignorable="d"
Icon="Images\app.png"
@@ -276,14 +277,14 @@
<GridView>
<GridViewColumn Header="{DynamicResource hotkey}" Width="180">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="s:CustomPluginHotkey">
<DataTemplate DataType="userSettings:CustomPluginHotkey">
<TextBlock Text="{Binding Hotkey}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="{DynamicResource actionKeywords}" Width="500">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="s:CustomPluginHotkey">
<DataTemplate DataType="userSettings:CustomPluginHotkey">
<TextBlock Text="{Binding ActionKeyword}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
@@ -304,10 +305,10 @@
</TabItem>
<TabItem Header="{DynamicResource proxy}">
<StackPanel>
<CheckBox Margin="10" IsChecked="{Binding Settings.ProxyEnabled}">
<CheckBox Margin="10" IsChecked="{Binding Settings.Proxy.Enabled}">
<TextBlock Text="{DynamicResource enableProxy}" />
</CheckBox>
<Grid Margin="10" IsEnabled="{Binding Settings.ProxyEnabled}">
<Grid Margin="10" IsEnabled="{Binding Settings.Proxy.Enabled}">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
@@ -319,15 +320,15 @@
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<TextBlock Text="{DynamicResource server}" Grid.Row="0" Grid.Column="0" Padding="5" />
<TextBox Text="{Binding Settings.ProxyServer}" Grid.Row="0" Grid.Column="1" Padding="5" />
<TextBox Text="{Binding Settings.Proxy.Server}" Grid.Row="0" Grid.Column="1" Padding="5" />
<TextBlock Text="{DynamicResource port}" Grid.Row="0" Grid.Column="2" Padding="5" />
<TextBox Text="{Binding Settings.ProxyPort}" Grid.Row="0" Grid.Column="3" Padding="5" />
<TextBox Text="{Binding Settings.Proxy.Port, TargetNullValue={x:Static sys:String.Empty} }" Grid.Row="0" Grid.Column="3" Padding="5" />
<TextBlock Text="{DynamicResource userName}" Grid.Row="1" Grid.Column="0" Padding="5" />
<TextBox Text="{Binding Settings.ProxyUserName}" Grid.Row="1" Grid.Column="1" Padding="5" />
<TextBox Text="{Binding Settings.Proxy.UserName}" Grid.Row="1" Grid.Column="1" Padding="5" />
<TextBlock Text="{DynamicResource password}" Grid.Row="1" Grid.Column="2" Padding="5" />
<TextBox Text="{Binding Settings.ProxyPassword}" Grid.Row="1" Grid.Column="3" Padding="5" />
<TextBox Text="{Binding Settings.Proxy.Password}" Grid.Row="1" Grid.Column="3" Padding="5" />
</Grid>
<Button Content="{DynamicResource testProxy}" IsEnabled="{Binding Settings.ProxyEnabled}"
<Button Content="{DynamicResource testProxy}" IsEnabled="{Binding Settings.Proxy.Enabled}"
Width="80" HorizontalAlignment="Left" Margin="10" Click="OnTestProxyClick" />
</StackPanel>
</TabItem>

View File

@@ -14,8 +14,8 @@ using NHotkey.Wpf;
using Wox.Core;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
using Wox.ViewModel;
@@ -264,29 +264,27 @@ namespace Wox
private void OnTestProxyClick(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(_settings.ProxyServer))
if (string.IsNullOrEmpty(_settings.Proxy.Server))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty"));
return;
}
if (_settings.ProxyPort > 0)
if (_settings.Proxy.Port <= 0)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("portCantBeEmpty"));
return;
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Infrastructure.Constant.Github);
request.Timeout = 1000 * 5;
request.ReadWriteTimeout = 1000 * 5;
if (string.IsNullOrEmpty(_settings.ProxyUserName) || string.IsNullOrEmpty(_settings.ProxyPassword))
if (string.IsNullOrEmpty(_settings.Proxy.UserName) || string.IsNullOrEmpty(_settings.Proxy.Password))
{
request.Proxy = new WebProxy(_settings.ProxyServer, _settings.ProxyPort);
request.Proxy = new WebProxy(_settings.Proxy.Server, _settings.Proxy.Port);
}
else
{
request.Proxy = new WebProxy(_settings.ProxyServer, _settings.ProxyPort)
request.Proxy = new WebProxy(_settings.Proxy.Server, _settings.Proxy.Port)
{
Credentials = new NetworkCredential(_settings.ProxyUserName, _settings.ProxyPassword)
Credentials = new NetworkCredential(_settings.Proxy.UserName, _settings.Proxy.Password)
};
}
try

View File

@@ -9,12 +9,12 @@ using NHotkey;
using NHotkey.Wpf;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.Image;
using Wox.Infrastructure.Storage;
using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
using Wox.Storage;
@@ -57,12 +57,6 @@ namespace Wox.ViewModel
_settings = settings;
// happlebao todo temp fix for instance code logic
HttpProxy.Instance.Settings = _settings;
InternationalizationManager.Instance.Settings = _settings;
InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
ThemeManager.Instance.Settings = _settings;
_queryHistoryStorage = new JsonStrorage<QueryHistory>();
_userSelectedRecordStorage = new JsonStrorage<UserSelectedRecord>();
_topMostRecordStorage = new JsonStrorage<TopMostRecord>();

View File

@@ -4,7 +4,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Data;
using Wox.Core.UserSettings;
using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
namespace Wox.ViewModel

View File

@@ -8,10 +8,11 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Http;
using Wox.Infrastructure.Storage;
using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
namespace Wox.ViewModel
@@ -31,6 +32,12 @@ namespace Wox.ViewModel
OnPropertyChanged(nameof(ActivatedTimes));
}
};
// happlebao todo temp fix for instance code logic
InternationalizationManager.Instance.Settings = Settings;
InternationalizationManager.Instance.ChangeLanguage(Settings.Language);
ThemeManager.Instance.Settings = Settings;
Http.Proxy = Settings.Proxy;
}
public Settings Settings { get; set; }