Browse Source

Remove ShadowsocksController.GetConfigurationCopy() and ServerSharingWindow

tags/4.3.0.0
database64128 3 years ago
parent
commit
a05a782293
No known key found for this signature in database GPG Key ID: 1CA27546BEDB8B01
11 changed files with 45 additions and 98 deletions
  1. +2
    -16
      shadowsocks-csharp/Controller/ShadowsocksController.cs
  2. +5
    -6
      shadowsocks-csharp/Controller/System/Hotkeys/HotkeyCallbacks.cs
  3. +0
    -11
      shadowsocks-csharp/ServerSharingWindow.xaml
  4. +0
    -27
      shadowsocks-csharp/ServerSharingWindow.xaml.cs
  5. +1
    -1
      shadowsocks-csharp/View/ConfigForm.cs
  6. +1
    -1
      shadowsocks-csharp/View/HotkeySettingsForm.cs
  7. +3
    -3
      shadowsocks-csharp/View/LogForm.cs
  8. +31
    -24
      shadowsocks-csharp/View/MenuViewController.cs
  9. +1
    -1
      shadowsocks-csharp/View/OnlineConfigForm.cs
  10. +1
    -1
      shadowsocks-csharp/View/ProxyForm.cs
  11. +0
    -7
      shadowsocks-csharp/shadowsocks-csharp.csproj

+ 2
- 16
shadowsocks-csharp/Controller/ShadowsocksController.cs View File

