Files
friction/PanelRadarGraph.cs
mjjo53 a810a5b118 table, spring 전체 선택/해제
Potential S-Slip Risk -> Potential Stick-Slip Risk
Radar Graph Popup
2017-08-20 20:18:16 +09:00

250 lines
7.2 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using WeifenLuo.WinFormsUI.Docking;
namespace friction
{
public partial class PanelRadarGraph : DockContent
{
MainForm m_Owner = null;
DataHandler m_DataHandler = null;
string m_CurSpring = "";
List<string> m_UncheckedTable = null;
Config.RANGE m_TempRange = Config.TEMP_ALL;
Config.RANGE m_HumidRange = Config.HUMID_ALL;
bool m_bPopupDrag = false;
Point m_DragPos;
public PanelRadarGraph(MainForm owner, DataHandler data)
{
InitializeComponent();
m_Owner = owner;
m_DataHandler = data;
Theme.Apply(this);
Theme.Apply(rbAll);
Theme.Apply(rbNormalLow);
Theme.Apply(rbNormalHigh);
Theme.Apply(rbHighLow);
Theme.Apply(rbHighHigh);
Theme.Apply(rbLowTemp);
Theme.Apply(btnClose);
chart.ChartAreas[0].AxisY.Maximum = 10;
//chart.Series["SeriesHigh"].Color = Color.FromArgb(255, 200, 200, 200);
//chart.Series["SeriesPotential"].Color = Color.FromArgb(255, 180, 180, 180);
//chart.Series["SeriesNo"].Color = Color.FromArgb(255, 140, 140, 140);
chart.Series["SeriesHigh"].Color = Color.FromArgb(255, 255, 185, 185);
chart.Series["SeriesHigh"].Font = new Font(chart.Series["SeriesNo"].Font.FontFamily, 20.0f);
chart.Series["SeriesPotential"].Color = Color.FromArgb(255, 255, 255, 151);
chart.Series["SeriesPotential"].Font = new Font(chart.Series["SeriesNo"].Font.FontFamily, 20.0f);
chart.Series["SeriesNo"].Color = Color.FromArgb(255, 175, 255, 211);
chart.Series["SeriesNo"].Font = new Font(chart.Series["SeriesNo"].Font.FontFamily, 20.0f);
chart.Series["SeriesMax"].Color = Color.FromArgb(255, 192, 0, 0);
chart.Series["SeriesMax"]["RadarDrawingStyle"] = "Line";
chart.Series["SeriesMax"].BorderWidth = 3;
chart.Series["SeriesMax"].Font = new Font(chart.Series["SeriesNo"].Font.FontFamily, 20.0f);
chart.Series["SeriesAvg"].Color = Color.FromArgb(255, 229, 150, 9);
chart.Series["SeriesAvg"]["RadarDrawingStyle"] = "Line";
chart.Series["SeriesAvg"].BorderWidth = 3;
chart.Series["SeriesAvg"].Font = new Font(chart.Series["SeriesNo"].Font.FontFamily, 20.0f);
chart.Series["SeriesMin"].Color = Color.FromArgb(255, 79, 98, 40);
chart.Series["SeriesMin"]["RadarDrawingStyle"] = "Line";
chart.Series["SeriesMin"].BorderWidth = 3;
chart.Series["SeriesMin"].Font = new Font(chart.Series["SeriesNo"].Font.FontFamily, 20.0f);
chart.ChartAreas[0].AxisX.LabelStyle.Font = new Font(chart.ChartAreas[0].AxisX.LabelStyle.Font.FontFamily, 14.0f);
chart.ChartAreas[0].AxisX.MajorGrid.LineWidth = 1;
chart.ChartAreas[0].AxisY.MajorGrid.LineWidth = 1;
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.Black;
chart.ChartAreas[0].AxisX.MajorTickMark.Enabled = false;
chart.ChartAreas[0].AxisX.MinorTickMark.Enabled = false;
chart.ChartAreas[0].AxisY.MajorTickMark.Enabled = true;
chart.ChartAreas[0].AxisY.MajorTickMark.LineWidth = 1;
chart.ChartAreas[0].AxisY.MajorTickMark.LineColor = Color.FromArgb(150, 0, 0, 0);
chart.ChartAreas[0].AxisY.MinorTickMark.Enabled = false;
chart.ChartAreas[0].AxisX.LabelAutoFitStyle = LabelAutoFitStyles.DecreaseFont;
chart.ChartAreas[0].AxisX.IsLabelAutoFit = true;
foreach (var series in chart.Series)
series["AreaDrawingStyle"] = "Polygon";
panel1.BackColor = Color.Gray;
}
public void Reset()
{
m_CurSpring = "";
}
public void UpdateGraph()
{
panelPopup.Visible = false;
string strSpring = m_DataHandler.GetCurSpring();
List<string> uncheckedTable = Config.GetInstance().GetTableUnchecked();
if (strSpring == m_CurSpring && uncheckedTable == m_UncheckedTable)
return;
lbSpring.Text = "Material Spring: " + strSpring;
lbSpring.BackColor = Color.Gray;
lbSpring.ForeColor = Color.Black;
foreach (var series in chart.Series)
series.Points.Clear();
List<DataHandler.RADAR_CHART> graphData = m_DataHandler.GetAvgAll(strSpring, m_TempRange, m_HumidRange);
List<string> xValues = new List<string>();
List<float> yValues = new List<float>();
int iTableCnt = 0;
foreach(var data in graphData)
{
if (uncheckedTable.Contains(data.m_strTable) == true)
continue;
chart.Series["SeriesMax"].Points.AddXY(data.m_strTable, data.m_fMax);
chart.Series["SeriesAvg"].Points.AddXY(data.m_strTable, data.m_fAvg);
chart.Series["SeriesMin"].Points.AddXY(data.m_strTable, data.m_fMin);
chart.Series["SeriesHigh"].Points.AddXY(data.m_strTable, (int)Config.ANALYSIS.RISK.HIGH);
chart.Series["SeriesPotential"].Points.AddXY(data.m_strTable, (int)Config.ANALYSIS.RISK.POTENTIAL);
chart.Series["SeriesNo"].Points.AddXY(data.m_strTable, (int)Config.ANALYSIS.RISK.NO);
iTableCnt++;
}
m_CurSpring = strSpring;
if (iTableCnt < 3)
{
panelPopup.Left = (panel2.Width - panelPopup.Width) / 2;
panelPopup.Top = (panel2.Height - panelPopup.Height) / 2;
panelPopup.Visible = true;
}
}
public Bitmap CopyChart()
{
MemoryStream ms = new MemoryStream();
chart.SaveImage(ms, ChartImageFormat.Bmp);
Bitmap bm = new Bitmap(ms);
return bm;
}
private void chart_MouseClick(object sender, MouseEventArgs e)
{
HitTestResult result = chart.HitTest(e.X, e.Y);
if(result.ChartElementType == ChartElementType.AxisLabels &&
result.Object != null)
{
string strTable = (string)result.Object;
m_Owner.OnRadarSelectTable(strTable);
}
}
private void rbAll_CheckedChanged(object sender, EventArgs e)
{
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;
}
else if (rbNormalLow.Checked == true)
{
m_TempRange = Config.TEMP_NORMAL;
m_HumidRange = Config.HUMID_LOW;
}
else if (rbNormalHigh.Checked == true)
{
m_TempRange = Config.TEMP_NORMAL;
m_HumidRange = Config.HUMID_HIGH;
}
else if (rbHighLow.Checked == true)
{
m_TempRange = Config.TEMP_HIGH;
m_HumidRange = Config.HUMID_LOW;
}
else if (rbHighHigh.Checked == true)
{
m_TempRange = Config.TEMP_HIGH;
m_HumidRange = Config.HUMID_HIGH;
}
else if (rbLowTemp.Checked == true)
{
m_TempRange = Config.TEMP_LOW;
m_HumidRange = Config.HUMID_ALL;
}
m_CurSpring = "";
UpdateGraph();
}
private void PanelRadarGraph_Enter(object sender, EventArgs e)
{
m_Owner.OnRadarGraphActivated();
}
private void btnClose_Click(object sender, EventArgs e)
{
panelPopup.Visible = false;
}
private void panelPopup_MouseDown(object sender, MouseEventArgs e)
{
m_bPopupDrag = true;
m_DragPos = e.Location;
panelPopup.Capture = true;
}
private void panelPopup_MouseUp(object sender, MouseEventArgs e)
{
m_bPopupDrag = false;
panelPopup.Capture = false;
}
private void panelPopup_MouseMove(object sender, MouseEventArgs e)
{
if (m_bPopupDrag == true)
{
panelPopup.Left = e.X + panelPopup.Left - m_DragPos.X;
panelPopup.Top = e.Y + panelPopup.Top - m_DragPos.Y;
}
}
}
}