250 lines
9.1 KiB
C#
250 lines
9.1 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
using SmartX;
|
|
using INT69DB_2A.Forms;
|
|
|
|
namespace INT69DB_2A.Controls
|
|
{
|
|
public partial class ControlMainDisplayDotGraph4 : UserControl
|
|
{
|
|
#region Field
|
|
private FormMainDisplay m_ParentForm;
|
|
|
|
private Collection<PictureBox> CollectionPictureBoxZero;
|
|
private Collection<SmartDraw> CollectionDraw;
|
|
private Collection<PictureBox> CollectionPictureBoxBypass;
|
|
#endregion
|
|
|
|
#region Constructor
|
|
public ControlMainDisplayDotGraph4(FormMainDisplay parent)
|
|
{
|
|
InitializeComponent();
|
|
|
|
this.ParentForm = parent;
|
|
|
|
this.CreateCollection();
|
|
this.InitializeControl();
|
|
}
|
|
#endregion
|
|
|
|
#region Property
|
|
public FormMainDisplay ParentForm
|
|
{
|
|
get { return this.m_ParentForm; }
|
|
private set { this.m_ParentForm = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region Method
|
|
private void CreateCollection()
|
|
{
|
|
// PictureBoxZero
|
|
this.CollectionPictureBoxZero = new Collection<PictureBox>();
|
|
this.CollectionPictureBoxZero.Clear();
|
|
this.CollectionPictureBoxZero.Add(this.pictureBox1);
|
|
this.CollectionPictureBoxZero.Add(this.pictureBox2);
|
|
this.CollectionPictureBoxZero.Add(this.pictureBox3);
|
|
this.CollectionPictureBoxZero.Add(this.pictureBox4);
|
|
|
|
// SmartDraw
|
|
this.CollectionDraw = new Collection<SmartDraw>();
|
|
this.CollectionDraw.Clear();
|
|
this.CollectionDraw.Add(this.draw1);
|
|
this.CollectionDraw.Add(this.draw2);
|
|
this.CollectionDraw.Add(this.draw3);
|
|
this.CollectionDraw.Add(this.draw4);
|
|
|
|
// PictureBoxBypass
|
|
this.CollectionPictureBoxBypass = new Collection<PictureBox>();
|
|
this.CollectionPictureBoxBypass.Clear();
|
|
this.CollectionPictureBoxBypass.Add(this.pictureBoxBypass1);
|
|
this.CollectionPictureBoxBypass.Add(this.pictureBoxBypass2);
|
|
this.CollectionPictureBoxBypass.Add(this.pictureBoxBypass3);
|
|
this.CollectionPictureBoxBypass.Add(this.pictureBoxBypass4);
|
|
}
|
|
private void InitializeControl()
|
|
{
|
|
foreach (PictureBox picture in this.CollectionPictureBoxZero)
|
|
picture.Visible = false;
|
|
|
|
foreach (PictureBox picture in this.CollectionPictureBoxBypass)
|
|
picture.Visible = false;
|
|
|
|
this.InitialzeDraws();
|
|
this.draw1.BringToFront();
|
|
this.button1.ButtonDown();
|
|
}
|
|
private void InitialzeDraws()
|
|
{
|
|
foreach (SmartDraw draw in this.CollectionDraw)
|
|
this.InitializeDraw(draw, this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig);
|
|
}
|
|
private void InitializeDraw(SmartDraw draw, ProductItem pItem, SystemConfigurationItem sItem)
|
|
{
|
|
draw.BackDraw.SetPenStyle(Color.Blue, 3);
|
|
|
|
draw.BackDraw.Line(100, 20, 100, 310);
|
|
draw.BackDraw.Line(100, 310, 730, 310);
|
|
|
|
draw.BackDraw.SetPenStyle(Color.Gray, 1);
|
|
|
|
draw.BackDraw.SetFontCfg(25, Color.Red);
|
|
draw.BackDraw.TextOut(650, 2, draw.Text);
|
|
draw.BackDraw.SetFontCfg(30, Color.White);
|
|
|
|
// Chart의 가로 그리드 그리기
|
|
draw.BackDraw.Line(103, 310 - (1 * 103) + 7, 730, 310 - (1 * 103) + 7);
|
|
draw.BackDraw.TextOut(15, 295 - (1 * 103) + 7, Helper.StringToDecimalPlaces(pItem.UnderRange, sItem.DecimalPlaces));
|
|
|
|
draw.BackDraw.Line(103, 310 - (2 * 103) + 14, 730, 310 - (2 * 103) + 14);
|
|
draw.BackDraw.TextOut(15, 295 - (2 * 103) + 14, Helper.StringToDecimalPlaces(pItem.OverRange, sItem.DecimalPlaces));
|
|
|
|
SmartX.SmartDraw.CHARTPENSTYLE[] chartchPenStyle = new SmartX.SmartDraw.CHARTPENSTYLE[1];
|
|
chartchPenStyle[0].m_chColor = Color.Yellow;
|
|
chartchPenStyle[0].m_iPenWidth = 2;
|
|
|
|
draw.SetChartCfg(103, 310, 627, 290, 16, SmartX.SmartDraw.CHARTREFRESH.LEFTSCROLL, 1);
|
|
draw.ChartChannelPenStyle = chartchPenStyle;
|
|
}
|
|
|
|
public void RescaleControl()
|
|
{
|
|
foreach (SmartDraw draw in this.CollectionDraw)
|
|
{
|
|
draw.BackDraw.BackErase(Color.Black);
|
|
draw.Erase();
|
|
draw.PutDataAllClear();
|
|
}
|
|
this.InitialzeDraws();
|
|
}
|
|
public void Clear()
|
|
{
|
|
foreach (SmartX.SmartDraw draw in this.CollectionDraw)
|
|
draw.PutDataAllClear();
|
|
}
|
|
|
|
private void UpdateDraw(SmartDraw draw, WeightData weightData)
|
|
{
|
|
int iValue = 0, gap = 0, startingPoint = 0;
|
|
double scale = 0.0, value = 0.0;
|
|
|
|
if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
|
|
return;
|
|
|
|
// 스케일 계산
|
|
gap = int.Parse(this.ParentForm.ParentForm.CurrentProductItem.OverRange)
|
|
- int.Parse(this.ParentForm.ParentForm.CurrentProductItem.UnderRange);
|
|
scale = 97.0 / gap;
|
|
startingPoint = int.Parse(this.ParentForm.ParentForm.CurrentProductItem.UnderRange) - gap;
|
|
|
|
try
|
|
{
|
|
value = (int.Parse(weightData.WeightString) - startingPoint) * scale;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
value = 0;
|
|
}
|
|
|
|
// 그래프를 스케일을 넘어가면 Max값 적용
|
|
if (value > 290)
|
|
value = 290;
|
|
if (value < 2)
|
|
value = 2;
|
|
|
|
iValue = int.Parse(string.Format("{0:f0}", value));
|
|
|
|
draw.PutData(iValue);
|
|
}
|
|
|
|
public void UpdateEquipmentStatusDisplay(DataStore.EquipmentStatus status)
|
|
{
|
|
|
|
}
|
|
public void UpdateCurrentProductDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
|
|
{
|
|
}
|
|
public void UpdateStopWeightDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
|
|
{
|
|
string value = "";
|
|
|
|
if (this.ParentForm.ParentForm.SystemConfig.EquipmentColumns > weightDatas.Count)
|
|
return;
|
|
|
|
if (status == DataStore.EquipmentStatus.Stop)
|
|
{
|
|
for (int i = 0; i < this.ParentForm.ParentForm.SystemConfig.EquipmentColumns; i++)
|
|
{
|
|
// 영점표시
|
|
if (weightDatas[i].Status == DataStore.WeightStatus.WeightZero)
|
|
this.CollectionPictureBoxZero[i].Visible = true;
|
|
else
|
|
this.CollectionPictureBoxZero[i].Visible = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < this.ParentForm.ParentForm.SystemConfig.EquipmentColumns; i++)
|
|
{
|
|
// 영점표시
|
|
if (weightDatas[i].Status == DataStore.WeightStatus.WeightZero)
|
|
this.CollectionPictureBoxZero[i].Visible = true;
|
|
else
|
|
this.CollectionPictureBoxZero[i].Visible = false;
|
|
}
|
|
}
|
|
}
|
|
public void UpdateStartWeightDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
|
|
{
|
|
this.UpdateStartWeightDisplay1(status, weightDatas[0]);
|
|
this.UpdateStartWeightDisplay2(status, weightDatas[1]);
|
|
this.UpdateStartWeightDisplay3(status, weightDatas[2]);
|
|
this.UpdateStartWeightDisplay4(status, weightDatas[3]);
|
|
}
|
|
public void UpdateStartWeightDisplay1(DataStore.EquipmentStatus status, WeightData weightData)
|
|
{
|
|
this.UpdateDraw(this.CollectionDraw[0], weightData);
|
|
}
|
|
public void UpdateStartWeightDisplay2(DataStore.EquipmentStatus status, WeightData weightData)
|
|
{
|
|
this.UpdateDraw(this.CollectionDraw[1], weightData);
|
|
}
|
|
public void UpdateStartWeightDisplay3(DataStore.EquipmentStatus status, WeightData weightData)
|
|
{
|
|
this.UpdateDraw(this.CollectionDraw[2], weightData);
|
|
}
|
|
public void UpdateStartWeightDisplay4(DataStore.EquipmentStatus status, WeightData weightData)
|
|
{
|
|
this.UpdateDraw(this.CollectionDraw[3], weightData);
|
|
}
|
|
#endregion
|
|
|
|
#region Event Handler
|
|
private void buttonSelectDraw_Click(object sender, EventArgs e)
|
|
{
|
|
SmartButton button = sender as SmartButton;
|
|
|
|
if (button == null)
|
|
return;
|
|
|
|
if (button == this.button1)
|
|
this.draw1.BringToFront();
|
|
else if (button == this.button2)
|
|
this.draw2.BringToFront();
|
|
else if (button == this.button3)
|
|
this.draw3.BringToFront();
|
|
else if (button == this.button4)
|
|
this.draw4.BringToFront();
|
|
}
|
|
#endregion
|
|
}
|
|
}
|