mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-13 11:09:28 +08:00
Cleanup proxy enable/disable, fix #518
This commit is contained in:
parent
e37332a5d2
commit
099b62b645
@ -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>
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user