diff --git a/DataHandler.cs b/DataHandler.cs index d9ef8e7..815df17 100644 --- a/DataHandler.cs +++ b/DataHandler.cs @@ -192,7 +192,14 @@ namespace friction Config.COLUMN_NAME.TEMP, TempCond.m_fLow, TempCond.m_fHigh, Config.COLUMN_NAME.HUMIDITY, HumidCond.m_fLow, HumidCond.m_fHigh); - DataRow[] rows = m_Data.Select(strQuery); + DataRow[] rows = null; + try{ + rows = m_Data.Select(strQuery); + } + catch{ + return new List(); + } + var group = rows.GroupBy(r => r[Config.COLUMN_NAME.TABLE]); List result = rows @@ -233,6 +240,29 @@ namespace friction return result; } + public List GetMaxes(string strSpring, string strTable) + { + List result = new List(); + + Config.RANGE[] aTemp = new Config.RANGE[] { Config.TEMP_NORMAL, Config.TEMP_NORMAL, Config.TEMP_HIGH, Config.TEMP_HIGH, Config.TEMP_LOW }; + Config.RANGE[] aHumidity = new Config.RANGE[] { Config.HUMID_LOW, Config.HUMID_HIGH, Config.HUMID_LOW, Config.HUMID_HIGH, Config.HUMID_ALL }; + + for(int i=0; i= {5} and [{4}] <= {6} and [{7}] >= {8} and [{7}] <= {9}", + Config.COLUMN_NAME.SPRING, strSpring, Config.COLUMN_NAME.TABLE, strTable, + Config.COLUMN_NAME.TEMP, aTemp[i].m_fLow, aTemp[i].m_fHigh, + Config.COLUMN_NAME.HUMIDITY, aHumidity[i].m_fLow, aHumidity[i].m_fHigh); + var rows = m_Data.Select(strQuery); + float fValue = 0; + if(rows.Length > 0) + fValue = rows.Max(t => (float)t[Config.COLUMN_NAME.RPN]); + result.Add(fValue); + } + + return result; + } + #region calculation float CalcDependency(DataRow[] rows, string strColumn) { diff --git a/MainForm.cs b/MainForm.cs index a7632b0..0414c00 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -33,7 +33,7 @@ namespace friction m_MaterialPanel = new PanelMaterial(this); m_ResultPanel = new PanelResult(this); m_AnalysisPanel = new PanelAnalysis(this); - m_CompatibilityPanel = new PanelCompatibility(this); + m_CompatibilityPanel = new PanelCompatibility(this, m_DataHandler); m_RadarGraphPanel = new PanelRadarGraph(this, m_DataHandler); m_TrendGraphPanel = new PanelTrendGraph(this, m_DataHandler); @@ -106,7 +106,7 @@ namespace friction m_TrendGraphPanel.UpdateGraph(); OpenPanel(m_TrendGraphPanel); - m_CompatibilityPanel.UpdateData(m_DataHandler); + m_CompatibilityPanel.UpdateData(); OpenPanel(m_CompatibilityPanel); toolStripStatusLabel.Text = m_DBFileName; @@ -159,7 +159,7 @@ namespace friction private void materialCompatibilityMapToolStripMenuItem_Click(object sender, EventArgs e) { OpenPanel(m_CompatibilityPanel); - m_CompatibilityPanel.UpdateData(m_DataHandler); + m_CompatibilityPanel.UpdateData(); } private void radarGraphToolStripMenuItem_Click(object sender, EventArgs e) @@ -283,7 +283,7 @@ namespace friction private void toolStripButtonMap_Click(object sender, EventArgs e) { OpenPanel(m_CompatibilityPanel); - m_CompatibilityPanel.UpdateData(m_DataHandler); + m_CompatibilityPanel.UpdateData(); } private void toolStripButtonRadarGraph_Click(object sender, EventArgs e) @@ -298,7 +298,13 @@ namespace friction private void toolStripButtonTrendGraph_Click(object sender, EventArgs e) { if (m_DataHandler.GetCurTable() == "All") - OnApplyData(this, m_DataHandler.GetCurSpring(), m_DataHandler.GetTableList()[0]); + { + string strSpring = m_DataHandler.GetCurSpring(); + List tableList = m_DataHandler.GetTableList(); + + if(tableList.Count > 0) + OnApplyData(this, strSpring, tableList[0]); + } OpenPanel(m_TrendGraphPanel); m_TrendGraphPanel.UpdateGraph(); diff --git a/PanelCompatibility.Designer.cs b/PanelCompatibility.Designer.cs index ab64340..aff23fb 100644 --- a/PanelCompatibility.Designer.cs +++ b/PanelCompatibility.Designer.cs @@ -31,18 +31,20 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PanelCompatibility)); this.dgvMap = new System.Windows.Forms.DataGridView(); this.btPivot = new System.Windows.Forms.Button(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); + this.detailPanel = new System.Windows.Forms.TableLayoutPanel(); + this.lbLowTemp = new System.Windows.Forms.Label(); + this.lbHighHigh = new System.Windows.Forms.Label(); + this.lbHighLow = new System.Windows.Forms.Label(); + this.lbNormalHigh = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); - this.label6 = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); - this.label8 = new System.Windows.Forms.Label(); - this.label9 = new System.Windows.Forms.Label(); - this.label10 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.lbNormalLow = new System.Windows.Forms.Label(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); ((System.ComponentModel.ISupportInitialize)(this.dgvMap)).BeginInit(); + this.detailPanel.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // @@ -52,15 +54,16 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dgvMap.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dgvMap.Location = new System.Drawing.Point(12, 65); + this.dgvMap.Location = new System.Drawing.Point(3, 32); this.dgvMap.Name = "dgvMap"; this.dgvMap.RowTemplate.Height = 23; - this.dgvMap.Size = new System.Drawing.Size(799, 498); + this.dgvMap.Size = new System.Drawing.Size(817, 576); this.dgvMap.TabIndex = 0; + this.dgvMap.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvMap_CellClick); // // btPivot // - this.btPivot.Location = new System.Drawing.Point(12, 12); + this.btPivot.Location = new System.Drawing.Point(3, 3); this.btPivot.Name = "btPivot"; this.btPivot.Size = new System.Drawing.Size(75, 23); this.btPivot.TabIndex = 1; @@ -68,31 +71,118 @@ this.btPivot.UseVisualStyleBackColor = true; this.btPivot.Click += new System.EventHandler(this.btPivot_Click); // - // tableLayoutPanel1 + // detailPanel // - this.tableLayoutPanel1.ColumnCount = 5; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.Controls.Add(this.label10, 4, 1); - this.tableLayoutPanel1.Controls.Add(this.label9, 3, 1); - this.tableLayoutPanel1.Controls.Add(this.label8, 2, 1); - this.tableLayoutPanel1.Controls.Add(this.label7, 1, 1); - this.tableLayoutPanel1.Controls.Add(this.label5, 4, 0); - this.tableLayoutPanel1.Controls.Add(this.label4, 3, 0); - this.tableLayoutPanel1.Controls.Add(this.label3, 2, 0); - this.tableLayoutPanel1.Controls.Add(this.label2, 1, 0); - this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.label6, 0, 1); - this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 569); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 2; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(799, 99); - this.tableLayoutPanel1.TabIndex = 2; + this.detailPanel.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.detailPanel.ColumnCount = 5; + this.detailPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.detailPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.detailPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.detailPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.detailPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.detailPanel.Controls.Add(this.lbLowTemp, 4, 1); + this.detailPanel.Controls.Add(this.lbHighHigh, 3, 1); + this.detailPanel.Controls.Add(this.lbHighLow, 2, 1); + this.detailPanel.Controls.Add(this.lbNormalHigh, 1, 1); + this.detailPanel.Controls.Add(this.label5, 4, 0); + this.detailPanel.Controls.Add(this.label4, 3, 0); + this.detailPanel.Controls.Add(this.label3, 2, 0); + this.detailPanel.Controls.Add(this.label2, 1, 0); + this.detailPanel.Controls.Add(this.label1, 0, 0); + this.detailPanel.Controls.Add(this.lbNormalLow, 0, 1); + this.detailPanel.Location = new System.Drawing.Point(3, 614); + this.detailPanel.Name = "detailPanel"; + this.detailPanel.RowCount = 2; + this.detailPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.detailPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.detailPanel.Size = new System.Drawing.Size(817, 54); + this.detailPanel.TabIndex = 2; + // + // lbLowTemp + // + this.lbLowTemp.AutoSize = true; + this.lbLowTemp.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbLowTemp.Location = new System.Drawing.Point(655, 27); + this.lbLowTemp.Name = "lbLowTemp"; + this.lbLowTemp.Size = new System.Drawing.Size(159, 27); + this.lbLowTemp.TabIndex = 19; + this.lbLowTemp.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lbHighHigh + // + this.lbHighHigh.AutoSize = true; + this.lbHighHigh.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbHighHigh.Location = new System.Drawing.Point(492, 27); + this.lbHighHigh.Name = "lbHighHigh"; + this.lbHighHigh.Size = new System.Drawing.Size(157, 27); + this.lbHighHigh.TabIndex = 18; + this.lbHighHigh.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lbHighLow + // + this.lbHighLow.AutoSize = true; + this.lbHighLow.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbHighLow.Location = new System.Drawing.Point(329, 27); + this.lbHighLow.Name = "lbHighLow"; + this.lbHighLow.Size = new System.Drawing.Size(157, 27); + this.lbHighLow.TabIndex = 17; + this.lbHighLow.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lbNormalHigh + // + this.lbNormalHigh.AutoSize = true; + this.lbNormalHigh.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbNormalHigh.Location = new System.Drawing.Point(166, 27); + this.lbNormalHigh.Name = "lbNormalHigh"; + this.lbNormalHigh.Size = new System.Drawing.Size(157, 27); + this.lbNormalHigh.TabIndex = 16; + this.lbNormalHigh.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Dock = System.Windows.Forms.DockStyle.Fill; + this.label5.Location = new System.Drawing.Point(655, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(159, 27); + this.label5.TabIndex = 14; + this.label5.Text = "Low Temp"; + this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Dock = System.Windows.Forms.DockStyle.Fill; + this.label4.Location = new System.Drawing.Point(492, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(157, 27); + this.label4.TabIndex = 13; + this.label4.Text = "High Temp\r\nHigh Humid"; + this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Dock = System.Windows.Forms.DockStyle.Fill; + this.label3.Location = new System.Drawing.Point(329, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(157, 27); + this.label3.TabIndex = 12; + this.label3.Text = "High Temp\r\nLow Humid"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Dock = System.Windows.Forms.DockStyle.Fill; + this.label2.Location = new System.Drawing.Point(166, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(157, 27); + this.label2.TabIndex = 11; + this.label2.Text = "Normal Temp\r\nHigh Humid"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // label1 // @@ -100,104 +190,37 @@ this.label1.Dock = System.Windows.Forms.DockStyle.Fill; this.label1.Location = new System.Drawing.Point(3, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(153, 49); + this.label1.Size = new System.Drawing.Size(157, 27); this.label1.TabIndex = 10; this.label1.Text = "Normal Temp\r\nLow Humid"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // - // label2 + // lbNormalLow // - this.label2.AutoSize = true; - this.label2.Dock = System.Windows.Forms.DockStyle.Fill; - this.label2.Location = new System.Drawing.Point(162, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(153, 49); - this.label2.TabIndex = 11; - this.label2.Text = "Normal Temp\r\nHigh Humid"; - this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.lbNormalLow.AutoSize = true; + this.lbNormalLow.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbNormalLow.Location = new System.Drawing.Point(3, 27); + this.lbNormalLow.Name = "lbNormalLow"; + this.lbNormalLow.Size = new System.Drawing.Size(157, 27); + this.lbNormalLow.TabIndex = 15; + this.lbNormalLow.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // label3 + // tableLayoutPanel1 // - this.label3.AutoSize = true; - this.label3.Dock = System.Windows.Forms.DockStyle.Fill; - this.label3.Location = new System.Drawing.Point(321, 0); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(153, 49); - this.label3.TabIndex = 12; - this.label3.Text = "High Temp\r\nLow Humid"; - this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Dock = System.Windows.Forms.DockStyle.Fill; - this.label4.Location = new System.Drawing.Point(480, 0); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(153, 49); - this.label4.TabIndex = 13; - this.label4.Text = "High Temp\r\nHigh Humid"; - this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Dock = System.Windows.Forms.DockStyle.Fill; - this.label5.Location = new System.Drawing.Point(639, 0); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(157, 49); - this.label5.TabIndex = 14; - this.label5.Text = "Low Temp"; - this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Dock = System.Windows.Forms.DockStyle.Fill; - this.label6.Location = new System.Drawing.Point(3, 49); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(153, 50); - this.label6.TabIndex = 15; - this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Dock = System.Windows.Forms.DockStyle.Fill; - this.label7.Location = new System.Drawing.Point(162, 49); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(153, 50); - this.label7.TabIndex = 16; - this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label8 - // - this.label8.AutoSize = true; - this.label8.Dock = System.Windows.Forms.DockStyle.Fill; - this.label8.Location = new System.Drawing.Point(321, 49); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(153, 50); - this.label8.TabIndex = 17; - this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label9 - // - this.label9.AutoSize = true; - this.label9.Dock = System.Windows.Forms.DockStyle.Fill; - this.label9.Location = new System.Drawing.Point(480, 49); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(153, 50); - this.label9.TabIndex = 18; - this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Dock = System.Windows.Forms.DockStyle.Fill; - this.label10.Location = new System.Drawing.Point(639, 49); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(157, 50); - this.label10.TabIndex = 19; - this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.tableLayoutPanel1.ColumnCount = 1; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Controls.Add(this.btPivot, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.dgvMap, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.detailPanel, 0, 2); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 29F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 60F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(823, 671); + this.tableLayoutPanel1.TabIndex = 3; // // PanelCompatibility // @@ -206,8 +229,6 @@ this.ClientSize = new System.Drawing.Size(823, 671); this.ControlBox = false; this.Controls.Add(this.tableLayoutPanel1); - this.Controls.Add(this.btPivot); - this.Controls.Add(this.dgvMap); this.DockAreas = ((WeifenLuo.WinFormsUI.Docking.DockAreas)(((((WeifenLuo.WinFormsUI.Docking.DockAreas.DockLeft | WeifenLuo.WinFormsUI.Docking.DockAreas.DockRight) | WeifenLuo.WinFormsUI.Docking.DockAreas.DockTop) | WeifenLuo.WinFormsUI.Docking.DockAreas.DockBottom) @@ -217,8 +238,9 @@ this.Name = "PanelCompatibility"; this.Text = "Material Compatibility Map"; ((System.ComponentModel.ISupportInitialize)(this.dgvMap)).EndInit(); + this.detailPanel.ResumeLayout(false); + this.detailPanel.PerformLayout(); this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel1.PerformLayout(); this.ResumeLayout(false); } @@ -227,16 +249,17 @@ private System.Windows.Forms.DataGridView dgvMap; private System.Windows.Forms.Button btPivot; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.Label label10; - private System.Windows.Forms.Label label9; - private System.Windows.Forms.Label label8; - private System.Windows.Forms.Label label7; + private System.Windows.Forms.TableLayoutPanel detailPanel; + private System.Windows.Forms.Label lbLowTemp; + private System.Windows.Forms.Label lbHighHigh; + private System.Windows.Forms.Label lbHighLow; + private System.Windows.Forms.Label lbNormalHigh; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label lbNormalLow; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; } } \ No newline at end of file diff --git a/PanelCompatibility.cs b/PanelCompatibility.cs index 9677cc8..2d0df1a 100644 --- a/PanelCompatibility.cs +++ b/PanelCompatibility.cs @@ -16,15 +16,18 @@ namespace friction const int HEADER_SIZE = 100; MainForm m_Owner = null; + DataHandler m_DataHandler = null; - public PanelCompatibility(MainForm owner) + public PanelCompatibility(MainForm owner, DataHandler dataHandler) { InitializeComponent(); m_Owner = owner; + m_DataHandler = dataHandler; Theme.Apply(this); Theme.Apply(dgvMap); + Theme.Apply(btPivot); dgvMap.CellPainting += DgvMap_CellPainting; dgvMap.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing; @@ -44,10 +47,10 @@ namespace friction e.ToolTipText = "tooltip"; } - public void UpdateData(DataHandler data) + public void UpdateData() { - var Springs = data.GetSpringList(); - var Tables = data.GetTableList(); + var Springs = m_DataHandler.GetSpringList(); + var Tables = m_DataHandler.GetTableList(); dgvMap.Rows.Clear(); dgvMap.Columns.Clear(); @@ -75,7 +78,7 @@ namespace friction dgvMap.Rows[iRow].HeaderCell.Value = spring; dgvMap.Rows[iRow].HeaderCell.ToolTipText = spring; - var Averages = data.GetAvgAll(spring, Config.TEMP_ALL, Config.HUMID_ALL); + var Averages = m_DataHandler.GetAvgAll(spring, Config.TEMP_ALL, Config.HUMID_ALL); foreach(var avg in Averages) { if(avg.m_fMax > 0) @@ -138,7 +141,7 @@ namespace friction { DataGridView view = sender as DataGridView; - + if (e.RowIndex == -1 && e.ColumnIndex >= 0) { Brush brush = new SolidBrush(this.dgvMap.ForeColor); @@ -146,14 +149,14 @@ namespace friction e.PaintBackground(e.ClipBounds, true); Rectangle rect = view.GetColumnDisplayRectangle(e.ColumnIndex, true); Size titleSize = TextRenderer.MeasureText(e.Value.ToString(), e.CellStyle.Font); - if (view.ColumnHeadersHeight < titleSize.Width) - view.ColumnHeadersHeight = titleSize.Width; - if (view.ColumnHeadersHeight > HEADER_SIZE) - view.ColumnHeadersHeight = HEADER_SIZE; + //if (view.ColumnHeadersHeight < titleSize.Width) + // view.ColumnHeadersHeight = titleSize.Width; + //if (view.ColumnHeadersHeight > HEADER_SIZE) + // view.ColumnHeadersHeight = HEADER_SIZE; e.Graphics.TranslateTransform(0, titleSize.Width); e.Graphics.RotateTransform(-90.0F); - e.Graphics.DrawString(e.Value.ToString(), this.Font, brush, - new PointF(rect.Y - (view.ColumnHeadersHeight - titleSize.Width), rect.X+(e.CellBounds.Width-titleSize.Height)/2)); + e.Graphics.DrawString(e.Value.ToString(), this.Font, brush, + new PointF(rect.Y - (view.ColumnHeadersHeight - titleSize.Width), rect.X + (e.CellBounds.Width - titleSize.Height) / 2)); e.Graphics.RotateTransform(90.0F); e.Graphics.TranslateTransform(0, -titleSize.Width); e.Handled = true; @@ -213,5 +216,63 @@ namespace friction { Pivot(); } + + private void dgvMap_CellClick(object sender, DataGridViewCellEventArgs e) + { + if (e.RowIndex < 0 || e.ColumnIndex < 0) + return; + + if (dgvMap.Rows.Count < e.RowIndex || dgvMap.Columns.Count < e.ColumnIndex) + return; + + DataGridViewCell cell = dgvMap.Rows[e.RowIndex].Cells[e.ColumnIndex]; + if (cell.Value == null || cell.Value.GetType() == typeof(System.DBNull)) + { + Label[] aLabels = { lbNormalLow, lbNormalHigh, lbHighLow, lbHighHigh, lbLowTemp }; + for (int i = 0; i < aLabels.Length; i++) + { + aLabels[i].Text = ""; + Theme.Apply(aLabels[i]); + } + } + else + { + string strSpring = ""; + string strTable = ""; + if ((string)dgvMap.Rows[0].HeaderCell.Value == "spring") + { + strSpring = (string)dgvMap.Rows[e.RowIndex].HeaderCell.Value; + strTable = dgvMap.Columns[e.ColumnIndex].HeaderText; + } + else + { + strTable = (string)dgvMap.Rows[e.RowIndex].HeaderCell.Value; + strSpring = dgvMap.Columns[e.ColumnIndex].HeaderText; + } + + List maxes = m_DataHandler.GetMaxes(strSpring, strTable); + + Label[] aLabels = { lbNormalLow, lbNormalHigh, lbHighLow, lbHighHigh, lbLowTemp }; + for (int i = 0; i < aLabels.Length; i++) + { + aLabels[i].Text = maxes[i].ToString("N0"); + Config.ANALYSIS.RISK Risk = Config.ANALYSIS.GetRisk(maxes[i]); + switch (Risk) + { + case Config.ANALYSIS.RISK.NO: + aLabels[i].BackColor = Theme.Green; + break; + case Config.ANALYSIS.RISK.POTENTIAL: + aLabels[i].BackColor = Theme.Yellow; + break; + case Config.ANALYSIS.RISK.HIGH: + aLabels[i].BackColor = Theme.Red; + break; + } + } + + detailPanel.Visible = true; + } + } } } diff --git a/PanelRadarGraph.Designer.cs b/PanelRadarGraph.Designer.cs index 3cf4062..024c505 100644 --- a/PanelRadarGraph.Designer.cs +++ b/PanelRadarGraph.Designer.cs @@ -41,15 +41,17 @@ this.lbSpring = new System.Windows.Forms.Label(); this.panel1 = new System.Windows.Forms.Panel(); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.rbAll = new System.Windows.Forms.RadioButton(); - this.rbNormalLow = new System.Windows.Forms.RadioButton(); - this.rbNormalHigh = new System.Windows.Forms.RadioButton(); - this.rbHighLow = new System.Windows.Forms.RadioButton(); - this.rbHighHigh = new System.Windows.Forms.RadioButton(); this.rbLowTemp = new System.Windows.Forms.RadioButton(); + this.rbHighHigh = new System.Windows.Forms.RadioButton(); + this.rbHighLow = new System.Windows.Forms.RadioButton(); + this.rbNormalHigh = new System.Windows.Forms.RadioButton(); + this.rbNormalLow = new System.Windows.Forms.RadioButton(); + this.rbAll = new System.Windows.Forms.RadioButton(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // chart @@ -66,7 +68,7 @@ this.chart.ChartAreas.Add(chartArea1); legend1.Name = "Legend1"; this.chart.Legends.Add(legend1); - this.chart.Location = new System.Drawing.Point(12, 90); + this.chart.Location = new System.Drawing.Point(3, 83); this.chart.Name = "chart"; series1.ChartArea = "ChartArea1"; series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Radar; @@ -113,7 +115,7 @@ this.chart.Series.Add(series4); this.chart.Series.Add(series5); this.chart.Series.Add(series6); - this.chart.Size = new System.Drawing.Size(791, 557); + this.chart.Size = new System.Drawing.Size(809, 573); this.chart.TabIndex = 0; this.chart.Text = "chart"; this.chart.MouseClick += new System.Windows.Forms.MouseEventHandler(this.chart_MouseClick); @@ -129,12 +131,11 @@ // // panel1 // - this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this.panel1.Controls.Add(this.lbSpring); - this.panel1.Location = new System.Drawing.Point(12, -1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(3, 3); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(791, 25); + this.panel1.Size = new System.Drawing.Size(809, 19); this.panel1.TabIndex = 2; // // groupBox1 @@ -146,73 +147,12 @@ this.groupBox1.Controls.Add(this.rbNormalHigh); this.groupBox1.Controls.Add(this.rbNormalLow); this.groupBox1.Controls.Add(this.rbAll); - this.groupBox1.Location = new System.Drawing.Point(12, 30); + this.groupBox1.Location = new System.Drawing.Point(3, 28); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(623, 54); + this.groupBox1.Size = new System.Drawing.Size(623, 49); this.groupBox1.TabIndex = 3; this.groupBox1.TabStop = false; // - // rbAll - // - this.rbAll.Appearance = System.Windows.Forms.Appearance.Button; - this.rbAll.Location = new System.Drawing.Point(6, 13); - this.rbAll.Name = "rbAll"; - this.rbAll.Size = new System.Drawing.Size(96, 34); - this.rbAll.TabIndex = 0; - this.rbAll.TabStop = true; - this.rbAll.Text = "All"; - this.rbAll.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.rbAll.UseVisualStyleBackColor = true; - this.rbAll.CheckedChanged += new System.EventHandler(this.rbAll_CheckedChanged); - // - // rbNormalLow - // - this.rbNormalLow.Appearance = System.Windows.Forms.Appearance.Button; - this.rbNormalLow.Location = new System.Drawing.Point(108, 13); - this.rbNormalLow.Name = "rbNormalLow"; - this.rbNormalLow.Size = new System.Drawing.Size(96, 34); - this.rbNormalLow.TabIndex = 0; - this.rbNormalLow.TabStop = true; - this.rbNormalLow.Text = "Normal Temp\r\nLow Humid"; - this.rbNormalLow.UseVisualStyleBackColor = true; - this.rbNormalLow.CheckedChanged += new System.EventHandler(this.rbAll_CheckedChanged); - // - // rbNormalHigh - // - this.rbNormalHigh.Appearance = System.Windows.Forms.Appearance.Button; - this.rbNormalHigh.Location = new System.Drawing.Point(210, 13); - this.rbNormalHigh.Name = "rbNormalHigh"; - this.rbNormalHigh.Size = new System.Drawing.Size(96, 34); - this.rbNormalHigh.TabIndex = 0; - this.rbNormalHigh.TabStop = true; - this.rbNormalHigh.Text = "Normal Temp\r\nHigh Humid"; - this.rbNormalHigh.UseVisualStyleBackColor = true; - this.rbNormalHigh.CheckedChanged += new System.EventHandler(this.rbAll_CheckedChanged); - // - // rbHighLow - // - this.rbHighLow.Appearance = System.Windows.Forms.Appearance.Button; - this.rbHighLow.Location = new System.Drawing.Point(312, 13); - this.rbHighLow.Name = "rbHighLow"; - this.rbHighLow.Size = new System.Drawing.Size(96, 34); - this.rbHighLow.TabIndex = 0; - this.rbHighLow.TabStop = true; - this.rbHighLow.Text = "High Temp\r\nLow Humid"; - this.rbHighLow.UseVisualStyleBackColor = true; - this.rbHighLow.CheckedChanged += new System.EventHandler(this.rbAll_CheckedChanged); - // - // rbHighHigh - // - this.rbHighHigh.Appearance = System.Windows.Forms.Appearance.Button; - this.rbHighHigh.Location = new System.Drawing.Point(414, 13); - this.rbHighHigh.Name = "rbHighHigh"; - this.rbHighHigh.Size = new System.Drawing.Size(96, 34); - this.rbHighHigh.TabIndex = 0; - this.rbHighHigh.TabStop = true; - this.rbHighHigh.Text = "High Temp\r\nHigh Humid"; - this.rbHighHigh.UseVisualStyleBackColor = true; - this.rbHighHigh.CheckedChanged += new System.EventHandler(this.rbAll_CheckedChanged); - // // rbLowTemp // this.rbLowTemp.Appearance = System.Windows.Forms.Appearance.Button; @@ -226,15 +166,91 @@ this.rbLowTemp.UseVisualStyleBackColor = true; this.rbLowTemp.CheckedChanged += new System.EventHandler(this.rbAll_CheckedChanged); // + // rbHighHigh + // + this.rbHighHigh.Appearance = System.Windows.Forms.Appearance.Button; + this.rbHighHigh.Location = new System.Drawing.Point(414, 13); + this.rbHighHigh.Name = "rbHighHigh"; + this.rbHighHigh.Size = new System.Drawing.Size(96, 34); + this.rbHighHigh.TabIndex = 0; + this.rbHighHigh.TabStop = true; + this.rbHighHigh.Text = "High Temp\r\nHigh Humid"; + this.rbHighHigh.UseVisualStyleBackColor = true; + this.rbHighHigh.CheckedChanged += new System.EventHandler(this.rbAll_CheckedChanged); + // + // rbHighLow + // + this.rbHighLow.Appearance = System.Windows.Forms.Appearance.Button; + this.rbHighLow.Location = new System.Drawing.Point(312, 13); + this.rbHighLow.Name = "rbHighLow"; + this.rbHighLow.Size = new System.Drawing.Size(96, 34); + this.rbHighLow.TabIndex = 0; + this.rbHighLow.TabStop = true; + this.rbHighLow.Text = "High Temp\r\nLow Humid"; + this.rbHighLow.UseVisualStyleBackColor = true; + this.rbHighLow.CheckedChanged += new System.EventHandler(this.rbAll_CheckedChanged); + // + // rbNormalHigh + // + this.rbNormalHigh.Appearance = System.Windows.Forms.Appearance.Button; + this.rbNormalHigh.Location = new System.Drawing.Point(210, 13); + this.rbNormalHigh.Name = "rbNormalHigh"; + this.rbNormalHigh.Size = new System.Drawing.Size(96, 34); + this.rbNormalHigh.TabIndex = 0; + this.rbNormalHigh.TabStop = true; + this.rbNormalHigh.Text = "Normal Temp\r\nHigh Humid"; + this.rbNormalHigh.UseVisualStyleBackColor = true; + this.rbNormalHigh.CheckedChanged += new System.EventHandler(this.rbAll_CheckedChanged); + // + // rbNormalLow + // + this.rbNormalLow.Appearance = System.Windows.Forms.Appearance.Button; + this.rbNormalLow.Location = new System.Drawing.Point(108, 13); + this.rbNormalLow.Name = "rbNormalLow"; + this.rbNormalLow.Size = new System.Drawing.Size(96, 34); + this.rbNormalLow.TabIndex = 0; + this.rbNormalLow.TabStop = true; + this.rbNormalLow.Text = "Normal Temp\r\nLow Humid"; + this.rbNormalLow.UseVisualStyleBackColor = true; + this.rbNormalLow.CheckedChanged += new System.EventHandler(this.rbAll_CheckedChanged); + // + // rbAll + // + this.rbAll.Appearance = System.Windows.Forms.Appearance.Button; + this.rbAll.Location = new System.Drawing.Point(6, 13); + this.rbAll.Name = "rbAll"; + this.rbAll.Size = new System.Drawing.Size(96, 34); + this.rbAll.TabIndex = 0; + this.rbAll.TabStop = true; + this.rbAll.Text = "All"; + this.rbAll.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.rbAll.UseVisualStyleBackColor = true; + this.rbAll.CheckedChanged += new System.EventHandler(this.rbAll_CheckedChanged); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 1; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.groupBox1, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.chart, 0, 2); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 55F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(815, 659); + this.tableLayoutPanel1.TabIndex = 4; + // // PanelRadarGraph // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(815, 659); this.ControlBox = false; - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.panel1); - this.Controls.Add(this.chart); + this.Controls.Add(this.tableLayoutPanel1); this.DockAreas = ((WeifenLuo.WinFormsUI.Docking.DockAreas)(((((WeifenLuo.WinFormsUI.Docking.DockAreas.DockLeft | WeifenLuo.WinFormsUI.Docking.DockAreas.DockRight) | WeifenLuo.WinFormsUI.Docking.DockAreas.DockTop) | WeifenLuo.WinFormsUI.Docking.DockAreas.DockBottom) @@ -250,6 +266,7 @@ this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); this.groupBox1.ResumeLayout(false); + this.tableLayoutPanel1.ResumeLayout(false); this.ResumeLayout(false); } @@ -266,5 +283,6 @@ private System.Windows.Forms.RadioButton rbNormalHigh; private System.Windows.Forms.RadioButton rbNormalLow; private System.Windows.Forms.RadioButton rbAll; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; } } \ No newline at end of file diff --git a/PanelRadarGraph.cs b/PanelRadarGraph.cs index cc1eedc..bca4da2 100644 --- a/PanelRadarGraph.cs +++ b/PanelRadarGraph.cs @@ -101,8 +101,8 @@ namespace friction public void UpdateGraph() { string strSpring = m_DataHandler.GetCurSpring(); - //if (m_CurSpring == strSpring) - // return; + if (m_CurSpring == strSpring) + return; lbSpring.Text = "Material Spring: " + strSpring; lbSpring.BackColor = Color.Gray; @@ -168,7 +168,14 @@ namespace friction private void rbAll_CheckedChanged(object sender, EventArgs e) { - if(rbAll.Checked == true) + if(sender.GetType() == typeof(RadioButton)) + { + RadioButton btn = sender as RadioButton; + if (btn.Checked == false) + return; + } + + if (rbAll.Checked == true) { m_TempRange = Config.TEMP_ALL; m_HumidRange = Config.HUMID_ALL; @@ -199,6 +206,7 @@ namespace friction m_HumidRange = Config.HUMID_ALL; } + m_CurSpring = ""; UpdateGraph(); } }