From bf1c79304ec83b01cb3413b7344b517cd89354d7 Mon Sep 17 00:00:00 2001 From: icylogic Date: Sun, 16 Aug 2015 20:07:51 +0800 Subject: [PATCH] Basic user controls --- .../Controller/ShadowsocksController.cs | 6 + ...sticsStrategy.cs => StatisticsStrategy.cs} | 25 +- .../Controller/Strategy/StrategyManager.cs | 2 +- shadowsocks-csharp/Model/Configuration.cs | 3 + .../Model/StatisticsStrategyConfiguration.cs | 66 +++ ...StatisticsStrategyConfiguration.datasource | 10 + .../View/CalculationControl.Designer.cs | 108 +++++ shadowsocks-csharp/View/CalculationControl.cs | 23 + ...tionsForm.resx => CalculationControl.resx} | 0 shadowsocks-csharp/View/LogForm.Designer.cs | 11 +- shadowsocks-csharp/View/MenuViewController.cs | 12 +- ...ticsStrategyConfigurationForm.Designer.cs} | 438 ++++++++++-------- .../StatisticsStrategyConfigurationForm.cs | 56 +++ .../StatisticsStrategyConfigurationForm.resx | 126 +++++ .../View/StatisticsStrategyOptionsForm.cs | 56 --- shadowsocks-csharp/shadowsocks-csharp.csproj | 23 +- 16 files changed, 684 insertions(+), 281 deletions(-) rename shadowsocks-csharp/Controller/Strategy/{SimplyChooseByStatisticsStrategy.cs => StatisticsStrategy.cs} (96%) create mode 100644 shadowsocks-csharp/Model/StatisticsStrategyConfiguration.cs create mode 100644 shadowsocks-csharp/Properties/DataSources/Shadowsocks.Model.StatisticsStrategyConfiguration.datasource create mode 100644 shadowsocks-csharp/View/CalculationControl.Designer.cs create mode 100644 shadowsocks-csharp/View/CalculationControl.cs rename shadowsocks-csharp/View/{StatisticsStrategyOptionsForm.resx => CalculationControl.resx} (100%) rename shadowsocks-csharp/View/{StatisticsStrategyOptionsForm.Designer.cs => StatisticsStrategyConfigurationForm.Designer.cs} (50%) create mode 100644 shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs create mode 100644 shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.resx delete mode 100644 shadowsocks-csharp/View/StatisticsStrategyOptionsForm.cs diff --git a/shadowsocks-csharp/Controller/ShadowsocksController.cs b/shadowsocks-csharp/Controller/ShadowsocksController.cs index 4ecb3759..087dc851 100755 --- a/shadowsocks-csharp/Controller/ShadowsocksController.cs +++ b/shadowsocks-csharp/Controller/ShadowsocksController.cs @@ -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 diff --git a/shadowsocks-csharp/Controller/Strategy/SimplyChooseByStatisticsStrategy.cs b/shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs similarity index 96% rename from shadowsocks-csharp/Controller/Strategy/SimplyChooseByStatisticsStrategy.cs rename to shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs index 9da0aac5..e0c0fc98 100644 --- a/shadowsocks-csharp/Controller/Strategy/SimplyChooseByStatisticsStrategy.cs +++ b/shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs @@ -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 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 } - } } diff --git a/shadowsocks-csharp/Controller/Strategy/StrategyManager.cs b/shadowsocks-csharp/Controller/Strategy/StrategyManager.cs index dd1f705c..81a00e4d 100644 --- a/shadowsocks-csharp/Controller/Strategy/StrategyManager.cs +++ b/shadowsocks-csharp/Controller/Strategy/StrategyManager.cs @@ -13,7 +13,7 @@ namespace Shadowsocks.Controller.Strategy _strategies = new List(); _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 GetStrategies() diff --git a/shadowsocks-csharp/Model/Configuration.cs b/shadowsocks-csharp/Model/Configuration.cs index 1ccba56c..06e0d690 100755 --- a/shadowsocks-csharp/Model/Configuration.cs +++ b/shadowsocks-csharp/Model/Configuration.cs @@ -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() diff --git a/shadowsocks-csharp/Model/StatisticsStrategyConfiguration.cs b/shadowsocks-csharp/Model/StatisticsStrategyConfiguration.cs new file mode 100644 index 00000000..452ecc1d --- /dev/null +++ b/shadowsocks-csharp/Model/StatisticsStrategyConfiguration.cs @@ -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 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; } + } + } +} diff --git a/shadowsocks-csharp/Properties/DataSources/Shadowsocks.Model.StatisticsStrategyConfiguration.datasource b/shadowsocks-csharp/Properties/DataSources/Shadowsocks.Model.StatisticsStrategyConfiguration.datasource new file mode 100644 index 00000000..a1a52e80 --- /dev/null +++ b/shadowsocks-csharp/Properties/DataSources/Shadowsocks.Model.StatisticsStrategyConfiguration.datasource @@ -0,0 +1,10 @@ + + + + Shadowsocks.Model.StatisticsStrategyConfiguration, Shadowsocks, Version=2.5.2.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/shadowsocks-csharp/View/CalculationControl.Designer.cs b/shadowsocks-csharp/View/CalculationControl.Designer.cs new file mode 100644 index 00000000..62266759 --- /dev/null +++ b/shadowsocks-csharp/View/CalculationControl.Designer.cs @@ -0,0 +1,108 @@ +namespace Shadowsocks.View +{ + partial class CalculationControl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} diff --git a/shadowsocks-csharp/View/CalculationControl.cs b/shadowsocks-csharp/View/CalculationControl.cs new file mode 100644 index 00000000..89a2228d --- /dev/null +++ b/shadowsocks-csharp/View/CalculationControl.cs @@ -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); + } +} diff --git a/shadowsocks-csharp/View/StatisticsStrategyOptionsForm.resx b/shadowsocks-csharp/View/CalculationControl.resx similarity index 100% rename from shadowsocks-csharp/View/StatisticsStrategyOptionsForm.resx rename to shadowsocks-csharp/View/CalculationControl.resx diff --git a/shadowsocks-csharp/View/LogForm.Designer.cs b/shadowsocks-csharp/View/LogForm.Designer.cs index 7eb921ed..6320610d 100644 --- a/shadowsocks-csharp/View/LogForm.Designer.cs +++ b/shadowsocks-csharp/View/LogForm.Designer.cs @@ -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; diff --git a/shadowsocks-csharp/View/MenuViewController.cs b/shadowsocks-csharp/View/MenuViewController.cs index 8d68a0aa..02ae335a 100755 --- a/shadowsocks-csharp/View/MenuViewController.cs +++ b/shadowsocks-csharp/View/MenuViewController.cs @@ -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) diff --git a/shadowsocks-csharp/View/StatisticsStrategyOptionsForm.Designer.cs b/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.Designer.cs similarity index 50% rename from shadowsocks-csharp/View/StatisticsStrategyOptionsForm.Designer.cs rename to shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.Designer.cs index ca2dff75..8563fcc5 100644 --- a/shadowsocks-csharp/View/StatisticsStrategyOptionsForm.Designer.cs +++ b/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.Designer.cs @@ -1,6 +1,6 @@ namespace Shadowsocks.View { - partial class StatisticsStrategyOptionsForm + partial class StatisticsStrategyConfigurationForm { /// /// Required designer variable. @@ -28,13 +28,15 @@ /// 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; } } \ No newline at end of file diff --git a/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs b/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs new file mode 100644 index 00000000..970b5761 --- /dev/null +++ b/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs @@ -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(); + } + } +} diff --git a/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.resx b/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.resx new file mode 100644 index 00000000..55c9d750 --- /dev/null +++ b/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 1, 30 + + + 1, 30 + + \ No newline at end of file diff --git a/shadowsocks-csharp/View/StatisticsStrategyOptionsForm.cs b/shadowsocks-csharp/View/StatisticsStrategyOptionsForm.cs deleted file mode 100644 index ca91bf7c..00000000 --- a/shadowsocks-csharp/View/StatisticsStrategyOptionsForm.cs +++ /dev/null @@ -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) - { - - } - } -} diff --git a/shadowsocks-csharp/shadowsocks-csharp.csproj b/shadowsocks-csharp/shadowsocks-csharp.csproj index 128a903e..6fb5da2c 100644 --- a/shadowsocks-csharp/shadowsocks-csharp.csproj +++ b/shadowsocks-csharp/shadowsocks-csharp.csproj @@ -167,7 +167,7 @@ - + @@ -189,6 +189,7 @@ + True True @@ -210,6 +211,12 @@ + + UserControl + + + CalculationControl.cs + Form @@ -226,11 +233,11 @@ Form - + Form - - StatisticsStrategyOptionsForm.cs + + StatisticsStrategyConfigurationForm.cs ConfigForm.cs @@ -241,14 +248,17 @@ Designer Resources.Designer.cs + + CalculationControl.cs + LogForm.cs QRCodeForm.cs - - StatisticsStrategyOptionsForm.cs + + StatisticsStrategyConfigurationForm.cs @@ -261,6 +271,7 @@ +