finish basic calculation
This commit is contained in:
@@ -18,14 +18,12 @@ namespace Shadowsocks.Controller
|
||||
public sealed class AvailabilityStatistics : IDisposable
|
||||
{
|
||||
public const string DateTimePattern = "yyyy-MM-dd HH:mm:ss";
|
||||
public static readonly DateTime UnknownDateTime;
|
||||
private const string StatisticsFilesName = "shadowsocks.availability.json";
|
||||
public static string AvailabilityStatisticsFile;
|
||||
//static constructor to initialize every public static fields before refereced
|
||||
static AvailabilityStatistics()
|
||||
{
|
||||
AvailabilityStatisticsFile = Utils.GetTempPath(StatisticsFilesName);
|
||||
UnknownDateTime = new DateTime(1970, 1, 1);
|
||||
}
|
||||
|
||||
//arguments for ICMP tests
|
||||
@@ -230,7 +228,6 @@ namespace Shadowsocks.Controller
|
||||
{
|
||||
if (Config.ByHourOfDay)
|
||||
{
|
||||
if (record.Timestamp == UnknownDateTime) return false;
|
||||
if (!record.Timestamp.Hour.Equals(DateTime.Now.Hour)) return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -64,14 +64,14 @@ namespace Shadowsocks.Controller.Strategy
|
||||
averageRecord.setResponse(records.Select(record => record.AverageResponse));
|
||||
|
||||
if (!config.Calculations.TryGetValue("PackageLoss", out factor)) factor = 0;
|
||||
score += averageRecord.PackageLoss*factor ?? 0;
|
||||
score += averageRecord.PackageLoss * factor ?? 0;
|
||||
if (!config.Calculations.TryGetValue("AverageResponse", out factor)) factor = 0;
|
||||
score += averageRecord.AverageResponse*factor ?? 0;
|
||||
score += averageRecord.AverageResponse * factor ?? 0;
|
||||
if (!config.Calculations.TryGetValue("MinResponse", out factor)) factor = 0;
|
||||
score += averageRecord.MinResponse*factor ?? 0;
|
||||
score += averageRecord.MinResponse * factor ?? 0;
|
||||
if (!config.Calculations.TryGetValue("MaxResponse", out factor)) factor = 0;
|
||||
score += averageRecord.MaxResponse*factor ?? 0;
|
||||
Logging.Debug($"{JsonConvert.SerializeObject(averageRecord, Formatting.Indented)}");
|
||||
score += averageRecord.MaxResponse * factor ?? 0;
|
||||
Logging.Debug($"Highest score: {score} {JsonConvert.SerializeObject(averageRecord, Formatting.Indented)}");
|
||||
return score;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,10 @@ namespace Shadowsocks.Model
|
||||
// Simple processed records for a short period of time
|
||||
public class StatisticsRecord
|
||||
{
|
||||
public DateTime Timestamp;
|
||||
public DateTime Timestamp { get; set; } = DateTime.Now;
|
||||
public string ServerName { get; set; }
|
||||
|
||||
public string ServerName;
|
||||
|
||||
// these fields ping-only records would be null
|
||||
// in ping-only records, these fields would be null
|
||||
public int? AverageLatency;
|
||||
public int? MinLatency;
|
||||
public int? MaxLatency;
|
||||
@@ -37,7 +36,6 @@ namespace Shadowsocks.Model
|
||||
|
||||
public StatisticsRecord(string identifier, IEnumerable<int> inboundSpeedRecords, IEnumerable<int> outboundSpeedRecords, IEnumerable<int> latencyRecords)
|
||||
{
|
||||
Timestamp = DateTime.Now;
|
||||
ServerName = identifier;
|
||||
if (inboundSpeedRecords != null && inboundSpeedRecords.Any())
|
||||
{
|
||||
@@ -61,7 +59,6 @@ namespace Shadowsocks.Model
|
||||
|
||||
public StatisticsRecord(string identifier, IEnumerable<int?> responseRecords)
|
||||
{
|
||||
Timestamp = DateTime.Now;
|
||||
ServerName = identifier;
|
||||
setResponse(responseRecords);
|
||||
}
|
||||
|
||||
+8
-6
@@ -38,13 +38,14 @@
|
||||
// factorNum
|
||||
//
|
||||
this.factorNum.DecimalPlaces = 2;
|
||||
this.factorNum.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
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(285, 5);
|
||||
this.factorNum.Location = new System.Drawing.Point(236, 0);
|
||||
this.factorNum.Minimum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
@@ -58,7 +59,7 @@
|
||||
//
|
||||
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(251, 7);
|
||||
this.multiply.Location = new System.Drawing.Point(202, 2);
|
||||
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);
|
||||
@@ -69,7 +70,7 @@
|
||||
//
|
||||
this.plus.AutoSize = true;
|
||||
this.plus.Font = new System.Drawing.Font("Segoe UI", 10F);
|
||||
this.plus.Location = new System.Drawing.Point(5, 7);
|
||||
this.plus.Location = new System.Drawing.Point(5, 2);
|
||||
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);
|
||||
@@ -80,7 +81,7 @@
|
||||
//
|
||||
this.valueLabel.AutoSize = true;
|
||||
this.valueLabel.Font = new System.Drawing.Font("Microsoft YaHei", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.valueLabel.Location = new System.Drawing.Point(39, 11);
|
||||
this.valueLabel.Location = new System.Drawing.Point(39, 6);
|
||||
this.valueLabel.Name = "valueLabel";
|
||||
this.valueLabel.Size = new System.Drawing.Size(118, 24);
|
||||
this.valueLabel.TabIndex = 7;
|
||||
@@ -88,14 +89,15 @@
|
||||
//
|
||||
// CalculationControl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
|
||||
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.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.Name = "CalculationControl";
|
||||
this.Size = new System.Drawing.Size(380, 46);
|
||||
this.Size = new System.Drawing.Size(322, 34);
|
||||
((System.ComponentModel.ISupportInitialize)(this.factorNum)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
|
||||
System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
|
||||
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
this.StatisticsChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
|
||||
this.PingCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
@@ -57,6 +57,7 @@
|
||||
this.serverSelector = new System.Windows.Forms.ComboBox();
|
||||
this.CancelButton = new System.Windows.Forms.Button();
|
||||
this.OKButton = new System.Windows.Forms.Button();
|
||||
this.CalculatinTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.bindingConfiguration = new System.Windows.Forms.BindingSource(this.components);
|
||||
((System.ComponentModel.ISupportInitialize)(this.StatisticsChart)).BeginInit();
|
||||
this.chartModeSelector.SuspendLayout();
|
||||
@@ -81,48 +82,51 @@
|
||||
// StatisticsChart
|
||||
//
|
||||
this.StatisticsChart.BackColor = System.Drawing.Color.Transparent;
|
||||
chartArea2.AxisX.MajorGrid.Enabled = false;
|
||||
chartArea2.AxisY.MajorGrid.Enabled = false;
|
||||
chartArea2.AxisY2.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.False;
|
||||
chartArea2.AxisY2.MajorGrid.Enabled = false;
|
||||
chartArea2.BackColor = System.Drawing.Color.Transparent;
|
||||
chartArea2.Name = "DataArea";
|
||||
this.StatisticsChart.ChartAreas.Add(chartArea2);
|
||||
chartArea1.AxisX.MajorGrid.Enabled = false;
|
||||
chartArea1.AxisY.MajorGrid.Enabled = false;
|
||||
chartArea1.AxisY2.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.False;
|
||||
chartArea1.AxisY2.MajorGrid.Enabled = false;
|
||||
chartArea1.BackColor = System.Drawing.Color.Transparent;
|
||||
chartArea1.Name = "DataArea";
|
||||
this.StatisticsChart.ChartAreas.Add(chartArea1);
|
||||
this.StatisticsChart.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
legend2.BackColor = System.Drawing.Color.Transparent;
|
||||
legend2.Name = "ChartLegend";
|
||||
this.StatisticsChart.Legends.Add(legend2);
|
||||
legend1.BackColor = System.Drawing.Color.Transparent;
|
||||
legend1.Name = "ChartLegend";
|
||||
this.StatisticsChart.Legends.Add(legend1);
|
||||
this.StatisticsChart.Location = new System.Drawing.Point(0, 0);
|
||||
this.StatisticsChart.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
|
||||
this.StatisticsChart.Name = "StatisticsChart";
|
||||
this.StatisticsChart.Palette = System.Windows.Forms.DataVisualization.Charting.ChartColorPalette.Pastel;
|
||||
series4.ChartArea = "DataArea";
|
||||
series4.Color = System.Drawing.Color.DarkGray;
|
||||
series4.Legend = "ChartLegend";
|
||||
series4.Name = "Speed";
|
||||
series4.ToolTip = "Max inbound speed\\n#VAL KiB/s";
|
||||
series5.ChartArea = "DataArea";
|
||||
series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bubble;
|
||||
series5.Color = System.Drawing.Color.Crimson;
|
||||
series5.CustomProperties = "EmptyPointValue=Zero";
|
||||
series5.Legend = "ChartLegend";
|
||||
series5.Name = "Package Loss";
|
||||
series5.ToolTip = "#VAL%";
|
||||
series5.YAxisType = System.Windows.Forms.DataVisualization.Charting.AxisType.Secondary;
|
||||
series5.YValuesPerPoint = 2;
|
||||
series6.BorderWidth = 5;
|
||||
series6.ChartArea = "DataArea";
|
||||
series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
|
||||
series6.Color = System.Drawing.Color.DodgerBlue;
|
||||
series6.Legend = "ChartLegend";
|
||||
series6.MarkerSize = 10;
|
||||
series6.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
|
||||
series6.Name = "Ping";
|
||||
series6.ToolTip = "#VAL ms";
|
||||
this.StatisticsChart.Series.Add(series4);
|
||||
this.StatisticsChart.Series.Add(series5);
|
||||
this.StatisticsChart.Series.Add(series6);
|
||||
this.StatisticsChart.Size = new System.Drawing.Size(1089, 352);
|
||||
series1.ChartArea = "DataArea";
|
||||
series1.Color = System.Drawing.Color.DarkGray;
|
||||
series1.Legend = "ChartLegend";
|
||||
series1.Name = "Speed";
|
||||
series1.ToolTip = "#VALX\\nMax inbound speed\\n#VAL KiB/s";
|
||||
series1.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
|
||||
series2.ChartArea = "DataArea";
|
||||
series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bubble;
|
||||
series2.Color = System.Drawing.Color.Crimson;
|
||||
series2.CustomProperties = "EmptyPointValue=Zero";
|
||||
series2.Legend = "ChartLegend";
|
||||
series2.Name = "Package Loss";
|
||||
series2.ToolTip = "#VALX\\n#VAL%";
|
||||
series2.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
|
||||
series2.YAxisType = System.Windows.Forms.DataVisualization.Charting.AxisType.Secondary;
|
||||
series2.YValuesPerPoint = 2;
|
||||
series3.BorderWidth = 5;
|
||||
series3.ChartArea = "DataArea";
|
||||
series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
|
||||
series3.Color = System.Drawing.Color.DodgerBlue;
|
||||
series3.Legend = "ChartLegend";
|
||||
series3.MarkerSize = 10;
|
||||
series3.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
|
||||
series3.Name = "Ping";
|
||||
series3.ToolTip = "#VALX\\n#VAL ms";
|
||||
series3.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
|
||||
this.StatisticsChart.Series.Add(series1);
|
||||
this.StatisticsChart.Series.Add(series2);
|
||||
this.StatisticsChart.Series.Add(series3);
|
||||
this.StatisticsChart.Size = new System.Drawing.Size(978, 429);
|
||||
this.StatisticsChart.TabIndex = 2;
|
||||
//
|
||||
// PingCheckBox
|
||||
@@ -163,11 +167,11 @@
|
||||
this.chartModeSelector.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.chartModeSelector.Controls.Add(this.allMode);
|
||||
this.chartModeSelector.Controls.Add(this.dayMode);
|
||||
this.chartModeSelector.Location = new System.Drawing.Point(813, 123);
|
||||
this.chartModeSelector.Location = new System.Drawing.Point(729, 194);
|
||||
this.chartModeSelector.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
|
||||
this.chartModeSelector.Name = "chartModeSelector";
|
||||
this.chartModeSelector.Padding = new System.Windows.Forms.Padding(5, 10, 5, 10);
|
||||
this.chartModeSelector.Size = new System.Drawing.Size(261, 103);
|
||||
this.chartModeSelector.Size = new System.Drawing.Size(234, 103);
|
||||
this.chartModeSelector.TabIndex = 3;
|
||||
this.chartModeSelector.TabStop = false;
|
||||
this.chartModeSelector.Text = "Chart Mode";
|
||||
@@ -175,13 +179,11 @@
|
||||
// allMode
|
||||
//
|
||||
this.allMode.AutoSize = true;
|
||||
this.allMode.Checked = true;
|
||||
this.allMode.Location = new System.Drawing.Point(11, 61);
|
||||
this.allMode.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
|
||||
this.allMode.Name = "allMode";
|
||||
this.allMode.Size = new System.Drawing.Size(58, 31);
|
||||
this.allMode.TabIndex = 1;
|
||||
this.allMode.TabStop = true;
|
||||
this.allMode.Text = "all";
|
||||
this.allMode.UseVisualStyleBackColor = true;
|
||||
this.allMode.CheckedChanged += new System.EventHandler(this.allMode_CheckedChanged);
|
||||
@@ -189,11 +191,13 @@
|
||||
// dayMode
|
||||
//
|
||||
this.dayMode.AutoSize = true;
|
||||
this.dayMode.Checked = true;
|
||||
this.dayMode.Location = new System.Drawing.Point(11, 29);
|
||||
this.dayMode.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
|
||||
this.dayMode.Name = "dayMode";
|
||||
this.dayMode.Size = new System.Drawing.Size(73, 31);
|
||||
this.dayMode.TabIndex = 0;
|
||||
this.dayMode.TabStop = true;
|
||||
this.dayMode.Text = "24h";
|
||||
this.dayMode.UseVisualStyleBackColor = true;
|
||||
this.dayMode.CheckedChanged += new System.EventHandler(this.dayMode_CheckedChanged);
|
||||
@@ -218,8 +222,8 @@
|
||||
this.splitContainer1.Panel2.Controls.Add(this.OKButton);
|
||||
this.splitContainer1.Panel2.Controls.Add(this.chartModeSelector);
|
||||
this.splitContainer1.Panel2.Controls.Add(this.StatisticsChart);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(1089, 614);
|
||||
this.splitContainer1.SplitterDistance = 252;
|
||||
this.splitContainer1.Size = new System.Drawing.Size(978, 744);
|
||||
this.splitContainer1.SplitterDistance = 305;
|
||||
this.splitContainer1.SplitterWidth = 10;
|
||||
this.splitContainer1.TabIndex = 12;
|
||||
//
|
||||
@@ -249,7 +253,7 @@
|
||||
// splitContainer2.Panel2
|
||||
//
|
||||
this.splitContainer2.Panel2.Controls.Add(this.splitContainer3);
|
||||
this.splitContainer2.Size = new System.Drawing.Size(1089, 252);
|
||||
this.splitContainer2.Size = new System.Drawing.Size(978, 305);
|
||||
this.splitContainer2.SplitterDistance = 384;
|
||||
this.splitContainer2.SplitterWidth = 5;
|
||||
this.splitContainer2.TabIndex = 7;
|
||||
@@ -403,20 +407,21 @@
|
||||
// splitContainer3.Panel2
|
||||
//
|
||||
this.splitContainer3.Panel2.Controls.Add(this.calculationContainer);
|
||||
this.splitContainer3.Size = new System.Drawing.Size(700, 252);
|
||||
this.splitContainer3.SplitterDistance = 46;
|
||||
this.splitContainer3.SplitterWidth = 10;
|
||||
this.splitContainer3.Size = new System.Drawing.Size(589, 305);
|
||||
this.splitContainer3.SplitterDistance = 42;
|
||||
this.splitContainer3.SplitterWidth = 1;
|
||||
this.splitContainer3.TabIndex = 6;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(5, 12);
|
||||
this.label1.Location = new System.Drawing.Point(5, 9);
|
||||
this.label1.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(262, 27);
|
||||
this.label1.Size = new System.Drawing.Size(137, 27);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Design evaluation method";
|
||||
this.label1.Text = "Final Score =";
|
||||
this.CalculatinTip.SetToolTip(this.label1, "(The server with the highest score would be choosen)");
|
||||
//
|
||||
// calculationContainer
|
||||
//
|
||||
@@ -425,23 +430,23 @@
|
||||
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(700, 196);
|
||||
this.calculationContainer.Size = new System.Drawing.Size(589, 262);
|
||||
this.calculationContainer.TabIndex = 1;
|
||||
//
|
||||
// serverSelector
|
||||
//
|
||||
this.serverSelector.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.serverSelector.FormattingEnabled = true;
|
||||
this.serverSelector.Location = new System.Drawing.Point(813, 86);
|
||||
this.serverSelector.Location = new System.Drawing.Point(729, 157);
|
||||
this.serverSelector.Name = "serverSelector";
|
||||
this.serverSelector.Size = new System.Drawing.Size(260, 35);
|
||||
this.serverSelector.Size = new System.Drawing.Size(233, 35);
|
||||
this.serverSelector.TabIndex = 6;
|
||||
this.serverSelector.SelectionChangeCommitted += new System.EventHandler(this.serverSelector_SelectionChangeCommitted);
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
this.CancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.CancelButton.Location = new System.Drawing.Point(972, 239);
|
||||
this.CancelButton.Location = new System.Drawing.Point(861, 376);
|
||||
this.CancelButton.Name = "CancelButton";
|
||||
this.CancelButton.Size = new System.Drawing.Size(101, 41);
|
||||
this.CancelButton.TabIndex = 5;
|
||||
@@ -452,7 +457,7 @@
|
||||
// OKButton
|
||||
//
|
||||
this.OKButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.OKButton.Location = new System.Drawing.Point(864, 239);
|
||||
this.OKButton.Location = new System.Drawing.Point(754, 376);
|
||||
this.OKButton.Name = "OKButton";
|
||||
this.OKButton.Size = new System.Drawing.Size(101, 41);
|
||||
this.OKButton.TabIndex = 4;
|
||||
@@ -471,11 +476,11 @@
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 27F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoSize = true;
|
||||
this.ClientSize = new System.Drawing.Size(1089, 614);
|
||||
this.ClientSize = new System.Drawing.Size(978, 744);
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Font = new System.Drawing.Font("Microsoft YaHei", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
|
||||
this.MinimumSize = new System.Drawing.Size(1059, 498);
|
||||
this.MinimumSize = new System.Drawing.Size(1000, 800);
|
||||
this.Name = "StatisticsStrategyConfigurationForm";
|
||||
this.Text = "StatisticsStrategyConfigurationForm";
|
||||
((System.ComponentModel.ISupportInitialize)(this.StatisticsChart)).EndInit();
|
||||
@@ -528,5 +533,6 @@
|
||||
private new System.Windows.Forms.Button CancelButton;
|
||||
private System.Windows.Forms.Button OKButton;
|
||||
private System.Windows.Forms.ComboBox serverSelector;
|
||||
private System.Windows.Forms.ToolTip CalculatinTip;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.DataVisualization.Charting;
|
||||
using Shadowsocks.Controller;
|
||||
using Shadowsocks.Model;
|
||||
|
||||
@@ -14,15 +15,22 @@ namespace Shadowsocks.View
|
||||
private StatisticsStrategyConfiguration _configuration;
|
||||
private readonly DataTable _dataTable = new DataTable();
|
||||
private List<string> _servers;
|
||||
private readonly Series _speedSeries;
|
||||
private readonly Series _packageLossSeries;
|
||||
private readonly Series _pingSeries;
|
||||
|
||||
public StatisticsStrategyConfigurationForm(ShadowsocksController controller)
|
||||
{
|
||||
if (controller == null) return;
|
||||
InitializeComponent();
|
||||
_speedSeries = StatisticsChart.Series["Speed"];
|
||||
_packageLossSeries = StatisticsChart.Series["Package Loss"];
|
||||
_pingSeries = StatisticsChart.Series["Ping"];
|
||||
_controller = controller;
|
||||
_controller.ConfigChanged += (sender, args) => LoadConfiguration();
|
||||
LoadConfiguration();
|
||||
Load += (sender, args) => InitData();
|
||||
|
||||
}
|
||||
|
||||
private void LoadConfiguration()
|
||||
@@ -48,22 +56,18 @@ namespace Shadowsocks.View
|
||||
|
||||
serverSelector.DataSource = _servers;
|
||||
|
||||
var speedSeries = StatisticsChart.Series["Speed"];
|
||||
var packageLossSeries = StatisticsChart.Series["Package Loss"];
|
||||
var pingSeries = StatisticsChart.Series["Ping"];
|
||||
|
||||
_dataTable.Columns.Add("Timestamp", typeof(DateTime));
|
||||
_dataTable.Columns.Add("Speed", typeof (int));
|
||||
speedSeries.XValueMember = "Timestamp";
|
||||
speedSeries.YValueMembers = "Speed";
|
||||
_speedSeries.XValueMember = "Timestamp";
|
||||
_speedSeries.YValueMembers = "Speed";
|
||||
|
||||
// might be empty
|
||||
_dataTable.Columns.Add("Package Loss", typeof (int));
|
||||
_dataTable.Columns.Add("Ping", typeof (int));
|
||||
packageLossSeries.XValueMember = "Timestamp";
|
||||
packageLossSeries.YValueMembers = "Package Loss";
|
||||
pingSeries.XValueMember = "Timestamp";
|
||||
pingSeries.YValueMembers = "Ping";
|
||||
_packageLossSeries.XValueMember = "Timestamp";
|
||||
_packageLossSeries.YValueMembers = "Package Loss";
|
||||
_pingSeries.XValueMember = "Timestamp";
|
||||
_pingSeries.YValueMembers = "Ping";
|
||||
|
||||
StatisticsChart.DataSource = _dataTable;
|
||||
LoadChartData();
|
||||
@@ -98,12 +102,18 @@ namespace Shadowsocks.View
|
||||
IEnumerable<IGrouping<int, StatisticsRecord>> dataGroups;
|
||||
if (allMode.Checked)
|
||||
{
|
||||
_pingSeries.XValueType = ChartValueType.DateTime;
|
||||
_packageLossSeries.XValueType = ChartValueType.DateTime;
|
||||
_speedSeries.XValueType = ChartValueType.DateTime;
|
||||
dataGroups = statistics.GroupBy(data => data.Timestamp.DayOfYear);
|
||||
StatisticsChart.ChartAreas["DataArea"].AxisX.LabelStyle.Format = "g";
|
||||
StatisticsChart.ChartAreas["DataArea"].AxisX2.LabelStyle.Format = "g";
|
||||
}
|
||||
else
|
||||
{
|
||||
_pingSeries.XValueType = ChartValueType.Time;
|
||||
_packageLossSeries.XValueType = ChartValueType.Time;
|
||||
_speedSeries.XValueType = ChartValueType.Time;
|
||||
dataGroups = statistics.GroupBy(data => data.Timestamp.Hour);
|
||||
StatisticsChart.ChartAreas["DataArea"].AxisX.LabelStyle.Format = "HH:00";
|
||||
StatisticsChart.ChartAreas["DataArea"].AxisX2.LabelStyle.Format = "HH:00";
|
||||
|
||||
@@ -120,7 +120,10 @@
|
||||
<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="CalculatinTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>238, 6</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>63</value>
|
||||
<value>37</value>
|
||||
</metadata>
|
||||
</root>
|
||||
Reference in New Issue
Block a user