Cleanup proxy enable/disable, fix #518

This commit is contained in:
stafford 2016-03-11 12:31:21 +11:00 committed by bao-qian
parent e37332a5d2
commit 099b62b645
2 changed files with 13 additions and 36 deletions

View File

@ -287,10 +287,10 @@
</TabItem>
<TabItem Header="{DynamicResource proxy}" Height="22" VerticalAlignment="Top">
<StackPanel>
<CheckBox x:Name="cbEnableProxy" Margin="10">
<TextBlock Text="{DynamicResource enableProxy}" />
<CheckBox x:Name="ToggleProxy" Margin="10" Checked="ProxyToggled" Unchecked="ProxyToggled">
<TextBlock Text="{DynamicResource enableProxy}"/>
</CheckBox>
<Grid Margin="10">
<Grid Margin="10" IsEnabled="{Binding IsChecked, ElementName=ToggleProxy}">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
@ -326,11 +326,9 @@
<PasswordBox Width="200" HorizontalAlignment="Left" x:Name="tbProxyPassword" />
</Border>
</Grid>
<StackPanel Orientation="Horizontal">
<Button x:Name="btnTestProxy" Width="80" HorizontalAlignment="Left" Margin="10"
Click="btnTestProxy_Click" Content="{DynamicResource testProxy}" />
<Button x:Name="btnSaveProxy" Width="80" HorizontalAlignment="Left" Margin="10"
Click="btnSaveProxy_Click" Content="{DynamicResource save}" />
<StackPanel Orientation="Horizontal" IsEnabled="{Binding IsChecked, ElementName=ToggleProxy}">
<Button x:Name="btnTestProxy" Width="80" HorizontalAlignment="Left" Margin="10" Click="btnTestProxy_Click" Content="{DynamicResource testProxy}"/>
<Button x:Name="btnSaveProxy" Width="80" HorizontalAlignment="Left" Margin="10" Click="btnSaveProxy_Click" Content="{DynamicResource save}"/>
</StackPanel>
</StackPanel>
</TabItem>

View File

@ -51,6 +51,11 @@ namespace Wox
Loaded += Setting_Loaded;
}
private void ProxyToggled(object sender, RoutedEventArgs e)
{
_settings.ProxyEnabled = ToggleProxy.IsChecked ?? false;
}
private void Setting_Loaded(object sender, RoutedEventArgs ev)
{
#region General
@ -119,9 +124,7 @@ namespace Wox
#region Proxy
cbEnableProxy.Checked += (o, e) => EnableProxy();
cbEnableProxy.Unchecked += (o, e) => DisableProxy();
cbEnableProxy.IsChecked = _settings.ProxyEnabled;
ToggleProxy.IsChecked = _settings.ProxyEnabled;
tbProxyServer.Text = _settings.ProxyServer;
if (_settings.ProxyPort != 0)
{
@ -129,14 +132,6 @@ namespace Wox
}
tbProxyUserName.Text = _settings.ProxyUserName;
tbProxyPassword.Password = _settings.ProxyPassword;
if (_settings.ProxyEnabled)
{
EnableProxy();
}
else
{
DisableProxy();
}
#endregion
@ -726,7 +721,7 @@ namespace Wox
#region Proxy
private void btnSaveProxy_Click(object sender, RoutedEventArgs e)
{
_settings.ProxyEnabled = cbEnableProxy.IsChecked ?? false;
_settings.ProxyEnabled = ToggleProxy.IsChecked ?? false;
int port = 80;
if (_settings.ProxyEnabled)
@ -805,22 +800,6 @@ namespace Wox
}
}
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