237 lines
6.0 KiB
C#
237 lines
6.0 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;
|
|
PanelRadarGraph m_RadarGraphPanel = null;
|
|
PanelTrendGraph m_TrendGraphPanel = null;
|
|
|
|
public MainForm()
|
|
{
|
|
InitializeComponent();
|
|
|
|
dockPanel.Theme = new VS2015DarkTheme();
|
|
m_MaterialPanel = new PanelMaterial(this);
|
|
m_ResultPanel = new PanelResult(this);
|
|
m_AnalysisPanel = new PanelAnalysis(this);
|
|
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);
|
|
|
|
Config.Init();
|
|
UpdateRecentFile();
|
|
}
|
|
|
|
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
|
|
{
|
|
m_DBFileName = strFile;
|
|
}
|
|
|
|
|
|
m_DataHandler.LoadData(m_DBFileName);
|
|
|
|
toolStripButtonTrendGraph.Enabled = false;
|
|
toolStripButtonRadarGraph.Enabled = true;
|
|
|
|
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);
|
|
|
|
toolStripStatusLabel.Text = m_DBFileName;
|
|
|
|
Config.OPTION.AddRecentFile(m_DBFileName);
|
|
UpdateRecentFile();
|
|
}
|
|
|
|
private void OpenPanel(DockContent panel)
|
|
{
|
|
if (panel.Visible == false)
|
|
panel.Show(dockPanel);
|
|
if (panel.IsHidden == true)
|
|
panel.IsHidden = false;
|
|
|
|
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)
|
|
{
|
|
|
|
}
|
|
|
|
private void resultTableToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
OpenPanel(m_ResultPanel);
|
|
}
|
|
|
|
private void analysisTableToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
OpenPanel(m_AnalysisPanel);
|
|
}
|
|
|
|
private void radarGraphToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
OpenPanel(m_RadarGraphPanel);
|
|
m_RadarGraphPanel.UpdateGraph();
|
|
}
|
|
|
|
private void trendGraphToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
OpenPanel(m_TrendGraphPanel);
|
|
m_TrendGraphPanel.UpdateGraph();
|
|
}
|
|
#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 toolStripButtonRadarGraph_Click(object sender, EventArgs e)
|
|
{
|
|
OpenPanel(m_RadarGraphPanel);
|
|
m_RadarGraphPanel.UpdateGraph();
|
|
}
|
|
|
|
private void toolStripButtonTrendGraph_Click(object sender, EventArgs e)
|
|
{
|
|
OpenPanel(m_TrendGraphPanel);
|
|
m_TrendGraphPanel.UpdateGraph();
|
|
}
|
|
#endregion
|
|
|
|
#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 != 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 != null)
|
|
m_TrendGraphPanel.UpdateGraph();
|
|
}
|
|
|
|
m_AnalysisPanel.UpdateData(m_DataHandler);
|
|
|
|
Console.WriteLine(string.Format("[end ] MainForm::OnApplyData({0}, {1})", strSpring, strTable));
|
|
}
|
|
|
|
public void OnRadarSelectTable(string strTable)
|
|
{
|
|
if (m_AnalysisPanel != null)
|
|
m_AnalysisPanel.SelectRow(strTable);
|
|
}
|
|
|
|
public void OnTrendSelectByHumidity(string strSpring, string strTable, float fHumidity, float fRPN)
|
|
{
|
|
if (m_ResultPanel != null)
|
|
m_ResultPanel.SelectRowByHumidity(strSpring, strTable, fHumidity, fRPN);
|
|
}
|
|
|
|
public void OnTrendSelectByTemperature(string strSpring, string strTable, float fTemperature, float fRPN)
|
|
{
|
|
if (m_ResultPanel != null)
|
|
m_ResultPanel.SelectRowByTemperature(strSpring, strTable, fTemperature, fRPN);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|