Browse Source

Basic user controls

tags/3.0
icylogic 9 years ago
parent
commit
bf1c79304e
16 changed files with 684 additions and 281 deletions
  1. +6
    -0
      shadowsocks-csharp/Controller/ShadowsocksController.cs
  2. +12
    -13
      shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs
  3. +1
    -1
      shadowsocks-csharp/Controller/Strategy/StrategyManager.cs
  4. +3
    -0
      shadowsocks-csharp/Model/Configuration.cs
  5. +66
    -0
      shadowsocks-csharp/Model/StatisticsStrategyConfiguration.cs
  6. +10
    -0
      shadowsocks-csharp/Properties/DataSources/Shadowsocks.Model.StatisticsStrategyConfiguration.datasource
  7. +108
    -0
      shadowsocks-csharp/View/CalculationControl.Designer.cs
  8. +23
    -0
      shadowsocks-csharp/View/CalculationControl.cs
  9. +0
    -0
      shadowsocks-csharp/View/CalculationControl.resx
  10. +7
    -4
      shadowsocks-csharp/View/LogForm.Designer.cs
  11. +2
    -10
      shadowsocks-csharp/View/MenuViewController.cs
  12. +247
    -191
      shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.Designer.cs
  13. +56
    -0
      shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs
  14. +126
    -0
      shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.resx
  15. +0
    -56
      shadowsocks-csharp/View/StatisticsStrategyOptionsForm.cs
  16. +17
    -6
      shadowsocks-csharp/shadowsocks-csharp.csproj

+ 6
- 0
shadowsocks-csharp/Controller/ShadowsocksController.cs View File

@@ -124,6 +124,12 @@ namespace Shadowsocks.Controller
SaveConfig(_config);
}
public void SaveStrategyConfigurations(StatisticsStrategyConfiguration configuration)
{
_config.statisticsStrategyConfiguration = configuration;
SaveConfig(_config);
}
public bool AddServerBySSURL(string ssURL)
{
try


shadowsocks-csharp/Controller/Strategy/SimplyChooseByStatisticsStrategy.cs → shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs View File

@@ -9,7 +9,7 @@ using Shadowsocks.Model;

namespace Shadowsocks.Controller.Strategy
{
class SimplyChooseByStatisticsStrategy : IStrategy
class StatisticsStrategy : IStrategy
{
private readonly ShadowsocksController _controller;
private Server _currentServer;
@@ -18,7 +18,16 @@ namespace Shadowsocks.Controller.Strategy
private const int CachedInterval = 30*60*1000; //choose a new server every 30 minutes
private const int RetryInterval = 2*60*1000; //choose a new server every 30 minutes

public SimplyChooseByStatisticsStrategy(ShadowsocksController controller)
public class StatisticsData
{
public int SuccessTimes;
public int TimedOutTimes;
public int AverageResponse;
public int MinResponse;
public int MaxResponse;
}

public StatisticsStrategy(ShadowsocksController controller)
{
_controller = controller;
var servers = controller.GetCurrentConfiguration().configs;
@@ -90,15 +99,6 @@ namespace Shadowsocks.Controller.Strategy
return (double)data.SuccessTimes / (data.SuccessTimes + data.TimedOutTimes); //simply choose min package loss
}

private class StatisticsData
{
public int SuccessTimes;
public int TimedOutTimes;
public int AverageResponse;
public int MinResponse;
public int MaxResponse;
}

private void ChooseNewServer(List<Server> servers)
{
if (_statistics == null || servers.Count == 0)
@@ -137,7 +137,7 @@ namespace Shadowsocks.Controller.Strategy
}
}

public string ID => "com.shadowsocks.strategy.scbs";
public string ID => "com.shadowsocks.strategy.statistics";

public string Name => I18N.GetString("Choose By Total Package Loss");

@@ -176,6 +176,5 @@ namespace Shadowsocks.Controller.Strategy
{
//TODO: combine this part of data with ICMP statics
}

}
}

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

