Browse Source

Add Json.Net and separate out Statistics Configuration file

Import Json.Net since it's difficult for SimpleJson to deal with nested type.
tags/3.0
icylogic 9 years ago
parent
commit
4e1b140dd9
10 changed files with 132 additions and 71 deletions
  1. +7
    -2
      shadowsocks-csharp/Controller/ShadowsocksController.cs
  2. +1
    -1
      shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs
  3. +0
    -2
      shadowsocks-csharp/Model/Configuration.cs
  4. +39
    -0
      shadowsocks-csharp/Model/StatisticsStrategyConfiguration.cs
  5. +8
    -0
      shadowsocks-csharp/View/MenuViewController.cs
  6. +60
    -57
      shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.Designer.cs
  7. +6
    -2
      shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs
  8. +0
    -3
      shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.resx
  9. +2
    -1
      shadowsocks-csharp/packages.config
  10. +9
    -3
      shadowsocks-csharp/shadowsocks-csharp.csproj

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

@@ -26,6 +26,8 @@ namespace Shadowsocks.Controller
private PolipoRunner polipoRunner; private PolipoRunner polipoRunner;
private GFWListUpdater gfwListUpdater; private GFWListUpdater gfwListUpdater;
private AvailabilityStatistics _availabilityStatics; private AvailabilityStatistics _availabilityStatics;
public StatisticsStrategyConfiguration StatisticsConfiguration { get; private set; }
private bool stopped = false; private bool stopped = false;
private bool _systemProxyIsDirty = false; private bool _systemProxyIsDirty = false;
@@ -53,10 +55,12 @@ namespace Shadowsocks.Controller
public ShadowsocksController() public ShadowsocksController()
{ {
_config = Configuration.Load(); _config = Configuration.Load();
StatisticsConfiguration = StatisticsStrategyConfiguration.Load();
_strategyManager = new StrategyManager(this); _strategyManager = new StrategyManager(this);
StartReleasingMemory(); StartReleasingMemory();
} }
public void Start() public void Start()
{ {
Reload(); Reload();
@@ -127,8 +131,8 @@ namespace Shadowsocks.Controller
public void SaveStrategyConfigurations(StatisticsStrategyConfiguration configuration) public void SaveStrategyConfigurations(StatisticsStrategyConfiguration configuration)
{ {
_config.statisticsStrategyConfiguration = configuration;
SaveConfig(_config);
StatisticsConfiguration = configuration;
StatisticsStrategyConfiguration.Save(configuration);
} }
public bool AddServerBySSURL(string ssURL) public bool AddServerBySSURL(string ssURL)
@@ -290,6 +294,7 @@ namespace Shadowsocks.Controller
{ {
// some logic in configuration updated the config when saving, we need to read it again // some logic in configuration updated the config when saving, we need to read it again
_config = Configuration.Load(); _config = Configuration.Load();
StatisticsConfiguration = StatisticsStrategyConfiguration.Load();
if (polipoRunner == null) if (polipoRunner == null)
{ {


+ 1
- 1
shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs View File

@@ -93,7 +93,7 @@ namespace Shadowsocks.Controller.Strategy
return (double)data.SuccessTimes / (data.SuccessTimes + data.TimedOutTimes); //simply choose min package loss return (double)data.SuccessTimes / (data.SuccessTimes + data.TimedOutTimes); //simply choose min package loss
} }


private class StatisticsData
public class StatisticsData
{ {
public int SuccessTimes; public int SuccessTimes;
public int TimedOutTimes; public int TimedOutTimes;


+ 0
- 2
shadowsocks-csharp/Model/Configuration.cs View File

@@ -25,8 +25,6 @@ namespace Shadowsocks.Model
public bool useOnlinePac; public bool useOnlinePac;
public bool availabilityStatistics; public bool availabilityStatistics;
public StatisticsStrategyConfiguration statisticsStrategyConfiguration;
private static string CONFIG_FILE = "gui-config.json"; private static string CONFIG_FILE = "gui-config.json";
public Server GetCurrentServer() public Server GetCurrentServer()


+ 39
- 0
shadowsocks-csharp/Model/StatisticsStrategyConfiguration.cs View File

@@ -1,8 +1,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Shadowsocks.Controller;
using Shadowsocks.Controller.Strategy; using Shadowsocks.Controller.Strategy;
using SimpleJson;
using Newtonsoft.Json;


namespace Shadowsocks.Model namespace Shadowsocks.Model
{ {
@@ -17,6 +21,41 @@ namespace Shadowsocks.Model
private int _dataCollectionMinutes; private int _dataCollectionMinutes;
private int _repeatTimesNum; private int _repeatTimesNum;



private const string ConfigFile = "statistics-config.json";

public static StatisticsStrategyConfiguration Load()
{
try
{
var content = File.ReadAllText(ConfigFile);
var configuration = JsonConvert.DeserializeObject<StatisticsStrategyConfiguration>(content);
return configuration;
}
catch (FileNotFoundException e)
{
return new StatisticsStrategyConfiguration();
}
catch (Exception e)
{
Logging.LogUsefulException(e);
return new StatisticsStrategyConfiguration();
}
}

public static void Save(StatisticsStrategyConfiguration configuration)
{
try
{
var content = JsonConvert.SerializeObject(configuration, Formatting.Indented);
File.WriteAllText(ConfigFile, content);
}
catch (Exception e)
{
Logging.LogUsefulException(e);
}
}

public Dictionary<string, float> Calculations; public Dictionary<string, float> Calculations;


public StatisticsStrategyConfiguration() public StatisticsStrategyConfiguration()


+ 8
- 0
shadowsocks-csharp/View/MenuViewController.cs View File

@@ -164,6 +164,7 @@ namespace Shadowsocks.View
this.ServersItem = CreateMenuGroup("Servers", new MenuItem[] { this.ServersItem = CreateMenuGroup("Servers", new MenuItem[] {
this.SeperatorItem = new MenuItem("-"), this.SeperatorItem = new MenuItem("-"),
this.ConfigItem = CreateMenuItem("Edit Servers...", new EventHandler(this.Config_Click)), this.ConfigItem = CreateMenuItem("Edit Servers...", new EventHandler(this.Config_Click)),
CreateMenuItem("Statistics Config...", StatisticsConfigItem_Click),
CreateMenuItem("Show QRCode...", new EventHandler(this.QRCodeItem_Click)), CreateMenuItem("Show QRCode...", new EventHandler(this.QRCodeItem_Click)),
CreateMenuItem("Scan QRCode from Screen...", new EventHandler(this.ScanQRCodeItem_Click)) CreateMenuItem("Scan QRCode from Screen...", new EventHandler(this.ScanQRCodeItem_Click))
}), }),
@@ -188,6 +189,7 @@ namespace Shadowsocks.View
}); });
} }
private void controller_ConfigChanged(object sender, EventArgs e) private void controller_ConfigChanged(object sender, EventArgs e)
{ {
LoadCurrentConfiguration(); LoadCurrentConfiguration();
@@ -417,6 +419,12 @@ namespace Shadowsocks.View
new LogForm(argument).Show(); new LogForm(argument).Show();
} }
private void StatisticsConfigItem_Click(object sender, EventArgs e)
{
StatisticsStrategyConfigurationForm form = new StatisticsStrategyConfigurationForm(controller);
form.Show();
}
private void QRCodeItem_Click(object sender, EventArgs e) private void QRCodeItem_Click(object sender, EventArgs e)
{ {


+ 60
- 57
shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.Designer.cs View File

@@ -29,14 +29,13 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.StatisticsChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.StatisticsChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.byISPCheckBox = new System.Windows.Forms.CheckBox(); this.byISPCheckBox = new System.Windows.Forms.CheckBox();
this.bindingConfiguration = new System.Windows.Forms.BindingSource(this.components);
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
@@ -56,10 +55,10 @@
this.splitContainer3 = new System.Windows.Forms.SplitContainer(); this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.calculationContainer = new System.Windows.Forms.FlowLayoutPanel(); this.calculationContainer = new System.Windows.Forms.FlowLayoutPanel();
this.OKButton = new System.Windows.Forms.Button();
this.CancelButton = new System.Windows.Forms.Button(); this.CancelButton = new System.Windows.Forms.Button();
this.OKButton = new System.Windows.Forms.Button();
this.bindingConfiguration = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.StatisticsChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.StatisticsChart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingConfiguration)).BeginInit();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
@@ -76,46 +75,47 @@
this.splitContainer3.Panel1.SuspendLayout(); this.splitContainer3.Panel1.SuspendLayout();
this.splitContainer3.Panel2.SuspendLayout(); this.splitContainer3.Panel2.SuspendLayout();
this.splitContainer3.SuspendLayout(); this.splitContainer3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.bindingConfiguration)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// StatisticsChart // StatisticsChart
// //
this.StatisticsChart.BackColor = System.Drawing.Color.Transparent; this.StatisticsChart.BackColor = System.Drawing.Color.Transparent;
chartArea2.AxisX.MajorGrid.Enabled = false;
chartArea2.AxisY.MajorGrid.Enabled = false;
chartArea2.AxisY2.MajorGrid.Enabled = false;
chartArea2.BackColor = System.Drawing.Color.Transparent;
chartArea2.Name = "ChartArea";
this.StatisticsChart.ChartAreas.Add(chartArea2);
chartArea1.AxisX.MajorGrid.Enabled = false;
chartArea1.AxisY.MajorGrid.Enabled = false;
chartArea1.AxisY2.MajorGrid.Enabled = false;
chartArea1.BackColor = System.Drawing.Color.Transparent;
chartArea1.Name = "ChartArea";
this.StatisticsChart.ChartAreas.Add(chartArea1);
this.StatisticsChart.Dock = System.Windows.Forms.DockStyle.Fill; this.StatisticsChart.Dock = System.Windows.Forms.DockStyle.Fill;
legend2.BackColor = System.Drawing.Color.Transparent;
legend2.Name = "ChartLegend";
this.StatisticsChart.Legends.Add(legend2);
legend1.BackColor = System.Drawing.Color.Transparent;
legend1.Name = "ChartLegend";
this.StatisticsChart.Legends.Add(legend1);
this.StatisticsChart.Location = new System.Drawing.Point(0, 0); this.StatisticsChart.Location = new System.Drawing.Point(0, 0);
this.StatisticsChart.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10); this.StatisticsChart.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.StatisticsChart.Name = "StatisticsChart"; this.StatisticsChart.Name = "StatisticsChart";
this.StatisticsChart.Palette = System.Windows.Forms.DataVisualization.Charting.ChartColorPalette.Pastel; this.StatisticsChart.Palette = System.Windows.Forms.DataVisualization.Charting.ChartColorPalette.Pastel;
series4.ChartArea = "ChartArea";
series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Area;
series4.Color = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(204)))), ((int)(((byte)(204)))));
series4.Legend = "ChartLegend";
series4.Name = "Data Transferred";
series5.ChartArea = "ChartArea";
series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bubble;
series5.Color = System.Drawing.Color.FromArgb(((int)(((byte)(221)))), ((int)(((byte)(88)))), ((int)(((byte)(0)))));
series5.Legend = "ChartLegend";
series5.Name = "Package Loss";
series5.YValuesPerPoint = 4;
series6.BorderWidth = 4;
series6.ChartArea = "ChartArea";
series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series6.Color = System.Drawing.Color.FromArgb(((int)(((byte)(155)))), ((int)(((byte)(77)))), ((int)(((byte)(150)))));
series6.Legend = "ChartLegend";
series6.Name = "Ping";
this.StatisticsChart.Series.Add(series4);
this.StatisticsChart.Series.Add(series5);
this.StatisticsChart.Series.Add(series6);
this.StatisticsChart.Size = new System.Drawing.Size(951, 221);
series1.ChartArea = "ChartArea";
series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Area;
series1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(204)))), ((int)(((byte)(204)))));
series1.Legend = "ChartLegend";
series1.Name = "Data Transferred";
series2.ChartArea = "ChartArea";
series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bubble;
series2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(221)))), ((int)(((byte)(88)))), ((int)(((byte)(0)))));
series2.Legend = "ChartLegend";
series2.Name = "Package Loss";
series2.YValuesPerPoint = 4;
series3.BorderWidth = 4;
series3.ChartArea = "ChartArea";
series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series3.Color = System.Drawing.Color.FromArgb(((int)(((byte)(155)))), ((int)(((byte)(77)))), ((int)(((byte)(150)))));
series3.Legend = "ChartLegend";
series3.Name = "Ping";
this.StatisticsChart.Series.Add(series1);
this.StatisticsChart.Series.Add(series2);
this.StatisticsChart.Series.Add(series3);
this.StatisticsChart.Size = new System.Drawing.Size(951, 222);
this.StatisticsChart.TabIndex = 2; this.StatisticsChart.TabIndex = 2;
// //
// byISPCheckBox // byISPCheckBox
@@ -130,10 +130,6 @@
this.byISPCheckBox.Text = "By ISP/geolocation"; this.byISPCheckBox.Text = "By ISP/geolocation";
this.byISPCheckBox.UseVisualStyleBackColor = true; this.byISPCheckBox.UseVisualStyleBackColor = true;
// //
// bindingConfiguration
//
this.bindingConfiguration.DataSource = typeof(Shadowsocks.Model.StatisticsStrategyConfiguration);
//
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
@@ -169,7 +165,7 @@
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.radioButton2); this.groupBox1.Controls.Add(this.radioButton2);
this.groupBox1.Controls.Add(this.radioButton1); this.groupBox1.Controls.Add(this.radioButton1);
this.groupBox1.Location = new System.Drawing.Point(698, 12);
this.groupBox1.Location = new System.Drawing.Point(698, 7);
this.groupBox1.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10); this.groupBox1.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(5, 10, 5, 10); this.groupBox1.Padding = new System.Windows.Forms.Padding(5, 10, 5, 10);
@@ -205,6 +201,7 @@
// splitContainer1 // splitContainer1
// //
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.IsSplitterFixed = true;
this.splitContainer1.Location = new System.Drawing.Point(0, 0); this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10); this.splitContainer1.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.splitContainer1.Name = "splitContainer1"; this.splitContainer1.Name = "splitContainer1";
@@ -221,7 +218,7 @@
this.splitContainer1.Panel2.Controls.Add(this.groupBox1); this.splitContainer1.Panel2.Controls.Add(this.groupBox1);
this.splitContainer1.Panel2.Controls.Add(this.StatisticsChart); this.splitContainer1.Panel2.Controls.Add(this.StatisticsChart);
this.splitContainer1.Size = new System.Drawing.Size(951, 458); this.splitContainer1.Size = new System.Drawing.Size(951, 458);
this.splitContainer1.SplitterDistance = 227;
this.splitContainer1.SplitterDistance = 226;
this.splitContainer1.SplitterWidth = 10; this.splitContainer1.SplitterWidth = 10;
this.splitContainer1.TabIndex = 12; this.splitContainer1.TabIndex = 12;
// //
@@ -252,7 +249,7 @@
// splitContainer2.Panel2 // splitContainer2.Panel2
// //
this.splitContainer2.Panel2.Controls.Add(this.splitContainer3); this.splitContainer2.Panel2.Controls.Add(this.splitContainer3);
this.splitContainer2.Size = new System.Drawing.Size(951, 227);
this.splitContainer2.Size = new System.Drawing.Size(951, 226);
this.splitContainer2.SplitterDistance = 365; this.splitContainer2.SplitterDistance = 365;
this.splitContainer2.SplitterWidth = 5; this.splitContainer2.SplitterWidth = 5;
this.splitContainer2.TabIndex = 7; this.splitContainer2.TabIndex = 7;
@@ -404,7 +401,7 @@
// splitContainer3.Panel2 // splitContainer3.Panel2
// //
this.splitContainer3.Panel2.Controls.Add(this.calculationContainer); this.splitContainer3.Panel2.Controls.Add(this.calculationContainer);
this.splitContainer3.Size = new System.Drawing.Size(581, 227);
this.splitContainer3.Size = new System.Drawing.Size(581, 226);
this.splitContainer3.SplitterDistance = 46; this.splitContainer3.SplitterDistance = 46;
this.splitContainer3.SplitterWidth = 10; this.splitContainer3.SplitterWidth = 10;
this.splitContainer3.TabIndex = 6; this.splitContainer3.TabIndex = 6;
@@ -426,11 +423,23 @@
this.calculationContainer.Location = new System.Drawing.Point(0, 0); this.calculationContainer.Location = new System.Drawing.Point(0, 0);
this.calculationContainer.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10); this.calculationContainer.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.calculationContainer.Name = "calculationContainer"; this.calculationContainer.Name = "calculationContainer";
this.calculationContainer.Size = new System.Drawing.Size(581, 171);
this.calculationContainer.Size = new System.Drawing.Size(581, 170);
this.calculationContainer.TabIndex = 1; this.calculationContainer.TabIndex = 1;
// //
// CancelButton
//
this.CancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.CancelButton.Location = new System.Drawing.Point(844, 166);
this.CancelButton.Name = "CancelButton";
this.CancelButton.Size = new System.Drawing.Size(93, 43);
this.CancelButton.TabIndex = 5;
this.CancelButton.Text = "Cancel";
this.CancelButton.UseVisualStyleBackColor = true;
this.CancelButton.Click += new System.EventHandler(this.CancelButton_Click);
//
// OKButton // OKButton
// //
this.OKButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.OKButton.Location = new System.Drawing.Point(745, 166); this.OKButton.Location = new System.Drawing.Point(745, 166);
this.OKButton.Name = "OKButton"; this.OKButton.Name = "OKButton";
this.OKButton.Size = new System.Drawing.Size(93, 43); this.OKButton.Size = new System.Drawing.Size(93, 43);
@@ -439,15 +448,9 @@
this.OKButton.UseVisualStyleBackColor = true; this.OKButton.UseVisualStyleBackColor = true;
this.OKButton.Click += new System.EventHandler(this.OKButton_Click); this.OKButton.Click += new System.EventHandler(this.OKButton_Click);
// //
// CancelButton
// bindingConfiguration
// //
this.CancelButton.Location = new System.Drawing.Point(844, 166);
this.CancelButton.Name = "CancelButton";
this.CancelButton.Size = new System.Drawing.Size(93, 43);
this.CancelButton.TabIndex = 5;
this.CancelButton.Text = "Cancel";
this.CancelButton.UseVisualStyleBackColor = true;
this.CancelButton.Click += new System.EventHandler(this.CancelButton_Click);
this.bindingConfiguration.DataSource = typeof(Shadowsocks.Model.StatisticsStrategyConfiguration);
// //
// StatisticsStrategyConfigurationForm // StatisticsStrategyConfigurationForm
// //
@@ -462,7 +465,6 @@
this.Name = "StatisticsStrategyConfigurationForm"; this.Name = "StatisticsStrategyConfigurationForm";
this.Text = "StatisticsStrategyConfigurationForm"; this.Text = "StatisticsStrategyConfigurationForm";
((System.ComponentModel.ISupportInitialize)(this.StatisticsChart)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.StatisticsChart)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingConfiguration)).EndInit();
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout(); this.groupBox1.PerformLayout();
this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel1.ResumeLayout(false);
@@ -482,6 +484,7 @@
this.splitContainer3.Panel2.ResumeLayout(false); this.splitContainer3.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();
this.splitContainer3.ResumeLayout(false); this.splitContainer3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.bindingConfiguration)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);


} }
@@ -509,7 +512,7 @@
private System.Windows.Forms.Label label8; private System.Windows.Forms.Label label8;
private System.Windows.Forms.NumericUpDown dataCollectionMinutesNum; private System.Windows.Forms.NumericUpDown dataCollectionMinutesNum;
private System.Windows.Forms.BindingSource bindingConfiguration; private System.Windows.Forms.BindingSource bindingConfiguration;
private System.Windows.Forms.Button CancelButton;
private new System.Windows.Forms.Button CancelButton;
private System.Windows.Forms.Button OKButton; private System.Windows.Forms.Button OKButton;
} }
} }

