- 리포트 기능 추가(Trend Graph 제외)

- AboutBox 추가
This commit is contained in:
2017-06-24 14:43:27 +09:00
parent 4503bfc7a5
commit 334c131e6e
12 changed files with 6691 additions and 22 deletions

109
AboutBox.Designer.cs generated Normal file
View File

@@ -0,0 +1,109 @@
namespace friction
{
partial class AboutBox
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutBox));
this.label1 = new System.Windows.Forms.Label();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(3, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(160, 12);
this.label1.TabIndex = 0;
this.label1.Text = "Material Stick-slip Analysis";
//
// 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.label1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.label3, 0, 2);
this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 12);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 3;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(233, 64);
this.tableLayoutPanel1.TabIndex = 1;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(3, 16);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(48, 12);
this.label2.TabIndex = 0;
this.label2.Text = "Ver. 1.0";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(3, 32);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(212, 12);
this.label3.TabIndex = 0;
this.label3.Text = "Copyright © 2016, General Utility Ltd.";
//
// AboutBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(255, 77);
this.Controls.Add(this.tableLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "AboutBox";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "About";
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
}
}

20
AboutBox.cs Normal file
View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace friction
{
public partial class AboutBox : Form
{
public AboutBox()
{
InitializeComponent();
}
}
}

6293
AboutBox.resx Normal file

File diff suppressed because it is too large Load Diff

3
MainForm.Designer.cs generated
View File

@@ -286,8 +286,9 @@
// allToolStripMenuItem
//
this.allToolStripMenuItem.Name = "allToolStripMenuItem";
this.allToolStripMenuItem.Size = new System.Drawing.Size(88, 22);
this.allToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.allToolStripMenuItem.Text = "All";
this.allToolStripMenuItem.Click += new System.EventHandler(this.allToolStripMenuItem_Click);
//
// aToolStripMenuItem
//

View File

@@ -23,6 +23,8 @@ namespace friction
PanelRadarGraph m_RadarGraphPanel = null;
PanelTrendGraph m_TrendGraphPanel = null;
Report m_Report = null;
public MainForm()
{
InitializeComponent();
@@ -126,7 +128,7 @@ namespace friction
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void resultTableToolStripMenuItem_Click(object sender, EventArgs e)
@@ -157,10 +159,64 @@ namespace friction
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;
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();
m_Report.RadarChart = m_RadarGraphPanel.CopyChart();
m_Report.Export();
//OpenPanel(m_TrendGraphPanel);
//m_TrendGraphPanel.CopyChart(PanelTrendGraph.GRAPH_TYPE.HUMIDITY);
}
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;
break;
}
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
//AboutWindow aboutWindow = new AboutWindow();
//aboutWindow.Show();
AboutBox aboutWindow = new AboutBox();
aboutWindow.ShowDialog();
}
#endregion
@@ -209,6 +265,8 @@ namespace friction
#region Events from panels
public void OnApplyData(string strSpring, string strTable)
{
Console.WriteLine("[MainForm::OnApply] start");
m_DataHandler.SetSelectedMaterial(strSpring, strTable);
if (strTable == "All")
@@ -231,6 +289,8 @@ namespace friction
}
m_AnalysisPanel.UpdateData(m_DataHandler);
Console.WriteLine("[MainForm::OnApply] end");
}
public void OnRadarSelectTable(string strTable)

View File

@@ -145,5 +145,25 @@ namespace friction
}
}
}
public DataTable GetData()
{
var dt = new DataTable();
foreach (DataGridViewColumn column in dgvAnalysis.Columns)
{
if (column.Visible)
dt.Columns.Add(column.HeaderText);
}
object[] cellValues = new object[dgvAnalysis.Columns.Count];
foreach (DataGridViewRow row in dgvAnalysis.Rows)
{
for (int i = 0; i < row.Cells.Count; i++)
cellValues[i] = row.Cells[i].Value;
dt.Rows.Add(cellValues);
}
return dt;
}
}
}

View File

@@ -37,6 +37,7 @@
System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.chart = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.lbSpring = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
this.SuspendLayout();
//
@@ -54,7 +55,7 @@
this.chart.ChartAreas.Add(chartArea1);
legend1.Name = "Legend1";
this.chart.Legends.Add(legend1);
this.chart.Location = new System.Drawing.Point(12, 12);
this.chart.Location = new System.Drawing.Point(12, 27);
this.chart.Name = "chart";
series1.ChartArea = "ChartArea1";
series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Radar;
@@ -101,17 +102,26 @@
this.chart.Series.Add(series4);
this.chart.Series.Add(series5);
this.chart.Series.Add(series6);
this.chart.Size = new System.Drawing.Size(791, 635);
this.chart.Size = new System.Drawing.Size(791, 620);
this.chart.TabIndex = 0;
this.chart.Text = "chart";
this.chart.MouseClick += new System.Windows.Forms.MouseEventHandler(this.chart_MouseClick);
//
// lbSpring
//
this.lbSpring.AutoSize = true;
this.lbSpring.Location = new System.Drawing.Point(12, 12);
this.lbSpring.Name = "lbSpring";
this.lbSpring.Size = new System.Drawing.Size(0, 12);
this.lbSpring.TabIndex = 1;
//
// 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.lbSpring);
this.Controls.Add(this.chart);
this.HideOnClose = true;
this.Name = "PanelRadarGraph";
@@ -120,11 +130,13 @@
this.Text = "Radar Graph";
((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.DataVisualization.Charting.Chart chart;
private System.Windows.Forms.Label lbSpring;
}
}