@@ -250,22 +250,8 @@ namespace Shadowsocks.Controller
Errored?.Invoke(this, new ErrorEventArgs(e));
}
public Server GetCurrentServer()
{
return _config.GetCurrentServer();
}
// always return copy
public Configuration GetConfigurationCopy()
{
return Configuration.Load();
}
// always return current instance
public Configuration GetCurrentConfiguration()
{
return _config;
}
public Server GetCurrentServer() => _config.GetCurrentServer();
public Configuration GetCurrentConfiguration() => _config;
public Server GetAServer(IStrategyCallerType type, IPEndPoint localIPEndPoint, EndPoint destEndPoint)
{


+ 5
- 6
shadowsocks-csharp/Controller/System/Hotkeys/HotkeyCallbacks.cs View File

@@ -46,21 +46,20 @@ namespace Shadowsocks.Controller.Hotkeys

private void SwitchSystemProxyCallback()
{
bool enabled = _controller.GetConfigurationCopy().enabled;
bool enabled = _controller.GetCurrentConfiguration().enabled;
_controller.ToggleEnable(!enabled);
}

private void SwitchSystemProxyModeCallback()
{
var config = _controller.GetConfigurationCopy();
if (config.enabled == false) return;
var currStatus = config.global;
_controller.ToggleGlobal(!currStatus);
var config = _controller.GetCurrentConfiguration();
if (config.enabled)
_controller.ToggleGlobal(!config.global);
}

private void SwitchAllowLanCallback()
{
var status = _controller.GetConfigurationCopy().shareOverLan;
var status = _controller.GetCurrentConfiguration().shareOverLan;
_controller.ToggleShareOverLAN(!status);
}



+ 0
- 11
shadowsocks-csharp/ServerSharingWindow.xaml View File

@@ -1,11 +0,0 @@
<Window x:Class="Shadowsocks.ServerSharingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Shadowsocks"
xmlns:views="clr-namespace:Shadowsocks.Views"
mc:Ignorable="d"
Title="Server Sharing" Height="400" Width="660">
<views:ServerSharingView />
</Window>

+ 0
- 27
shadowsocks-csharp/ServerSharingWindow.xaml.cs View File

@@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Shadowsocks
{
/// <summary>
/// Interaction logic for ServerSharingWindow.xaml
/// </summary>
public partial class ServerSharingWindow : Window
{
public ServerSharingWindow()
{
InitializeComponent();
}
}
}

+ 1
- 1
shadowsocks-csharp/View/ConfigForm.cs View File

@@ -433,7 +433,7 @@ namespace Shadowsocks.View
private void LoadCurrentConfiguration()
{
_modifiedConfiguration = controller.GetConfigurationCopy();
_modifiedConfiguration = controller.GetCurrentConfiguration();
LoadServerNameListToUI(_modifiedConfiguration);
_lastSelectedIndex = _modifiedConfiguration.index;


+ 1
- 1
shadowsocks-csharp/View/HotkeySettingsForm.cs View File

@@ -40,7 +40,7 @@ namespace Shadowsocks.View
private void LoadCurrentConfiguration()
{
_modifiedHotkeyConfig = _controller.GetConfigurationCopy().hotkey;
_modifiedHotkeyConfig = _controller.GetCurrentConfiguration().hotkey;
SetConfigToUI(_modifiedHotkeyConfig);
}


+ 3
- 3
shadowsocks-csharp/View/LogForm.cs View File

@@ -62,7 +62,7 @@ namespace Shadowsocks.View
LogMessageTextBox.AppendText("Cannot get the log file name from NLog config file. Please check if the nlog config file exists with corresponding XML nodes.");
}
LogViewerConfig config = controller.GetConfigurationCopy().logViewer;
LogViewerConfig config = controller.GetCurrentConfiguration().logViewer;
topMostTrigger = config.topMost;
wrapTextTrigger = config.wrapText;
@@ -244,7 +244,7 @@ namespace Shadowsocks.View
timer.Tick += Timer_Tick;
timer.Start();
LogViewerConfig config = controller.GetConfigurationCopy().logViewer;
LogViewerConfig config = controller.GetCurrentConfiguration().logViewer;
Height = config.Height;
Width = config.Width;
@@ -270,7 +270,7 @@ namespace Shadowsocks.View
{
timer.Stop();
controller.TrafficChanged -= controller_TrafficChanged;
LogViewerConfig config = controller.GetConfigurationCopy().logViewer;
LogViewerConfig config = controller.GetCurrentConfiguration().logViewer;
config.topMost = topMostTrigger;
config.wrapText = wrapTextTrigger;


+ 31
- 24
shadowsocks-csharp/View/MenuViewController.cs View File

@@ -3,6 +3,7 @@ using Shadowsocks.Controller;
using Shadowsocks.Model;
using Shadowsocks.Properties;
using Shadowsocks.Util;
using Shadowsocks.Views;
using System;
using System.Diagnostics;
using System.Drawing;
@@ -65,7 +66,7 @@ namespace Shadowsocks.View
private HotkeySettingsForm hotkeySettingsForm;
private OnlineConfigForm onlineConfigForm;
private ServerSharingWindow serverSharingWindow;
private System.Windows.Window serverSharingWindow;
// color definition for icon color transformation
private readonly Color colorMaskBlue = Color.FromArgb(255, 25, 125, 191);
@@ -106,7 +107,7 @@ namespace Shadowsocks.View
LoadCurrentConfiguration();
Configuration config = controller.GetConfigurationCopy();
Configuration config = controller.GetCurrentConfiguration();
if (config.firstRun)
{
@@ -123,7 +124,7 @@ namespace Shadowsocks.View
private void UpdateTrayIconAndNotifyText()
{
Configuration config = controller.GetConfigurationCopy();
Configuration config = controller.GetCurrentConfiguration();
bool enabled = config.enabled;
bool global = config.global;
@@ -349,7 +350,7 @@ namespace Shadowsocks.View
private void LoadCurrentConfiguration()
{
Configuration config = controller.GetConfigurationCopy();
Configuration config = controller.GetCurrentConfiguration();
UpdateServersMenu();
UpdateSystemProxyItemsEnabledStatus(config);
ShareOverLANItem.Checked = config.shareOverLan;
@@ -537,7 +538,7 @@ namespace Shadowsocks.View
private void CheckUpdateForFirstRun()
{
Configuration config = controller.GetConfigurationCopy();
Configuration config = controller.GetCurrentConfiguration();
if (config.firstRun)
return;
_isStartupChecking = true;
@@ -555,7 +556,7 @@ namespace Shadowsocks.View
void controller_ShareOverLANStatusChanged(object sender, EventArgs e)
{
ShareOverLANItem.Checked = controller.GetConfigurationCopy().shareOverLan;
ShareOverLANItem.Checked = controller.GetCurrentConfiguration().shareOverLan;
}
private void proxyItem_Click(object sender, EventArgs e)
@@ -612,19 +613,19 @@ namespace Shadowsocks.View
private void controller_EnableStatusChanged(object sender, EventArgs e)
{
disableItem.Checked = !controller.GetConfigurationCopy().enabled;
disableItem.Checked = !controller.GetCurrentConfiguration().enabled;
}
private void EnableItem_Click(object sender, EventArgs e)
{
controller.ToggleEnable(false);
Configuration config = controller.GetConfigurationCopy();
Configuration config = controller.GetCurrentConfiguration();
UpdateSystemProxyItemsEnabledStatus(config);
}
void controller_EnableGlobalChanged(object sender, EventArgs e)
{
globalModeItem.Checked = controller.GetConfigurationCopy().global;
globalModeItem.Checked = controller.GetCurrentConfiguration().global;
PACModeItem.Checked = !globalModeItem.Checked;
}
@@ -647,7 +648,7 @@ namespace Shadowsocks.View
{
controller.ToggleEnable(true);
controller.ToggleGlobal(true);
Configuration config = controller.GetConfigurationCopy();
Configuration config = controller.GetCurrentConfiguration();
UpdateSystemProxyItemsEnabledStatus(config);
}
@@ -655,7 +656,7 @@ namespace Shadowsocks.View
{
controller.ToggleEnable(true);
controller.ToggleGlobal(false);
Configuration config = controller.GetConfigurationCopy();
Configuration config = controller.GetCurrentConfiguration();
UpdateSystemProxyItemsEnabledStatus(config);
}
@@ -684,7 +685,7 @@ namespace Shadowsocks.View
items.Add(strategyCount++, new MenuItem("-"));
int serverCount = 0;
Configuration configuration = controller.GetConfigurationCopy();
Configuration configuration = controller.GetCurrentConfiguration();
foreach (var server in configuration.configs)
{
try
@@ -747,7 +748,13 @@ namespace Shadowsocks.View
{
if (serverSharingWindow == null)
{
serverSharingWindow = new ServerSharingWindow();
serverSharingWindow = new System.Windows.Window()
{
Title = "Server Sharing",
Height = 400,
Width = 660,
Content = new ServerSharingView()
};
serverSharingWindow.Closed += ServerSharingWindow_Closed;
serverSharingWindow.Show();
}
@@ -870,11 +877,11 @@ namespace Shadowsocks.View
{
if (!onlinePACItem.Checked)
{
if (string.IsNullOrEmpty(controller.GetConfigurationCopy().pacUrl))
if (string.IsNullOrEmpty(controller.GetCurrentConfiguration().pacUrl))
{
UpdateOnlinePACURLItem_Click(sender, e);
}
if (!string.IsNullOrEmpty(controller.GetConfigurationCopy().pacUrl))
if (!string.IsNullOrEmpty(controller.GetCurrentConfiguration().pacUrl))
{
localPACItem.Checked = false;
onlinePACItem.Checked = true;
@@ -886,7 +893,7 @@ namespace Shadowsocks.View
private void UpdateOnlinePACURLItem_Click(object sender, EventArgs e)
{
string origPacUrl = controller.GetConfigurationCopy().pacUrl;
string origPacUrl = controller.GetCurrentConfiguration().pacUrl;
string pacUrl = Microsoft.VisualBasic.Interaction.InputBox(
I18N.GetString("Please input PAC Url"),
I18N.GetString("Edit Online PAC URL"),
@@ -899,13 +906,13 @@ namespace Shadowsocks.View
private void SecureLocalPacUrlToggleItem_Click(object sender, EventArgs e)
{
Configuration configuration = controller.GetConfigurationCopy();
Configuration configuration = controller.GetCurrentConfiguration();
controller.ToggleSecureLocalPac(!configuration.secureLocalPac);
}
private void RegenerateLocalPacOnUpdateItem_Click(object sender, EventArgs e)
{
var config = controller.GetConfigurationCopy();
var config = controller.GetCurrentConfiguration();
controller.ToggleRegeneratePacOnUpdate(!config.regeneratePacOnUpdate);
}
@@ -974,12 +981,12 @@ namespace Shadowsocks.View
void controller_VerboseLoggingStatusChanged(object sender, EventArgs e)
{
VerboseLoggingToggleItem.Checked = controller.GetConfigurationCopy().isVerboseLogging;
VerboseLoggingToggleItem.Checked = controller.GetCurrentConfiguration().isVerboseLogging;
}
void controller_ShowPluginOutputChanged(object sender, EventArgs e)
{
ShowPluginOutputToggleItem.Checked = controller.GetConfigurationCopy().showPluginOutput;
ShowPluginOutputToggleItem.Checked = controller.GetCurrentConfiguration().showPluginOutput;
}
private void VerboseLoggingToggleItem_Click(object sender, EventArgs e)
@@ -1023,28 +1030,28 @@ namespace Shadowsocks.View
private void UpdateUpdateMenu()
{
Configuration configuration = controller.GetConfigurationCopy();
Configuration configuration = controller.GetCurrentConfiguration();
autoCheckUpdatesToggleItem.Checked = configuration.autoCheckUpdate;
checkPreReleaseToggleItem.Checked = configuration.checkPreRelease;
}
private void autoCheckUpdatesToggleItem_Click(object sender, EventArgs e)
{
Configuration configuration = controller.GetConfigurationCopy();
Configuration configuration = controller.GetCurrentConfiguration();
controller.ToggleCheckingUpdate(!configuration.autoCheckUpdate);
UpdateUpdateMenu();
}
private void checkPreReleaseToggleItem_Click(object sender, EventArgs e)
{
Configuration configuration = controller.GetConfigurationCopy();
Configuration configuration = controller.GetCurrentConfiguration();
controller.ToggleCheckingPreRelease(!configuration.checkPreRelease);
UpdateUpdateMenu();
}
private void checkUpdatesItem_Click(object sender, EventArgs e)
{
updateChecker.CheckUpdate(controller.GetConfigurationCopy());
updateChecker.CheckUpdate(controller.GetCurrentConfiguration());
}
private void AboutItem_Click(object sender, EventArgs e)


+ 1
- 1
shadowsocks-csharp/View/OnlineConfigForm.cs View File

@@ -24,7 +24,7 @@ namespace Shadowsocks.View

private void LoadConfig()
{
config = controller.GetConfigurationCopy();
config = controller.GetCurrentConfiguration();
var idx = UrlListBox.SelectedIndex;
UrlListBox.Items.Clear();



+ 1
- 1
shadowsocks-csharp/View/ProxyForm.cs View File

@@ -41,7 +41,7 @@ namespace Shadowsocks.View
private void LoadCurrentConfiguration()
{
_modifiedProxyConfig = controller.GetConfigurationCopy().proxy;
_modifiedProxyConfig = controller.GetCurrentConfiguration().proxy;
UseProxyCheckBox.Checked = _modifiedProxyConfig.useProxy;
ProxyServerTextBox.Text = _modifiedProxyConfig.proxyServer;
ProxyPortTextBox.Text = _modifiedProxyConfig.proxyPort.ToString();


+ 0
- 7
shadowsocks-csharp/shadowsocks-csharp.csproj View File

@@ -257,9 +257,6 @@
<Compile Include="Controller\Strategy\IStrategy.cs" />
<Compile Include="Controller\Service\Sip003Plugin.cs" />
<Compile Include="Proxy\Socks5Proxy.cs" />
<Compile Include="ServerSharingWindow.xaml.cs">
<DependentUpon>ServerSharingWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Settings.cs" />
<Compile Include="Controller\System\Hotkeys\Hotkeys.cs" />
<Compile Include="Util\ProcessManagement\Job.cs" />
@@ -415,10 +412,6 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Page Include="ServerSharingWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ServerSharingView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>


Loading…
Cancel
Save