mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Pack python env to zip
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
@@ -184,11 +185,47 @@ namespace Wox
|
||||
|
||||
#endregion
|
||||
|
||||
#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
|
||||
|
||||
//PreviewPanel
|
||||
settingsLoaded = true;
|
||||
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private List<string> LoadAvailableThemes()
|
||||
{
|
||||
string themePath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Themes");
|
||||
@@ -565,5 +602,87 @@ namespace Wox
|
||||
{
|
||||
Process.Start("http://www.getwox.com/theme");
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user