@@ -13,7 +13,7 @@ namespace Shadowsocks.Controller.Strategy
_strategies = new List<IStrategy>();
_strategies.Add(new BalancingStrategy(controller));
_strategies.Add(new HighAvailabilityStrategy(controller));
_strategies.Add(new SimplyChooseByStatisticsStrategy(controller));
_strategies.Add(new StatisticsStrategy(controller));
// TODO: load DLL plugins
}
public IList<IStrategy> GetStrategies()


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

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using SimpleJson;
namespace Shadowsocks.Model
{
@@ -24,6 +25,8 @@ namespace Shadowsocks.Model
public bool useOnlinePac;
public bool availabilityStatistics;
public StatisticsStrategyConfiguration statisticsStrategyConfiguration;
private static string CONFIG_FILE = "gui-config.json";
public Server GetCurrentServer()


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

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Shadowsocks.Controller.Strategy;

namespace Shadowsocks.Model
{
[Serializable]
public class StatisticsStrategyConfiguration
{
public static readonly string ID = "com.shadowsocks.strategy.statistics";
private bool _statisticsEnabled;
private bool _byIsp;
private bool _byHourOfDay;
private int _choiceKeptMinutes;
private int _dataCollectionMinutes;
private int _repeatTimesNum;

public Dictionary<string, float> Calculations;

public StatisticsStrategyConfiguration()
{
var statisticsStrategy = typeof (StatisticsStrategy);
var statisticsData = statisticsStrategy.GetNestedType("StatisticsData");
var properties = statisticsData.GetFields(BindingFlags.Instance | BindingFlags.Public);
Calculations = properties.ToDictionary(p => p.Name, _ => (float) 0);
}

public bool StatisticsEnabled
{
get { return _statisticsEnabled; }
set { _statisticsEnabled = value; }
}

public bool ByIsp
{
get { return _byIsp; }
set { _byIsp = value; }
}

public bool ByHourOfDay
{
get { return _byHourOfDay; }
set { _byHourOfDay = value; }
}

public int ChoiceKeptMinutes
{
get { return _choiceKeptMinutes; }
set { _choiceKeptMinutes = value; }
}

public int DataCollectionMinutes
{
get { return _dataCollectionMinutes; }
set { _dataCollectionMinutes = value; }
}

public int RepeatTimesNum
{
get { return _repeatTimesNum; }
set { _repeatTimesNum = value; }
}
}
}

+ 10
- 0
shadowsocks-csharp/Properties/DataSources/Shadowsocks.Model.StatisticsStrategyConfiguration.datasource View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="StatisticsStrategyConfiguration" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>Shadowsocks.Model.StatisticsStrategyConfiguration, Shadowsocks, Version=2.5.2.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

+ 108
- 0
shadowsocks-csharp/View/CalculationControl.Designer.cs View File

@@ -0,0 +1,108 @@
namespace Shadowsocks.View
{
partial class CalculationControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Component Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.factorNum = new System.Windows.Forms.NumericUpDown();
this.multiply = new System.Windows.Forms.Label();
this.plus = new System.Windows.Forms.Label();
this.valueLabel = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.factorNum)).BeginInit();
this.SuspendLayout();
//
// factorNum
//
this.factorNum.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.factorNum.Increment = new decimal(new int[] {
1,
0,
0,
131072});
this.factorNum.Location = new System.Drawing.Point(320, 7);
this.factorNum.Minimum = new decimal(new int[] {
1000,
0,
0,
-2147418112});
this.factorNum.Name = "factorNum";
this.factorNum.Size = new System.Drawing.Size(86, 34);
this.factorNum.TabIndex = 6;
//
// multiply
//
this.multiply.AutoSize = true;
this.multiply.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.multiply.Location = new System.Drawing.Point(286, 9);
this.multiply.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.multiply.Name = "multiply";
this.multiply.Size = new System.Drawing.Size(26, 28);
this.multiply.TabIndex = 2;
this.multiply.Text = "×";
//
// plus
//
this.plus.AutoSize = true;
this.plus.Font = new System.Drawing.Font("Segoe UI", 10F);
this.plus.Location = new System.Drawing.Point(5, 9);
this.plus.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.plus.Name = "plus";
this.plus.Size = new System.Drawing.Size(26, 28);
this.plus.TabIndex = 3;
this.plus.Text = "+";
//
// valueLabel
//
this.valueLabel.AutoSize = true;
this.valueLabel.Location = new System.Drawing.Point(39, 17);
this.valueLabel.Name = "valueLabel";
this.valueLabel.Size = new System.Drawing.Size(0, 18);
this.valueLabel.TabIndex = 7;
//
// CalculationControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.valueLabel);
this.Controls.Add(this.factorNum);
this.Controls.Add(this.multiply);
this.Controls.Add(this.plus);
this.Name = "CalculationControl";
this.Size = new System.Drawing.Size(425, 46);
((System.ComponentModel.ISupportInitialize)(this.factorNum)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion
private System.Windows.Forms.NumericUpDown factorNum;
private System.Windows.Forms.Label multiply;
private System.Windows.Forms.Label plus;
private System.Windows.Forms.Label valueLabel;
}
}