View File

@@ -4,6 +4,7 @@ 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;
@@ -27,6 +28,9 @@ namespace friction
m_Owner = owner;
m_DataHandler = data;
Theme.Apply(this);
chart.ChartAreas[0].AxisY.Maximum = 10;
chart.Series["SeriesHigh"].Color = Color.FromArgb(255, 200, 200, 200);
@@ -62,6 +66,10 @@ namespace friction
if (m_CurSpring == strSpring)
return;
lbSpring.Text = "Material Spring: " + strSpring;
lbSpring.BackColor = Color.Transparent;
lbSpring.ForeColor = Color.Orange;
foreach (var series in chart.Series)
series.Points.Clear();
@@ -81,10 +89,17 @@ namespace friction
chart.Series["SeriesNo"].Points.AddXY(data.m_strTable, (int)Config.ANALYSIS.RISK.NO);
}
m_CurSpring = strSpring;
}
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);

View File

@@ -32,8 +32,8 @@
this.rbHumidity = new System.Windows.Forms.RadioButton();
this.rbTemp = new System.Windows.Forms.RadioButton();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.rbForce = new System.Windows.Forms.RadioButton();
this.rbVelocity = new System.Windows.Forms.RadioButton();
this.rbForce = new System.Windows.Forms.RadioButton();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
@@ -47,6 +47,7 @@
this.trendChart.Size = new System.Drawing.Size(742, 603);
this.trendChart.TabIndex = 0;
this.trendChart.Text = "trendChart";
this.trendChart.UpdaterTick += new LiveCharts.Events.UpdaterTickHandler(this.trendChart_UpdaterTick);
//
// rbHumidity
//
@@ -90,19 +91,6 @@
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Data";
//
// rbForce
//
this.rbForce.Appearance = System.Windows.Forms.Appearance.Button;
this.rbForce.AutoSize = true;
this.rbForce.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.rbForce.Location = new System.Drawing.Point(171, 20);
this.rbForce.Name = "rbForce";
this.rbForce.Size = new System.Drawing.Size(49, 24);
this.rbForce.TabIndex = 1;
this.rbForce.Text = "Force";
this.rbForce.UseVisualStyleBackColor = true;
this.rbForce.CheckedChanged += new System.EventHandler(this.rbForce_CheckedChanged);
//
// rbVelocity
//
this.rbVelocity.Appearance = System.Windows.Forms.Appearance.Button;
@@ -116,6 +104,19 @@
this.rbVelocity.UseVisualStyleBackColor = true;
this.rbVelocity.CheckedChanged += new System.EventHandler(this.rbVelocity_CheckedChanged);
//
// rbForce
//
this.rbForce.Appearance = System.Windows.Forms.Appearance.Button;
this.rbForce.AutoSize = true;
this.rbForce.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.rbForce.Location = new System.Drawing.Point(171, 20);
this.rbForce.Name = "rbForce";
this.rbForce.Size = new System.Drawing.Size(49, 24);
this.rbForce.TabIndex = 1;
this.rbForce.Text = "Force";
this.rbForce.UseVisualStyleBackColor = true;
this.rbForce.CheckedChanged += new System.EventHandler(this.rbForce_CheckedChanged);
//
// PanelTrendGraph
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);

View File

@@ -13,6 +13,7 @@ using LiveCharts.Wpf;
using LiveCharts.WinForms;
using LiveCharts.Defaults;
using System.Windows.Media;
using System.Threading;
namespace friction
{
@@ -35,6 +36,9 @@ namespace friction
string m_CurTable = "";
GRAPH_TYPE m_GraphType = GRAPH_TYPE.NONE;
// for report
bool m_bReport = false;
public PanelTrendGraph(MainForm owner, DataHandler data)
{
InitializeComponent();
@@ -382,7 +386,9 @@ namespace friction
public void UpdateGraph(GRAPH_TYPE Type=GRAPH_TYPE.NONE)
{
if(Type == GRAPH_TYPE.NONE)
Console.WriteLine("[TrendGraph::UpdateGraph] start");
if (Type == GRAPH_TYPE.NONE)
{
if (rbHumidity.Checked == true)
UpdateGraph(GRAPH_TYPE.HUMIDITY);
@@ -392,6 +398,8 @@ namespace friction
UpdateGraph(GRAPH_TYPE.FORCE);
else if (rbVelocity.Checked == true)
UpdateGraph(GRAPH_TYPE.VELOCITY);
Console.WriteLine("[TrendGraph::UpdateGraph] end");
return;
}
@@ -420,6 +428,8 @@ namespace friction
m_CurSpring = strSpring;
m_CurTable = strTable;
m_GraphType = Type;
Console.WriteLine("[TrendGraph::UpdateGraph] end");
}
private void rbHumidity_CheckedChanged(object sender, EventArgs e)
@@ -441,5 +451,28 @@ namespace friction
{
UpdateGraph(GRAPH_TYPE.VELOCITY);
}
public void CopyChart(GRAPH_TYPE Type)
{
m_bReport = true;
trendChart.DisableAnimations = true;
UpdateGraph(Type);
}
private void trendChart_UpdaterTick(object sender)
{
if(m_bReport == true)
{
Thread.Sleep(1500);
m_bReport = false;
Bitmap bm = new Bitmap(Width, Height);
DrawToBitmap(bm, new Rectangle(0, 0, Width, Height));
m_Owner.OnChartUpdate(bm, m_GraphType);
}
Console.WriteLine("chart updated");
}
}
}

