- datagridview cell을 계속 그리는 문제 해결 - 5가지 상태창 표시 - layout 수정 RadarGraph 수정 - 팝업창 두번씩 뜨지 않도록 수정 - layout 수정
385 lines
10 KiB
C#
385 lines
10 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using WeifenLuo.WinFormsUI.Docking;
|
|
|
|
namespace friction
|
|
{
|
|
public partial class MainForm : Form
|
|
{
|
|
string m_DBFileName = "";
|
|
DataHandler m_DataHandler = new DataHandler();
|
|
PanelMaterial m_MaterialPanel = null;
|
|
PanelResult m_ResultPanel = null;
|
|
PanelAnalysis m_AnalysisPanel = null;
|
|
PanelCompatibility m_CompatibilityPanel = null;
|
|
PanelRadarGraph m_RadarGraphPanel = null;
|
|
PanelTrendGraph m_TrendGraphPanel = null;
|
|
|
|
Report m_Report = null;
|
|
|
|
public MainForm()
|
|
{
|
|
InitializeComponent();
|
|
|
|
dockPanel.Theme = new VS2015DarkTheme();
|
|
m_MaterialPanel = new PanelMaterial(this);
|
|
m_ResultPanel = new PanelResult(this);
|
|
m_AnalysisPanel = new PanelAnalysis(this);
|
|
m_CompatibilityPanel = new PanelCompatibility(this, m_DataHandler);
|
|
m_RadarGraphPanel = new PanelRadarGraph(this, m_DataHandler);
|
|
m_TrendGraphPanel = new PanelTrendGraph(this, m_DataHandler);
|
|
|
|
Theme.Apply(this);
|
|
Theme.Apply(menuStrip);
|
|
Theme.Apply(toolStripMain);
|
|
Theme.Apply(statusStrip);
|
|
|
|
dockPanel.Font = new Font(dockPanel.Font.FontFamily, 12.0f);
|
|
|
|
Config.Init();
|
|
UpdateRecentFile();
|
|
if(Config.OPTION.WindowBound.Width > 0)
|
|
Bounds = Config.OPTION.WindowBound;
|
|
}
|
|
|
|
void UpdateRecentFile()
|
|
{
|
|
recentToolStripMenuItem.DropDownItems.Clear();
|
|
|
|
foreach (string file in Enumerable.Reverse(Config.OPTION.m_RecentList))
|
|
{
|
|
ToolStripItem item = recentToolStripMenuItem.DropDownItems.Add(file);
|
|
item.BackColor = Theme.Backcolor;
|
|
item.ForeColor = Theme.Forecolor;
|
|
item.Click += RecentToolStripMenuItem_Click;
|
|
}
|
|
}
|
|
|
|
private void RecentToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
string strFile = ((ToolStripItem)sender).Text;
|
|
OpenDB(strFile);
|
|
}
|
|
|
|
private void OpenDB(string strFile=null)
|
|
{
|
|
if (strFile == null)
|
|
{
|
|
OpenFileDialog ofd = new OpenFileDialog();
|
|
ofd.Filter = "엑셀 파일 (*.xlsx)|*.xlsx|엑셀 파일 (*.xls)|*.xls|전체|*";
|
|
DialogResult result = ofd.ShowDialog();
|
|
if (result == DialogResult.OK)
|
|
m_DBFileName = ofd.FileName;
|
|
else
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
m_DBFileName = strFile;
|
|
}
|
|
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
|
|
m_DataHandler.LoadData(m_DBFileName);
|
|
|
|
m_MaterialPanel.UpdateData(m_DataHandler);
|
|
OpenPanel(m_MaterialPanel);
|
|
|
|
m_ResultPanel.UpdateData(m_DataHandler);
|
|
OpenPanel(m_ResultPanel);
|
|
|
|
m_AnalysisPanel.Reset();
|
|
m_AnalysisPanel.UpdateData(m_DataHandler);
|
|
OpenPanel(m_AnalysisPanel);
|
|
|
|
m_RadarGraphPanel.UpdateGraph();
|
|
OpenPanel(m_RadarGraphPanel);
|
|
|
|
m_TrendGraphPanel.UpdateGraph();
|
|
OpenPanel(m_TrendGraphPanel);
|
|
|
|
m_CompatibilityPanel.UpdateData();
|
|
OpenPanel(m_CompatibilityPanel);
|
|
|
|
toolStripStatusLabel.Text = m_DBFileName;
|
|
|
|
Config.OPTION.AddRecentFile(m_DBFileName);
|
|
UpdateRecentFile();
|
|
|
|
Cursor.Current = Cursors.Default;
|
|
}
|
|
|
|
public void OpenPanel(DockContent panel)
|
|
{
|
|
if (panel.Visible == false)
|
|
panel.Show(dockPanel);
|
|
if (panel.IsHidden == true)
|
|
panel.IsHidden = false;
|
|
|
|
panel.ShowIcon = true;
|
|
|
|
if (panel.DockState == DockState.DockTopAutoHide ||
|
|
panel.DockState == DockState.DockBottomAutoHide ||
|
|
panel.DockState == DockState.DockLeftAutoHide ||
|
|
panel.DockState == DockState.DockRightAutoHide)
|
|
{
|
|
dockPanel.ActiveAutoHideContent = panel;
|
|
}
|
|
}
|
|
|
|
#region Events from menu
|
|
private void openDBToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
OpenDB();
|
|
}
|
|
|
|
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
Application.Exit();
|
|
}
|
|
|
|
private void resultTableToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
OpenPanel(m_ResultPanel);
|
|
}
|
|
|
|
private void analysisTableToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
OpenPanel(m_AnalysisPanel);
|
|
}
|
|
|
|
private void materialCompatibilityMapToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
OpenPanel(m_CompatibilityPanel);
|
|
m_CompatibilityPanel.UpdateData();
|
|
}
|
|
|
|
private void radarGraphToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
if (m_DataHandler.GetCurTable() != "All")
|
|
OnApplyData(this, m_DataHandler.GetCurSpring(), "All");
|
|
|
|
OpenPanel(m_RadarGraphPanel);
|
|
m_RadarGraphPanel.UpdateGraph();
|
|
}
|
|
|
|
private void trendGraphToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
if (m_DataHandler.GetCurTable() == "All")
|
|
OnApplyData(this, m_DataHandler.GetCurSpring(), m_DataHandler.GetTableList()[0]);
|
|
|
|
OpenPanel(m_TrendGraphPanel);
|
|
m_TrendGraphPanel.UpdateGraph();
|
|
}
|
|
|
|
private void allToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
SaveFileDialog sfd = new SaveFileDialog();
|
|
sfd.Filter = "엑셀 파일 (*.xlsx)|*.xlsx|엑셀 파일 (*.xls)|*.xls|전체|*";
|
|
DialogResult result = sfd.ShowDialog();
|
|
string strFilePath = "";
|
|
if (result == DialogResult.OK)
|
|
strFilePath = sfd.FileName;
|
|
else
|
|
return;
|
|
|
|
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
|
|
m_Report = new Report();
|
|
m_Report.FilePath = strFilePath;
|
|
m_Report.MaterialSpring = m_DataHandler.GetCurSpring();
|
|
m_Report.MaterialTable = m_DataHandler.GetCurTable();
|
|
m_Report.AnalysisData = m_AnalysisPanel.GetData();
|
|
object[] CompData = m_CompatibilityPanel.GetData();
|
|
m_Report.CompatibilityData = (DataTable)CompData[0];
|
|
m_Report.CompatibilityColumns = (List<string>)CompData[1];
|
|
m_Report.CompatibilityRows = (List<string>)CompData[2];
|
|
|
|
m_Report.RadarChart = m_RadarGraphPanel.CopyChart();
|
|
|
|
if(m_DataHandler.GetCurTable() != "" && m_DataHandler.GetCurTable() != "All")
|
|
{
|
|
if (m_DataHandler.GetCurTable() == "All")
|
|
OnApplyData(this, m_DataHandler.GetCurSpring(), m_DataHandler.GetTableList()[0]);
|
|
|
|
OpenPanel(m_TrendGraphPanel);
|
|
m_TrendGraphPanel.CopyChart(PanelTrendGraph.GRAPH_TYPE.HUMIDITY);
|
|
}
|
|
else
|
|
{
|
|
m_Report.Export();
|
|
m_Report = null;
|
|
Cursor.Current = Cursors.Default;
|
|
}
|
|
}
|
|
|
|
public void OnChartUpdate(Bitmap bm, PanelTrendGraph.GRAPH_TYPE Type)
|
|
{
|
|
switch(Type)
|
|
{
|
|
case PanelTrendGraph.GRAPH_TYPE.HUMIDITY:
|
|
m_Report.TrendChartByHumidity = bm;
|
|
m_TrendGraphPanel.CopyChart(PanelTrendGraph.GRAPH_TYPE.TEMPERATURE);
|
|
break;
|
|
|
|
case PanelTrendGraph.GRAPH_TYPE.TEMPERATURE:
|
|
m_Report.TrendChartByTemperature = bm;
|
|
m_TrendGraphPanel.CopyChart(PanelTrendGraph.GRAPH_TYPE.FORCE);
|
|
break;
|
|
|
|
case PanelTrendGraph.GRAPH_TYPE.FORCE:
|
|
m_Report.TrendChartByForce = bm;
|
|
m_TrendGraphPanel.CopyChart(PanelTrendGraph.GRAPH_TYPE.VELOCITY);
|
|
break;
|
|
|
|
case PanelTrendGraph.GRAPH_TYPE.VELOCITY:
|
|
m_Report.TrendChartByVelocity = bm;
|
|
m_Report.Export();
|
|
m_Report = null;
|
|
Cursor.Current = Cursors.Default;
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
AboutBox aboutWindow = new AboutBox();
|
|
aboutWindow.ShowDialog();
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region Events from toolbox
|
|
private void toolStripButtonOpen_Click(object sender, EventArgs e)
|
|
{
|
|
OpenDB();
|
|
}
|
|
|
|
private void toolStripButtonMaterial_Click(object sender, EventArgs e)
|
|
{
|
|
OpenPanel(m_MaterialPanel);
|
|
}
|
|
|
|
private void toolStripButtonResult_Click(object sender, EventArgs e)
|
|
{
|
|
OpenPanel(m_ResultPanel);
|
|
}
|
|
|
|
private void toolStripButtonAnalysis_Click(object sender, EventArgs e)
|
|
{
|
|
OpenPanel(m_AnalysisPanel);
|
|
}
|
|
|
|
private void toolStripButtonMap_Click(object sender, EventArgs e)
|
|
{
|
|
OpenPanel(m_CompatibilityPanel);
|
|
m_CompatibilityPanel.UpdateData();
|
|
}
|
|
|
|
private void toolStripButtonRadarGraph_Click(object sender, EventArgs e)
|
|
{
|
|
if (m_DataHandler.GetCurTable() != "All")
|
|
OnApplyData(this, m_DataHandler.GetCurSpring(), "All");
|
|
|
|
OpenPanel(m_RadarGraphPanel);
|
|
m_RadarGraphPanel.UpdateGraph();
|
|
}
|
|
|
|
private void toolStripButtonTrendGraph_Click(object sender, EventArgs e)
|
|
{
|
|
if (m_DataHandler.GetCurTable() == "All")
|
|
{
|
|
string strSpring = m_DataHandler.GetCurSpring();
|
|
List<string> tableList = m_DataHandler.GetTableList();
|
|
|
|
if(tableList.Count > 0)
|
|
OnApplyData(this, strSpring, tableList[0]);
|
|
}
|
|
|
|
OpenPanel(m_TrendGraphPanel);
|
|
m_TrendGraphPanel.UpdateGraph();
|
|
}
|
|
#endregion
|
|
|
|
#region Events from panels
|
|
public void OnApplyData(object sender, string strSpring, string strTable)
|
|
{
|
|
Console.WriteLine("[MainForm::OnApply] start");
|
|
|
|
m_DataHandler.SetSelectedMaterial(strSpring, strTable);
|
|
|
|
if (strTable == "All")
|
|
{
|
|
if (m_RadarGraphPanel != null)
|
|
m_RadarGraphPanel.UpdateGraph();
|
|
if (m_TrendGraphPanel != null)
|
|
m_TrendGraphPanel.UpdateGraph();
|
|
}
|
|
else
|
|
{
|
|
if (m_TrendGraphPanel != null)
|
|
m_TrendGraphPanel.UpdateGraph();
|
|
}
|
|
|
|
if (sender != m_MaterialPanel)
|
|
m_MaterialPanel.SelectTable(strTable);
|
|
|
|
m_AnalysisPanel.UpdateData(m_DataHandler);
|
|
}
|
|
|
|
public void OnRadarSelectTable(string strTable)
|
|
{
|
|
if (m_AnalysisPanel != null)
|
|
m_AnalysisPanel.SelectRow(strTable);
|
|
OpenPanel(m_AnalysisPanel);
|
|
}
|
|
|
|
public void OnTrendSelectByHumidity(string strSpring, string strTable, float fHumidity, float fRPN)
|
|
{
|
|
if (m_ResultPanel != null)
|
|
m_ResultPanel.SelectRowByHumidity(strSpring, strTable, fHumidity, fRPN);
|
|
OpenPanel(m_ResultPanel);
|
|
}
|
|
|
|
public void OnTrendSelectByTemperature(string strSpring, string strTable, float fTemperature, float fRPN)
|
|
{
|
|
if (m_ResultPanel != null)
|
|
m_ResultPanel.SelectRowByTemperature(strSpring, strTable, fTemperature, fRPN);
|
|
OpenPanel(m_ResultPanel);
|
|
}
|
|
|
|
public void OnTrendSelectByForce(string strSpring, string strTable, float fTemperature, float fRPN)
|
|
{
|
|
if (m_ResultPanel != null)
|
|
m_ResultPanel.SelectRowByForce(strSpring, strTable, fTemperature, fRPN);
|
|
OpenPanel(m_ResultPanel);
|
|
}
|
|
|
|
public void OnTrendSelectByVelocity(string strSpring, string strTable, float fTemperature, float fRPN)
|
|
{
|
|
if (m_ResultPanel != null)
|
|
m_ResultPanel.SelectRowByVelocity(strSpring, strTable, fTemperature, fRPN);
|
|
OpenPanel(m_ResultPanel);
|
|
}
|
|
#endregion
|
|
|
|
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
Config.OPTION.WindowBound = this.Bounds;
|
|
Config.OPTION.CheckedColumns = m_ResultPanel.GetCheckedColumns();
|
|
Config.OPTION.UncheckedColumns = m_ResultPanel.GetUncheckedColumns();
|
|
Config.Save();
|
|
}
|
|
}
|
|
}
|