+ 23
- 0
shadowsocks-csharp/View/CalculationControl.cs View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Shadowsocks.View
{
public partial class CalculationControl : UserControl
{
public CalculationControl(string value)
{
InitializeComponent();
valueLabel.Text = value;
}

public string Value => valueLabel.Text;
public float Factor => float.Parse(factorNum.Text);
}
}

shadowsocks-csharp/View/StatisticsStrategyOptionsForm.resx → shadowsocks-csharp/View/CalculationControl.resx View File


+ 7
- 4
shadowsocks-csharp/View/LogForm.Designer.cs View File

@@ -44,19 +44,21 @@
this.textBox1.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox1.ForeColor = System.Drawing.Color.White;
this.textBox1.Location = new System.Drawing.Point(0, 0);
this.textBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.textBox1.MaxLength = 2147483647;
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.textBox1.Size = new System.Drawing.Size(547, 382);
this.textBox1.Size = new System.Drawing.Size(820, 529);
this.textBox1.TabIndex = 0;
this.textBox1.WordWrap = false;
//
// contextMenuStrip1
//
this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
this.contextMenuStrip1.Size = new System.Drawing.Size(74, 4);
//
// mainMenu1
//
@@ -85,10 +87,11 @@
//
// LogForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(547, 382);
this.ClientSize = new System.Drawing.Size(820, 529);
this.Controls.Add(this.textBox1);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Menu = this.mainMenu1;
this.Name = "LogForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;


+ 2
- 10
shadowsocks-csharp/View/MenuViewController.cs View File

