mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 19:49:15 +08:00
Cleanup proxy enable/disable, fix #518
This commit is contained in:
parent
e37332a5d2
commit
099b62b645
@ -287,10 +287,10 @@
|
|||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="{DynamicResource proxy}" Height="22" VerticalAlignment="Top">
|
<TabItem Header="{DynamicResource proxy}" Height="22" VerticalAlignment="Top">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<CheckBox x:Name="cbEnableProxy" Margin="10">
|
<CheckBox x:Name="ToggleProxy" Margin="10" Checked="ProxyToggled" Unchecked="ProxyToggled">
|
||||||
<TextBlock Text="{DynamicResource enableProxy}" />
|
<TextBlock Text="{DynamicResource enableProxy}"/>
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
<Grid Margin="10">
|
<Grid Margin="10" IsEnabled="{Binding IsChecked, ElementName=ToggleProxy}">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
@ -326,11 +326,9 @@
|
|||||||
<PasswordBox Width="200" HorizontalAlignment="Left" x:Name="tbProxyPassword" />
|
<PasswordBox Width="200" HorizontalAlignment="Left" x:Name="tbProxyPassword" />
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal" IsEnabled="{Binding IsChecked, ElementName=ToggleProxy}">
|
||||||
<Button x:Name="btnTestProxy" Width="80" HorizontalAlignment="Left" Margin="10"
|
<Button x:Name="btnTestProxy" Width="80" HorizontalAlignment="Left" Margin="10" Click="btnTestProxy_Click" Content="{DynamicResource testProxy}"/>
|
||||||
Click="btnTestProxy_Click" Content="{DynamicResource testProxy}" />
|
<Button x:Name="btnSaveProxy" Width="80" HorizontalAlignment="Left" Margin="10" Click="btnSaveProxy_Click" Content="{DynamicResource save}"/>
|
||||||
<Button x:Name="btnSaveProxy" Width="80" HorizontalAlignment="Left" Margin="10"
|
|
||||||
Click="btnSaveProxy_Click" Content="{DynamicResource save}" />
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
@ -51,6 +51,11 @@ namespace Wox
|
|||||||
Loaded += Setting_Loaded;
|
Loaded += Setting_Loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ProxyToggled(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_settings.ProxyEnabled = ToggleProxy.IsChecked ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
private void Setting_Loaded(object sender, RoutedEventArgs ev)
|
private void Setting_Loaded(object sender, RoutedEventArgs ev)
|
||||||
{
|
{
|
||||||
#region General
|
#region General
|
||||||
@ -119,9 +124,7 @@ namespace Wox
|
|||||||
|
|
||||||
#region Proxy
|
#region Proxy
|
||||||
|
|
||||||
cbEnableProxy.Checked += (o, e) => EnableProxy();
|
ToggleProxy.IsChecked = _settings.ProxyEnabled;
|
||||||
cbEnableProxy.Unchecked += (o, e) => DisableProxy();
|
|
||||||
cbEnableProxy.IsChecked = _settings.ProxyEnabled;
|
|
||||||
tbProxyServer.Text = _settings.ProxyServer;
|
tbProxyServer.Text = _settings.ProxyServer;
|
||||||
if (_settings.ProxyPort != 0)
|
if (_settings.ProxyPort != 0)
|
||||||
{
|
{
|
||||||
@ -129,14 +132,6 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
tbProxyUserName.Text = _settings.ProxyUserName;
|
tbProxyUserName.Text = _settings.ProxyUserName;
|
||||||
tbProxyPassword.Password = _settings.ProxyPassword;
|
tbProxyPassword.Password = _settings.ProxyPassword;
|
||||||
if (_settings.ProxyEnabled)
|
|
||||||
{
|
|
||||||
EnableProxy();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DisableProxy();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -726,7 +721,7 @@ namespace Wox
|
|||||||
#region Proxy
|
#region Proxy
|
||||||
private void btnSaveProxy_Click(object sender, RoutedEventArgs e)
|
private void btnSaveProxy_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
_settings.ProxyEnabled = cbEnableProxy.IsChecked ?? false;
|
_settings.ProxyEnabled = ToggleProxy.IsChecked ?? false;
|
||||||
|
|
||||||
int port = 80;
|
int port = 80;
|
||||||
if (_settings.ProxyEnabled)
|
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
|
#endregion
|
||||||
|
|
||||||
#region About
|
#region About
|
||||||
|
Loading…
Reference in New Issue
Block a user