+ 6
- 2
shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs View File

@@ -9,7 +9,7 @@ namespace Shadowsocks.View
{ {
public partial class StatisticsStrategyConfigurationForm: Form public partial class StatisticsStrategyConfigurationForm: Form
{ {
private ShadowsocksController _controller;
private readonly ShadowsocksController _controller;
private StatisticsStrategyConfiguration _configuration; private StatisticsStrategyConfiguration _configuration;


public StatisticsStrategyConfigurationForm(ShadowsocksController controller) public StatisticsStrategyConfigurationForm(ShadowsocksController controller)
@@ -24,8 +24,12 @@ namespace Shadowsocks.View


private void LoadConfiguration() private void LoadConfiguration()
{ {
_configuration = _controller.GetConfigurationCopy()?.statisticsStrategyConfiguration
_configuration = _controller.StatisticsConfiguration
?? new StatisticsStrategyConfiguration(); ?? new StatisticsStrategyConfiguration();
if (_configuration.Calculations == null)
{
_configuration = new StatisticsStrategyConfiguration();
}
} }


private void InitData() private void InitData()


+ 0
- 3
shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.resx View File

@@ -120,7 +120,4 @@
<metadata name="bindingConfiguration.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="bindingConfiguration.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>1, 30</value> <value>1, 30</value>
</metadata> </metadata>
<metadata name="bindingConfiguration.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>1, 30</value>
</metadata>
</root> </root>

+ 2
- 1
shadowsocks-csharp/packages.config View File

@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Costura.Fody" version="1.3.3.0" targetFramework="net4-client" developmentDependency="true" /> <package id="Costura.Fody" version="1.3.3.0" targetFramework="net4-client" developmentDependency="true" />
<package id="Fody" version="1.28.3" targetFramework="net4-client" developmentDependency="true" />
<package id="Fody" version="1.29.3" targetFramework="net4-client" developmentDependency="true" />
<package id="Microsoft.Bcl" version="1.1.8" targetFramework="net4-client" /> <package id="Microsoft.Bcl" version="1.1.8" targetFramework="net4-client" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net4-client" /> <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net4-client" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net4-client" /> <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net4-client" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net4-client" />
</packages> </packages>

+ 9
- 3
shadowsocks-csharp/shadowsocks-csharp.csproj View File

@@ -81,6 +81,10 @@
<EmbedInteropTypes>False</EmbedInteropTypes> <EmbedInteropTypes>False</EmbedInteropTypes>
</Reference> </Reference>
<Reference Include="Microsoft.VisualBasic" /> <Reference Include="Microsoft.VisualBasic" />
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>3rd\Newtonsoft.Json.7.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
@@ -280,7 +284,9 @@
<Content Include="Data\cn.txt" /> <Content Include="Data\cn.txt" />
<Content Include="Data\privoxy_conf.txt" /> <Content Include="Data\privoxy_conf.txt" />
<Content Include="Data\user-rule.txt" /> <Content Include="Data\user-rule.txt" />
<Content Include="FodyWeavers.xml" />
<Content Include="FodyWeavers.xml">
<SubType>Designer</SubType>
</Content>
<Content Include="shadowsocks.ico" /> <Content Include="shadowsocks.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -321,12 +327,12 @@
<Error Condition="!Exists('3rd\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" /> <Error Condition="!Exists('3rd\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('3rd\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" /> <Error Condition="Exists('3rd\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target> </Target>
<Import Project="3rd\Fody.1.28.3\build\Fody.targets" Condition="Exists('3rd\Fody.1.28.3\build\Fody.targets')" />
<Import Project="3rd\Fody.1.29.3\build\portable-net+sl+win+wpa+wp\Fody.targets" Condition="Exists('3rd\Fody.1.29.3\build\portable-net+sl+win+wpa+wp\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('3rd\Fody.1.28.3\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '3rd\Fody.1.28.3\build\Fody.targets'))" />
<Error Condition="!Exists('3rd\Fody.1.29.3\build\portable-net+sl+win+wpa+wp\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '3rd\Fody.1.29.3\build\portable-net+sl+win+wpa+wp\Fody.targets'))" />
</Target> </Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.


Loading…
Cancel
Save