From 06d60f54bcdd8e0de640b99d3d4ba9dadfaa3618 Mon Sep 17 00:00:00 2001 From: icylogic Date: Fri, 5 Feb 2016 17:25:48 +0800 Subject: [PATCH] redesign statistics form --- .../Service/AvailabilityStatistics.cs | 1 - ...sticsStrategyConfigurationForm.Designer.cs | 29 +++++++++------ .../StatisticsStrategyConfigurationForm.cs | 37 ++++++++++++------- 3 files changed, 42 insertions(+), 25 deletions(-) diff --git a/shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs b/shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs index 8d805786..4e6a71bf 100644 --- a/shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs +++ b/shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.IO; using System.Linq; using System.Net; diff --git a/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.Designer.cs b/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.Designer.cs index d3f319a9..0bc91e92 100644 --- a/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.Designer.cs +++ b/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.Designer.cs @@ -33,8 +33,10 @@ 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.bindingConfiguration = new System.Windows.Forms.BindingSource(this.components); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.chartModeSelector = new System.Windows.Forms.GroupBox(); @@ -56,8 +58,8 @@ this.serverSelector = new System.Windows.Forms.ComboBox(); this.CancelButton = new System.Windows.Forms.Button(); this.OKButton = new System.Windows.Forms.Button(); - this.bindingConfiguration = new System.Windows.Forms.BindingSource(this.components); ((System.ComponentModel.ISupportInitialize)(this.StatisticsChart)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingConfiguration)).BeginInit(); this.chartModeSelector.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); @@ -74,7 +76,6 @@ this.splitContainer3.Panel1.SuspendLayout(); this.splitContainer3.Panel2.SuspendLayout(); this.splitContainer3.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.bindingConfiguration)).BeginInit(); this.SuspendLayout(); // // StatisticsChart @@ -108,10 +109,16 @@ series2.Legend = "ChartLegend"; series2.Name = "Ping"; series2.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.DateTime; + series3.ChartArea = "DataArea"; + series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Area; + series3.Legend = "ChartLegend"; + series3.Name = "Speed"; this.StatisticsChart.Series.Add(series1); this.StatisticsChart.Series.Add(series2); + this.StatisticsChart.Series.Add(series3); this.StatisticsChart.Size = new System.Drawing.Size(1089, 303); this.StatisticsChart.TabIndex = 2; + this.StatisticsChart.Click += new System.EventHandler(this.StatisticsChart_Click); // // PingCheckBox // @@ -126,6 +133,10 @@ this.PingCheckBox.UseVisualStyleBackColor = true; this.PingCheckBox.CheckedChanged += new System.EventHandler(this.PingCheckBox_CheckedChanged); // + // bindingConfiguration + // + this.bindingConfiguration.DataSource = typeof(Shadowsocks.Model.StatisticsStrategyConfiguration); + // // label2 // this.label2.AutoSize = true; @@ -151,7 +162,7 @@ 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, 98); + this.chartModeSelector.Location = new System.Drawing.Point(813, 92); 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); @@ -421,7 +432,7 @@ // 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, 61); + this.serverSelector.Location = new System.Drawing.Point(813, 55); this.serverSelector.Name = "serverSelector"; this.serverSelector.Size = new System.Drawing.Size(260, 31); this.serverSelector.TabIndex = 6; @@ -430,7 +441,7 @@ // 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, 214); + this.CancelButton.Location = new System.Drawing.Point(972, 208); this.CancelButton.Name = "CancelButton"; this.CancelButton.Size = new System.Drawing.Size(101, 41); this.CancelButton.TabIndex = 5; @@ -441,7 +452,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, 214); + this.OKButton.Location = new System.Drawing.Point(864, 208); this.OKButton.Name = "OKButton"; this.OKButton.Size = new System.Drawing.Size(101, 41); this.OKButton.TabIndex = 4; @@ -449,10 +460,6 @@ this.OKButton.UseVisualStyleBackColor = true; this.OKButton.Click += new System.EventHandler(this.OKButton_Click); // - // bindingConfiguration - // - this.bindingConfiguration.DataSource = typeof(Shadowsocks.Model.StatisticsStrategyConfiguration); - // // StatisticsStrategyConfigurationForm // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 23F); @@ -466,6 +473,7 @@ this.Name = "StatisticsStrategyConfigurationForm"; this.Text = "StatisticsStrategyConfigurationForm"; ((System.ComponentModel.ISupportInitialize)(this.StatisticsChart)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingConfiguration)).EndInit(); this.chartModeSelector.ResumeLayout(false); this.chartModeSelector.PerformLayout(); this.splitContainer1.Panel1.ResumeLayout(false); @@ -485,7 +493,6 @@ this.splitContainer3.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit(); this.splitContainer3.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.bindingConfiguration)).EndInit(); this.ResumeLayout(false); } diff --git a/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs b/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs index cda9448c..2fb71b00 100644 --- a/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs +++ b/shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Data; using System.Linq; -using System.Net.NetworkInformation; using System.Windows.Forms; using Shadowsocks.Controller; @@ -52,15 +51,22 @@ namespace Shadowsocks.View serverSelector.DataSource = _servers; _dataTable.Columns.Add("Timestamp", typeof(DateTime)); - _dataTable.Columns.Add("Package Loss", typeof(int)); - _dataTable.Columns.Add("Ping", typeof(int)); + _dataTable.Columns.Add("Speed", typeof (int)); + StatisticsChart.Series["Speed"].XValueMember = "Timestamp"; + StatisticsChart.Series["Speed"].YValueMembers = "Speed"; + + if (_configuration.Ping) + { + _dataTable.Columns.Add("Package Loss", typeof (int)); + _dataTable.Columns.Add("Ping", typeof (int)); + StatisticsChart.Series["Package Loss"].XValueMember = "Timestamp"; + StatisticsChart.Series["Package Loss"].YValueMembers = "Package Loss"; + StatisticsChart.Series["Ping"].XValueMember = "Timestamp"; + StatisticsChart.Series["Ping"].YValueMembers = "Ping"; + } - StatisticsChart.Series["Package Loss"].XValueMember = "Timestamp"; - StatisticsChart.Series["Package Loss"].YValueMembers = "Package Loss"; - StatisticsChart.Series["Ping"].XValueMember = "Timestamp"; - StatisticsChart.Series["Ping"].YValueMembers = "Ping"; StatisticsChart.DataSource = _dataTable; - loadChartData(); + LoadChartData(); StatisticsChart.DataBind(); } @@ -80,9 +86,9 @@ namespace Shadowsocks.View Close(); } - private void loadChartData() + private void LoadChartData() { - string serverName = _servers[serverSelector.SelectedIndex]; + var serverName = _servers[serverSelector.SelectedIndex]; _dataTable.Rows.Clear(); //return directly when no data is usable @@ -118,7 +124,7 @@ namespace Shadowsocks.View private void serverSelector_SelectedIndexChanged(object sender, EventArgs e) { - loadChartData(); + LoadChartData(); } private void chartModeSelector_Enter(object sender, EventArgs e) @@ -128,17 +134,22 @@ namespace Shadowsocks.View private void dayMode_CheckedChanged(object sender, EventArgs e) { - loadChartData(); + LoadChartData(); } private void allMode_CheckedChanged(object sender, EventArgs e) { - loadChartData(); + LoadChartData(); } private void PingCheckBox_CheckedChanged(object sender, EventArgs e) { repeatTimesNum.ReadOnly = !PingCheckBox.Checked; } + + private void StatisticsChart_Click(object sender, EventArgs e) + { + + } } }