@@ -29,7 +29,6 @@ namespace Shadowsocks.View
private MenuItem enableItem;
private MenuItem modeItem;
private MenuItem AutoStartupItem;
private MenuItem AvailabilityStatistics;
private MenuItem ShareOverLANItem;
private MenuItem SeperatorItem;
private MenuItem ConfigItem;
@@ -179,7 +178,6 @@ namespace Shadowsocks.View
}),
new MenuItem("-"),
this.AutoStartupItem = CreateMenuItem("Start on Boot", new EventHandler(this.AutoStartupItem_Click)),
this.AvailabilityStatistics = CreateMenuItem("Availability Statistics", new EventHandler(this.AvailabilityStatisticsItem_Click)),
this.ShareOverLANItem = CreateMenuItem("Allow Clients from LAN", new EventHandler(this.ShareOverLANItem_Click)),
new MenuItem("-"),
CreateMenuItem("Show Logs...", new EventHandler(this.ShowLogItem_Click)),
@@ -263,7 +261,6 @@ namespace Shadowsocks.View
PACModeItem.Checked = !config.global;
ShareOverLANItem.Checked = config.shareOverLan;
AutoStartupItem.Checked = AutoStartup.Check();
AvailabilityStatistics.Checked = config.availabilityStatistics;
onlinePACItem.Checked = onlinePACItem.Enabled && config.useOnlinePac;
localPACItem.Checked = !onlinePACItem.Checked;
UpdatePACItemsEnabledStatus();
@@ -427,10 +424,10 @@ namespace Shadowsocks.View
qrCodeForm.Show();
}
private static void StatisticsStrategyOptionsItem_Click(object sender, EventArgs e)
private void StatisticsStrategyOptionsItem_Click(object sender, EventArgs e)
{
//TODO: Load options
var statisticsStrategyOptionsForm = new StatisticsStrategyOptionsForm();
var statisticsStrategyOptionsForm = new StatisticsStrategyConfigurationForm(controller);
statisticsStrategyOptionsForm.Show();
//TODO: Save options
}
@@ -536,11 +533,6 @@ namespace Shadowsocks.View
}
}
private void AvailabilityStatisticsItem_Click(object sender, EventArgs e) {
AvailabilityStatistics.Checked = !AvailabilityStatistics.Checked;
controller.ToggleAvailabilityStatistics(AvailabilityStatistics.Checked);
}
private void LocalPACItem_Click(object sender, EventArgs e)
{
if (!localPACItem.Checked)


shadowsocks-csharp/View/StatisticsStrategyOptionsForm.Designer.cs → shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.Designer.cs View File

@@ -1,6 +1,6 @@
namespace Shadowsocks.View
{
partial class StatisticsStrategyOptionsForm
partial class StatisticsStrategyConfigurationForm
{
/// <summary>
/// Required designer variable.
@@ -28,13 +28,15 @@
/// </summary>
private void InitializeComponent()
{
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.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();
this.StatisticsChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.checkBox1 = 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.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
@@ -43,19 +45,21 @@
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.label9 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.dataCollectionMinutesNum = new System.Windows.Forms.NumericUpDown();
this.StatisticsEnabledCheckBox = new System.Windows.Forms.CheckBox();
this.choiceKeptMinutesNum = new System.Windows.Forms.NumericUpDown();
this.byHourOfDayCheckBox = new System.Windows.Forms.CheckBox();
this.repeatTimesNum = new System.Windows.Forms.NumericUpDown();
this.label6 = new System.Windows.Forms.Label();
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.label1 = new System.Windows.Forms.Label();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.panel3 = new System.Windows.Forms.Panel();
this.label5 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.textBox5 = new System.Windows.Forms.TextBox();
this.comboBox3 = new System.Windows.Forms.ComboBox();
this.calculationContainer = new System.Windows.Forms.FlowLayoutPanel();
this.OKButton = new System.Windows.Forms.Button();
this.CancelButton = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.StatisticsChart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingConfiguration)).BeginInit();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
@@ -65,93 +69,95 @@
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataCollectionMinutesNum)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.choiceKeptMinutesNum)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.repeatTimesNum)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit();
this.splitContainer3.Panel1.SuspendLayout();
this.splitContainer3.Panel2.SuspendLayout();
this.splitContainer3.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.panel3.SuspendLayout();
this.SuspendLayout();
//
// StatisticsChart
//
this.StatisticsChart.BackColor = System.Drawing.Color.Transparent;
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);
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);
this.StatisticsChart.Dock = System.Windows.Forms.DockStyle.Fill;
legend1.BackColor = System.Drawing.Color.Transparent;
legend1.Name = "ChartLegend";
this.StatisticsChart.Legends.Add(legend1);
legend2.BackColor = System.Drawing.Color.Transparent;
legend2.Name = "ChartLegend";
this.StatisticsChart.Legends.Add(legend2);
this.StatisticsChart.Location = new System.Drawing.Point(0, 0);
this.StatisticsChart.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.StatisticsChart.Name = "StatisticsChart";
this.StatisticsChart.Palette = System.Windows.Forms.DataVisualization.Charting.ChartColorPalette.Pastel;
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(1029, 239);
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);
this.StatisticsChart.TabIndex = 2;
this.StatisticsChart.Click += new System.EventHandler(this.StatisticsChart_Click);
//
// checkBox1
// byISPCheckBox
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(16, 21);
this.checkBox1.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(204, 32);
this.checkBox1.TabIndex = 5;
this.checkBox1.Text = "By ISP/geolocation";
this.checkBox1.UseVisualStyleBackColor = true;
this.byISPCheckBox.AutoSize = true;
this.byISPCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", this.bindingConfiguration, "ByIsp", true));
this.byISPCheckBox.Location = new System.Drawing.Point(12, 56);
this.byISPCheckBox.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.byISPCheckBox.Name = "byISPCheckBox";
this.byISPCheckBox.Size = new System.Drawing.Size(204, 32);
this.byISPCheckBox.TabIndex = 5;
this.byISPCheckBox.Text = "By ISP/geolocation";
this.byISPCheckBox.UseVisualStyleBackColor = true;
//
// bindingConfiguration
//
this.bindingConfiguration.DataSource = typeof(Shadowsocks.Model.StatisticsStrategyConfiguration);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(11, 107);
this.label2.Location = new System.Drawing.Point(7, 141);
this.label2.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(160, 28);
this.label2.Size = new System.Drawing.Size(152, 28);
this.label2.TabIndex = 8;
this.label2.Text = "Cache choice for ";
this.label2.Text = "Keep choice for ";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(176, 148);
this.label3.Location = new System.Drawing.Point(261, 141);
this.label3.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(81, 28);
this.label3.TabIndex = 9;
this.label3.Text = "minutes";
this.label3.Click += new System.EventHandler(this.label3_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(16, 192);
this.label4.Location = new System.Drawing.Point(12, 226);
this.label4.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(51, 28);
@@ -163,7 +169,7 @@
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.radioButton1);
this.groupBox1.Location = new System.Drawing.Point(775, 107);
this.groupBox1.Location = new System.Drawing.Point(698, 12);
this.groupBox1.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(5, 10, 5, 10);
@@ -207,14 +213,15 @@
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.splitContainer2);
this.splitContainer1.Panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.splitContainer1_Panel1_Paint);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.CancelButton);
this.splitContainer1.Panel2.Controls.Add(this.OKButton);
this.splitContainer1.Panel2.Controls.Add(this.groupBox1);
this.splitContainer1.Panel2.Controls.Add(this.StatisticsChart);
this.splitContainer1.Size = new System.Drawing.Size(1029, 496);
this.splitContainer1.SplitterDistance = 247;
this.splitContainer1.Size = new System.Drawing.Size(951, 458);
this.splitContainer1.SplitterDistance = 227;
this.splitContainer1.SplitterWidth = 10;
this.splitContainer1.TabIndex = 12;
//
@@ -229,60 +236,143 @@
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.numericUpDown2);
this.splitContainer2.Panel1.Controls.Add(this.checkBox2);
this.splitContainer2.Panel1.Controls.Add(this.numericUpDown1);
this.splitContainer2.Panel1.Controls.Add(this.label9);
this.splitContainer2.Panel1.Controls.Add(this.label8);
this.splitContainer2.Panel1.Controls.Add(this.dataCollectionMinutesNum);
this.splitContainer2.Panel1.Controls.Add(this.StatisticsEnabledCheckBox);
this.splitContainer2.Panel1.Controls.Add(this.choiceKeptMinutesNum);
this.splitContainer2.Panel1.Controls.Add(this.byHourOfDayCheckBox);
this.splitContainer2.Panel1.Controls.Add(this.repeatTimesNum);
this.splitContainer2.Panel1.Controls.Add(this.label6);
this.splitContainer2.Panel1.Controls.Add(this.label2);
this.splitContainer2.Panel1.Controls.Add(this.label4);
this.splitContainer2.Panel1.Controls.Add(this.checkBox1);
this.splitContainer2.Panel1.Controls.Add(this.byISPCheckBox);
this.splitContainer2.Panel1.Controls.Add(this.label3);
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.splitContainer3);
this.splitContainer2.Size = new System.Drawing.Size(1029, 247);
this.splitContainer2.Size = new System.Drawing.Size(951, 227);
this.splitContainer2.SplitterDistance = 365;
this.splitContainer2.SplitterWidth = 5;
this.splitContainer2.TabIndex = 7;
//
// numericUpDown2
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(7, 181);
this.label9.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(152, 28);
this.label9.TabIndex = 20;
this.label9.Text = "Collect Data per";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(261, 183);
this.label8.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(81, 28);
this.label8.TabIndex = 19;
this.label8.Text = "minutes";
//
// dataCollectionMinutesNum
//
this.dataCollectionMinutesNum.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.bindingConfiguration, "DataCollectionMinutes", true));
this.dataCollectionMinutesNum.Increment = new decimal(new int[] {
10,
0,
0,
0});
this.dataCollectionMinutesNum.Location = new System.Drawing.Point(161, 188);
this.dataCollectionMinutesNum.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.dataCollectionMinutesNum.Maximum = new decimal(new int[] {
120,
0,
0,
0});
this.dataCollectionMinutesNum.Minimum = new decimal(new int[] {
5,
0,
0,
0});
this.dataCollectionMinutesNum.Name = "dataCollectionMinutesNum";
this.dataCollectionMinutesNum.Size = new System.Drawing.Size(92, 34);
this.dataCollectionMinutesNum.TabIndex = 18;
this.dataCollectionMinutesNum.Value = new decimal(new int[] {
5,
0,
0,
0});
//
// StatisticsEnabledCheckBox
//
this.StatisticsEnabledCheckBox.AutoSize = true;
this.StatisticsEnabledCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", this.bindingConfiguration, "StatisticsEnabled", true));
this.StatisticsEnabledCheckBox.Location = new System.Drawing.Point(12, 12);
this.StatisticsEnabledCheckBox.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.StatisticsEnabledCheckBox.Name = "StatisticsEnabledCheckBox";
this.StatisticsEnabledCheckBox.Size = new System.Drawing.Size(177, 32);
this.StatisticsEnabledCheckBox.TabIndex = 17;
this.StatisticsEnabledCheckBox.Text = "Enable Statistics";
this.StatisticsEnabledCheckBox.UseVisualStyleBackColor = true;
//
this.numericUpDown2.Location = new System.Drawing.Point(16, 145);
this.numericUpDown2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.numericUpDown2.Maximum = new decimal(new int[] {
60,
// choiceKeptMinutesNum
//
this.choiceKeptMinutesNum.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.bindingConfiguration, "ChoiceKeptMinutes", true));
this.choiceKeptMinutesNum.Increment = new decimal(new int[] {
10,
0,
0,
0});
this.choiceKeptMinutesNum.Location = new System.Drawing.Point(161, 139);
this.choiceKeptMinutesNum.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.choiceKeptMinutesNum.Maximum = new decimal(new int[] {
120,
0,
0,
0});
this.choiceKeptMinutesNum.Minimum = new decimal(new int[] {
5,
0,
0,
0});
this.choiceKeptMinutesNum.Name = "choiceKeptMinutesNum";
this.choiceKeptMinutesNum.Size = new System.Drawing.Size(92, 34);
this.choiceKeptMinutesNum.TabIndex = 16;
this.choiceKeptMinutesNum.Value = new decimal(new int[] {
5,
0,
0,
0});
this.numericUpDown2.Name = "numericUpDown2";
this.numericUpDown2.Size = new System.Drawing.Size(146, 34);
this.numericUpDown2.TabIndex = 16;
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(16, 64);
this.checkBox2.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(165, 32);
this.checkBox2.TabIndex = 15;
this.checkBox2.Text = "By hour of day";
this.checkBox2.UseVisualStyleBackColor = true;
//
// numericUpDown1
//
this.numericUpDown1.Location = new System.Drawing.Point(76, 189);
this.numericUpDown1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.numericUpDown1.Maximum = new decimal(new int[] {
//
// byHourOfDayCheckBox
//
this.byHourOfDayCheckBox.AutoSize = true;
this.byHourOfDayCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", this.bindingConfiguration, "ByHourOfDay", true));
this.byHourOfDayCheckBox.Location = new System.Drawing.Point(12, 98);
this.byHourOfDayCheckBox.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.byHourOfDayCheckBox.Name = "byHourOfDayCheckBox";
this.byHourOfDayCheckBox.Size = new System.Drawing.Size(165, 32);
this.byHourOfDayCheckBox.TabIndex = 15;
this.byHourOfDayCheckBox.Text = "By hour of day";
this.byHourOfDayCheckBox.UseVisualStyleBackColor = true;
//
// repeatTimesNum
//
this.repeatTimesNum.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.bindingConfiguration, "RepeatTimesNum", true));
this.repeatTimesNum.Location = new System.Drawing.Point(72, 223);
this.repeatTimesNum.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.repeatTimesNum.Maximum = new decimal(new int[] {
10,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(91, 34);
this.numericUpDown1.TabIndex = 14;
this.numericUpDown1.Value = new decimal(new int[] {
this.repeatTimesNum.Name = "repeatTimesNum";
this.repeatTimesNum.Size = new System.Drawing.Size(91, 34);
this.repeatTimesNum.TabIndex = 14;
this.repeatTimesNum.Value = new decimal(new int[] {
4,
0,
0,
@@ -291,7 +381,7 @@
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(175, 192);
this.label6.Location = new System.Drawing.Point(171, 226);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(184, 28);
this.label6.TabIndex = 13;
@@ -313,8 +403,8 @@
//
// splitContainer3.Panel2
//
this.splitContainer3.Panel2.Controls.Add(this.flowLayoutPanel1);
this.splitContainer3.Size = new System.Drawing.Size(659, 247);
this.splitContainer3.Panel2.Controls.Add(this.calculationContainer);
this.splitContainer3.Size = new System.Drawing.Size(581, 227);
this.splitContainer3.SplitterDistance = 46;
this.splitContainer3.SplitterWidth = 10;
this.splitContainer3.TabIndex = 6;
@@ -328,84 +418,51 @@
this.label1.Size = new System.Drawing.Size(242, 28);
this.label1.TabIndex = 0;
this.label1.Text = "Design evaluation method";
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoScroll = true;
this.flowLayoutPanel1.Controls.Add(this.panel3);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(659, 191);
this.flowLayoutPanel1.TabIndex = 1;
//
// panel3
//
this.panel3.AutoSize = true;
this.panel3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.panel3.Controls.Add(this.label5);
this.panel3.Controls.Add(this.label7);
this.panel3.Controls.Add(this.textBox5);
this.panel3.Controls.Add(this.comboBox3);
this.panel3.Location = new System.Drawing.Point(5, 10);
this.panel3.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(533, 56);
this.panel3.TabIndex = 4;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(5, 13);
this.label5.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(26, 28);
this.label5.TabIndex = 3;
this.label5.Text = "+";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(294, 13);
this.label7.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(26, 28);
this.label7.TabIndex = 2;
this.label7.Text = "×";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(329, 10);
this.textBox5.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(199, 34);
this.textBox5.TabIndex = 1;
//
// comboBox3
//
this.comboBox3.FormattingEnabled = true;
this.comboBox3.Location = new System.Drawing.Point(41, 10);
this.comboBox3.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(243, 36);
this.comboBox3.TabIndex = 0;
//
// StatisticsStrategyOptionsForm
//
// calculationContainer
//
this.calculationContainer.AutoScroll = true;
this.calculationContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.calculationContainer.Location = new System.Drawing.Point(0, 0);
this.calculationContainer.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.calculationContainer.Name = "calculationContainer";
this.calculationContainer.Size = new System.Drawing.Size(581, 171);
this.calculationContainer.TabIndex = 1;
//
// OKButton
//
this.OKButton.Location = new System.Drawing.Point(745, 166);
this.OKButton.Name = "OKButton";
this.OKButton.Size = new System.Drawing.Size(93, 43);
this.OKButton.TabIndex = 4;
this.OKButton.Text = "OK";
this.OKButton.UseVisualStyleBackColor = true;
this.OKButton.Click += new System.EventHandler(this.OKButton_Click);
//
// CancelButton
//
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);
//
// StatisticsStrategyConfigurationForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 28F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.ClientSize = new System.Drawing.Size(1029, 496);
this.ClientSize = new System.Drawing.Size(951, 458);
this.Controls.Add(this.splitContainer1);
this.Font = new System.Drawing.Font("Segoe UI", 10F);
this.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
this.MinimumSize = new System.Drawing.Size(973, 514);
this.Name = "StatisticsStrategyOptionsForm";
this.Name = "StatisticsStrategyConfigurationForm";
this.Text = "StatisticsStrategyConfigurationForm";
this.Load += new System.EventHandler(this.StatisticsStrategyOptionsForm_Load);
((System.ComponentModel.ISupportInitialize)(this.StatisticsChart)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingConfiguration)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.splitContainer1.Panel1.ResumeLayout(false);
@@ -417,24 +474,21 @@
this.splitContainer2.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataCollectionMinutesNum)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.choiceKeptMinutesNum)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.repeatTimesNum)).EndInit();
this.splitContainer3.Panel1.ResumeLayout(false);
this.splitContainer3.Panel1.PerformLayout();
this.splitContainer3.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();
this.splitContainer3.ResumeLayout(false);
this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.ResumeLayout(false);

}

