diff --git a/MainForm.cs b/MainForm.cs index f25dde1..88264f0 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -185,25 +185,32 @@ namespace friction #region Events from panels public void OnApplyData(string strSpring, string strTable) { + Console.WriteLine(string.Format("[start] MainForm::OnApplyData({0}, {1})", strSpring, strTable)); + + m_DataHandler.SetSelectedMaterial(strSpring, strTable); + if (strTable == "All") { trendGraphToolStripMenuItem.Enabled = toolStripButtonTrendGraph.Enabled = false; radarGraphToolStripMenuItem.Enabled = toolStripButtonRadarGraph.Enabled = true; - if (m_RadarGraphPanel.Visible == true) + if (m_RadarGraphPanel != null) m_RadarGraphPanel.UpdateGraph(); + if (m_TrendGraphPanel != null) + m_TrendGraphPanel.UpdateGraph(); } else { trendGraphToolStripMenuItem.Enabled = toolStripButtonTrendGraph.Enabled = true; radarGraphToolStripMenuItem.Enabled = toolStripButtonRadarGraph.Enabled = false; - if (m_TrendGraphPanel.Visible == true) + if (m_TrendGraphPanel != null) m_TrendGraphPanel.UpdateGraph(); } - m_DataHandler.SetSelectedMaterial(strSpring, strTable); m_AnalysisPanel.UpdateData(m_DataHandler); + + Console.WriteLine(string.Format("[end ] MainForm::OnApplyData({0}, {1})", strSpring, strTable)); } public void OnRadarSelectTable(string strTable) diff --git a/PanelMaterial.Designer.cs b/PanelMaterial.Designer.cs index 8e3c39d..8618487 100644 --- a/PanelMaterial.Designer.cs +++ b/PanelMaterial.Designer.cs @@ -28,43 +28,15 @@ /// private void InitializeComponent() { - this.cbMaterialTable = new System.Windows.Forms.ComboBox(); - this.cbMaterialSpring = new System.Windows.Forms.ComboBox(); - this.btApply = new System.Windows.Forms.Button(); this.lbFileName = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); + this.lvSpring = new System.Windows.Forms.ListView(); + this.lvchSpring = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.lvTable = new System.Windows.Forms.ListView(); + this.lvchTable = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.SuspendLayout(); // - // cbMaterialTable - // - this.cbMaterialTable.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cbMaterialTable.FormattingEnabled = true; - this.cbMaterialTable.Location = new System.Drawing.Point(32, 122); - this.cbMaterialTable.Name = "cbMaterialTable"; - this.cbMaterialTable.Size = new System.Drawing.Size(121, 20); - this.cbMaterialTable.TabIndex = 1; - // - // cbMaterialSpring - // - this.cbMaterialSpring.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cbMaterialSpring.FormattingEnabled = true; - this.cbMaterialSpring.Location = new System.Drawing.Point(32, 61); - this.cbMaterialSpring.Name = "cbMaterialSpring"; - this.cbMaterialSpring.Size = new System.Drawing.Size(121, 20); - this.cbMaterialSpring.TabIndex = 2; - // - // btApply - // - this.btApply.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btApply.Location = new System.Drawing.Point(32, 179); - this.btApply.Name = "btApply"; - this.btApply.Size = new System.Drawing.Size(75, 23); - this.btApply.TabIndex = 3; - this.btApply.Text = "Apply"; - this.btApply.UseVisualStyleBackColor = true; - this.btApply.Click += new System.EventHandler(this.btApply_Click); - // // lbFileName // this.lbFileName.AutoSize = true; @@ -77,7 +49,7 @@ // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(30, 46); + this.label2.Location = new System.Drawing.Point(12, 46); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(90, 12); this.label2.TabIndex = 5; @@ -85,25 +57,70 @@ // // label3 // + this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(30, 107); + this.label3.Location = new System.Drawing.Point(10, 424); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(86, 12); this.label3.TabIndex = 6; this.label3.Text = "Material Table"; // + // lvSpring + // + this.lvSpring.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lvSpring.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.lvchSpring}); + this.lvSpring.FullRowSelect = true; + this.lvSpring.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.lvSpring.Location = new System.Drawing.Point(12, 61); + this.lvSpring.Name = "lvSpring"; + this.lvSpring.Size = new System.Drawing.Size(326, 343); + this.lvSpring.TabIndex = 7; + this.lvSpring.UseCompatibleStateImageBehavior = false; + this.lvSpring.View = System.Windows.Forms.View.Details; + this.lvSpring.SizeChanged += new System.EventHandler(this.lvSpring_SizeChanged); + this.lvSpring.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvSpring_MouseDoubleClick); + // + // lvchSpring + // + this.lvchSpring.Text = "Material Spring"; + this.lvchSpring.Width = 308; + // + // lvTable + // + this.lvTable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lvTable.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.lvchTable}); + this.lvTable.FullRowSelect = true; + this.lvTable.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.lvTable.Location = new System.Drawing.Point(12, 439); + this.lvTable.Name = "lvTable"; + this.lvTable.Size = new System.Drawing.Size(326, 276); + this.lvTable.TabIndex = 8; + this.lvTable.UseCompatibleStateImageBehavior = false; + this.lvTable.View = System.Windows.Forms.View.Details; + this.lvTable.SizeChanged += new System.EventHandler(this.lvTable_SizeChanged); + this.lvTable.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvTable_MouseDoubleClick); + // + // lvchTable + // + this.lvchTable.Text = "Table"; + this.lvchTable.Width = 305; + // // PanelMaterial // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(284, 261); + this.ClientSize = new System.Drawing.Size(350, 727); this.ControlBox = false; + this.Controls.Add(this.lvTable); + this.Controls.Add(this.lvSpring); this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.lbFileName); - this.Controls.Add(this.btApply); - this.Controls.Add(this.cbMaterialSpring); - this.Controls.Add(this.cbMaterialTable); this.HideOnClose = true; this.Name = "PanelMaterial"; this.ShowHint = WeifenLuo.WinFormsUI.Docking.DockState.DockLeft; @@ -115,12 +132,12 @@ } #endregion - - private System.Windows.Forms.ComboBox cbMaterialTable; - private System.Windows.Forms.ComboBox cbMaterialSpring; - private System.Windows.Forms.Button btApply; private System.Windows.Forms.Label lbFileName; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; + private System.Windows.Forms.ListView lvSpring; + private System.Windows.Forms.ListView lvTable; + private System.Windows.Forms.ColumnHeader lvchSpring; + private System.Windows.Forms.ColumnHeader lvchTable; } } \ No newline at end of file diff --git a/PanelMaterial.cs b/PanelMaterial.cs index 25f36dd..a6e251d 100644 --- a/PanelMaterial.cs +++ b/PanelMaterial.cs @@ -15,6 +15,9 @@ namespace friction { MainForm m_Owner = null; + ListViewItem m_SelectedSpring = null; + ListViewItem m_SelectedTable = null; + public PanelMaterial(MainForm owner) { InitializeComponent(); @@ -23,35 +26,88 @@ namespace friction this.ApplyTheme(); Theme.Apply(this); - Theme.Apply(cbMaterialSpring); - Theme.Apply(cbMaterialTable); - Theme.Apply(btApply); + Theme.Apply(lvSpring); + Theme.Apply(lvTable); } public void UpdateData(DataHandler data) { + m_SelectedSpring = null; + m_SelectedTable = null; + var SpringList = data.GetSpringList(); var TableList = data.GetTableList(); - cbMaterialSpring.Items.Clear(); + lvSpring.Items.Clear(); foreach (var x in SpringList) - cbMaterialSpring.Items.Add(x); - cbMaterialSpring.SelectedIndex = 0; - - cbMaterialTable.Items.Clear(); - cbMaterialTable.Items.Add("All"); + lvSpring.Items.Add(x); + + lvTable.Items.Clear(); + lvTable.Items.Add("All"); foreach (var x in TableList) - cbMaterialTable.Items.Add(x); - cbMaterialTable.SelectedIndex = 0; + lvTable.Items.Add(x); + + lvSpring.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); + lvTable.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); lbFileName.Text = data.GetFileName(); - m_Owner.OnApplyData((string)cbMaterialSpring.SelectedItem, (string)cbMaterialTable.SelectedItem); + SelectSpring(0); + SelectTable(0); } - private void btApply_Click(object sender, EventArgs e) + private void lvSpring_SizeChanged(object sender, EventArgs e) { - m_Owner.OnApplyData((string)cbMaterialSpring.SelectedItem, (string)cbMaterialTable.SelectedItem); + lvSpring.Columns[0].Width = lvSpring.Width - SystemInformation.VerticalScrollBarWidth - lvSpring.Margin.Right*2; + } + + private void lvTable_SizeChanged(object sender, EventArgs e) + { + lvTable.Columns[0].Width = lvTable.Width - SystemInformation.VerticalScrollBarWidth - lvTable.Margin.Right*2; + } + + private void SelectSpring(int iIdx) + { + if (m_SelectedSpring != null) + { + m_SelectedSpring.Font = lvSpring.Font; + m_SelectedSpring.ForeColor = Theme.Forecolor; + } + + m_SelectedSpring = lvSpring.Items[iIdx]; + m_SelectedSpring.Font = new Font(lvSpring.Font, FontStyle.Bold); + m_SelectedSpring.ForeColor = Color.Orange; + + if(m_SelectedSpring != null && m_SelectedTable != null) + m_Owner.OnApplyData(m_SelectedSpring.Text, m_SelectedTable.Text); + } + + private void SelectTable(int iIdx) + { + if (m_SelectedTable != null) + { + m_SelectedTable.Font = lvTable.Font; + m_SelectedTable.ForeColor = Theme.Forecolor; + } + + m_SelectedTable = lvTable.Items[iIdx]; + m_SelectedTable.Font = new Font(lvTable.Font, FontStyle.Bold); + m_SelectedTable.ForeColor = Color.Orange; + + if (m_SelectedSpring != null && m_SelectedTable != null) + m_Owner.OnApplyData(m_SelectedSpring.Text, m_SelectedTable.Text); + } + + private void lvSpring_MouseDoubleClick(object sender, MouseEventArgs e) + { + if(lvSpring.SelectedIndices.Count == 1) + SelectSpring(lvSpring.SelectedIndices[0]); + } + + private void lvTable_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (lvTable.SelectedIndices.Count == 1) + SelectTable(lvTable.SelectedIndices[0]); } } } diff --git a/PanelTrendGraph.cs b/PanelTrendGraph.cs index 5ed22e3..7e9a153 100644 --- a/PanelTrendGraph.cs +++ b/PanelTrendGraph.cs @@ -112,13 +112,30 @@ namespace friction string strSpring = m_DataHandler.GetCurSpring(); string strTable = m_DataHandler.GetCurTable(); - if (m_CurSpring == strSpring && m_CurTable == strTable && rbHumidity.Checked == m_bHumidity) + Console.WriteLine(string.Format("[start] TrendGraph::UpdateGraph ({0}, {1}) -> ({2}, {3})", + m_CurSpring, m_CurTable, strSpring, strTable)); + + if (m_CurSpring == strSpring && m_CurTable == strTable + && rbHumidity.Checked == m_bHumidity + && m_bHumidity == rbHumidity.Checked) + { return; + } var Chart = m_DataHandler.GetHumidityChart(strSpring, strTable); if (Chart.Count <= 0) + { + foreach(Series series in trendChart.Series) + series.Values.Clear(); + + m_CurSpring = strSpring; + m_CurTable = strTable; + m_bHumidity = rbHumidity.Checked; + return; + } + string strTitle = ""; double dMin = 0; @@ -260,6 +277,8 @@ namespace friction m_CurSpring = strSpring; m_CurTable = strTable; m_bHumidity = rbHumidity.Checked; + + Console.WriteLine(string.Format("[end ] TrendGraph::UpdateGraph({0}, {1})", strSpring, strTable)); } private void rbHumidity_CheckedChanged(object sender, EventArgs e)