95
Report.cs Normal file
View File

@@ -0,0 +1,95 @@
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace friction
{
public class Report
{
public string FilePath { set; get; }
public string MaterialSpring { set; get; }
public string MaterialTable { set; get; }
public DataTable AnalysisData { set; get; }
public Bitmap RadarChart { set; get; }
public Bitmap TrendChartByHumidity { set; get; }
public Bitmap TrendChartByTemperature { set; get; }
public Bitmap TrendChartByForce { set; get; }
public Bitmap TrendChartByVelocity { set; get; }
public void Export()
{
using (ExcelPackage package = new ExcelPackage())
{
if (package.Workbook.Worksheets.Count < 1)
package.Workbook.Worksheets.Add("Report");
ExcelWorksheet Sheet = package.Workbook.Worksheets[1];
int iRow = 2;
int iCol = 2;
Sheet.Cells[iRow, iCol].Value = "Material Spring: " + MaterialSpring;
Sheet.Cells[iRow, iCol].Style.Font.Bold = true;
iRow += 1;
foreach(DataColumn column in AnalysisData.Columns)
{
Sheet.Cells[iRow, iCol].Value = column.ColumnName;
iCol++;
}
iRow++;
iCol = 2;
int iTableRowStart = iRow-1;
int iTableColStart = iCol;
foreach(DataRow row in AnalysisData.Rows)
{
iCol = 2;
for (int i = 0; i < AnalysisData.Columns.Count; i++)
{
Sheet.Cells[iRow, iCol].Value = row[i];
iCol++;
}
iRow++;
}
Sheet.Cells[iTableRowStart, iTableColStart, iTableRowStart, iCol-1].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
Sheet.Cells[iTableRowStart, iTableColStart, iRow-1, iTableColStart].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
Sheet.Cells[iTableRowStart, iTableColStart, iRow-1, iCol-1].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thick);
Sheet.Cells[iTableRowStart, iTableColStart, iRow - 1, iCol - 1].AutoFitColumns();
iRow += 2;
iCol = 2;
var picRadarChart = Sheet.Drawings.AddPicture("Radar Chart", RadarChart);
picRadarChart.SetPosition(iRow, 0, iCol-1, 0);
iRow += 30;
//var picTrendChartHumidity = Sheet.Drawings.AddPicture("Trend Chart by Humidity", TrendChartByHumidity);
//picTrendChartHumidity.SetPosition(iRow, 0, iCol, 0);
//iRow += 30;
//var picTrendChartTemperature = Sheet.Drawings.AddPicture("Trend Chart by Temperature", TrendChartByTemperature);
//picTrendChartTemperature.SetPosition(iRow, 0, iCol, 0);
//iRow += 30;
//var picTrendChartForce = Sheet.Drawings.AddPicture("Trend Chart by Force", TrendChartByForce);
//picTrendChartForce.SetPosition(iRow, 0, iCol, 0);
//iRow += 30;
//var picTrendChartVelocity = Sheet.Drawings.AddPicture("Trend Chart by Velocity", TrendChartByVelocity);
//picTrendChartVelocity.SetPosition(iRow, 0, iCol, 0);
//iRow += 30;
package.SaveAs(new FileInfo(FilePath));
}
}
}
}

View File

@@ -71,6 +71,12 @@
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Compile Include="AboutBox.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="AboutBox.Designer.cs">
<DependentUpon>AboutBox.cs</DependentUpon>
</Compile>
<Compile Include="Config.cs" />
<Compile Include="DataHandler.cs" />
<Compile Include="MainForm.cs">
@@ -117,8 +123,12 @@
<Compile Include="PanelMaterial.Designer.cs">
<DependentUpon>PanelMaterial.cs</DependentUpon>
</Compile>
<Compile Include="Report.cs" />
<Compile Include="Theme.cs" />
<Compile Include="TrendLine.cs" />
<EmbeddedResource Include="AboutBox.resx">
<DependentUpon>AboutBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>