#endregion
private System.Windows.Forms.DataVisualization.Charting.Chart StatisticsChart;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox byISPCheckBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
@@ -444,16 +498,18 @@
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.FlowLayoutPanel calculationContainer;
private System.Windows.Forms.SplitContainer splitContainer3;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.ComboBox comboBox3;
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.NumericUpDown repeatTimesNum;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.NumericUpDown numericUpDown2;
private System.Windows.Forms.CheckBox byHourOfDayCheckBox;
private System.Windows.Forms.NumericUpDown choiceKeptMinutesNum;
private System.Windows.Forms.CheckBox StatisticsEnabledCheckBox;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.NumericUpDown dataCollectionMinutesNum;
private System.Windows.Forms.BindingSource bindingConfiguration;
private System.Windows.Forms.Button CancelButton;
private System.Windows.Forms.Button OKButton;
}
}

+ 56
- 0
shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Shadowsocks.Controller;
using Shadowsocks.Model;
using SimpleJson;

namespace Shadowsocks.View
{
public partial class StatisticsStrategyConfigurationForm: Form
{
private ShadowsocksController _controller;
private StatisticsStrategyConfiguration _configuration;

public StatisticsStrategyConfigurationForm(ShadowsocksController controller)
{
if (controller == null) return;
InitializeComponent();
_controller = controller;
_controller.ConfigChanged += (sender, args) => LoadConfiguration();
LoadConfiguration();
Load += (sender, args) => InitData();
}

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

private void InitData()
{
bindingConfiguration.Add(_configuration);
foreach (var kv in _configuration.Calculations)
{
var calculation = new CalculationControl(kv.Key);
calculationContainer.Controls.Add(calculation);
}
}

private void CancelButton_Click(object sender, EventArgs e)
{
Close();
}

private void OKButton_Click(object sender, EventArgs e)
{
foreach (CalculationControl calculation in calculationContainer.Controls)
{
_configuration.Calculations[calculation.Value] = calculation.Factor;
}
_controller?.SaveStrategyConfigurations(_configuration);
Close();
}
}
}

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

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="bindingConfiguration.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>1, 30</value>
</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>

+ 0
- 56
shadowsocks-csharp/View/StatisticsStrategyOptionsForm.cs View File

@@ -1,56 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Shadowsocks.View
{
public partial class StatisticsStrategyOptionsForm: Form
{
private static readonly int emSize = 8;
public StatisticsStrategyOptionsForm()
{
InitializeComponent();
}


private void chart1_Click(object sender, EventArgs e)
{

}

private void StatisticsChart_Click(object sender, EventArgs e)
{

}

private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
{

}

private void label1_Click(object sender, EventArgs e)
{

}

private void label5_Click(object sender, EventArgs e)
{

}

private void StatisticsStrategyOptionsForm_Load(object sender, EventArgs e)
{

}

private void label3_Click(object sender, EventArgs e)
{

}
}
}

+ 17
- 6
shadowsocks-csharp/shadowsocks-csharp.csproj View File

@@ -167,7 +167,7 @@
<Compile Include="3rd\zxing\WriterException.cs" />
<Compile Include="Controller\Service\AvailabilityStatistics.cs" />
<Compile Include="Controller\Strategy\HighAvailabilityStrategy.cs" />
<Compile Include="Controller\Strategy\SimplyChooseByStatisticsStrategy.cs" />
<Compile Include="Controller\Strategy\StatisticsStrategy.cs" />
<Compile Include="Controller\System\AutoStartup.cs" />
<Compile Include="Controller\FileManager.cs" />
<Compile Include="Controller\Service\GFWListUpdater.cs" />
@@ -189,6 +189,7 @@
<Compile Include="Controller\Service\PACServer.cs" />
<Compile Include="Model\Server.cs" />
<Compile Include="Model\Configuration.cs" />
<Compile Include="Model\StatisticsStrategyConfiguration.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@@ -210,6 +211,12 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Controller\ShadowsocksController.cs" />
<Compile Include="Controller\System\SystemProxy.cs" />
<Compile Include="View\CalculationControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="View\CalculationControl.Designer.cs">
<DependentUpon>CalculationControl.cs</DependentUpon>
</Compile>
<Compile Include="View\LogForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -226,11 +233,11 @@
<Compile Include="View\QRCodeSplashForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="View\StatisticsStrategyOptionsForm.cs">
<Compile Include="View\StatisticsStrategyConfigurationForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="View\StatisticsStrategyOptionsForm.Designer.cs">
<DependentUpon>StatisticsStrategyOptionsForm.cs</DependentUpon>
<Compile Include="View\StatisticsStrategyConfigurationForm.Designer.cs">
<DependentUpon>StatisticsStrategyConfigurationForm.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="View\ConfigForm.resx">
<DependentUpon>ConfigForm.cs</DependentUpon>
@@ -241,14 +248,17 @@
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="View\CalculationControl.resx">
<DependentUpon>CalculationControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="View\LogForm.resx">
<DependentUpon>LogForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="View\QRCodeForm.resx">
<DependentUpon>QRCodeForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="View\StatisticsStrategyOptionsForm.resx">
<DependentUpon>StatisticsStrategyOptionsForm.cs</DependentUpon>
<EmbeddedResource Include="View\StatisticsStrategyConfigurationForm.resx">
<DependentUpon>StatisticsStrategyConfigurationForm.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.config" />
<None Include="app.manifest">
@@ -261,6 +271,7 @@
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Properties\DataSources\Shadowsocks.Model.StatisticsStrategyConfiguration.datasource" />
<None Include="Resources\ss20.png" />
<None Include="Resources\ss16.png" />
<None Include="Resources\ss24.png" />


Loading…
Cancel
Save