INT63DC_2C/INT63DC_2C/Controls/ControlMainDisplayEachBarGr...

508 lines
20 KiB
C#

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using INT63DC_2C.Forms;
using System.Collections.ObjectModel;
using SmartX;
namespace INT63DC_2C.Controls
{
public partial class ControlMainDisplayEachBarGraph6 : UserControl
{
#region Field
private FormMainDisplay m_ParentForm;
private Collection<PictureBox> CollectionPictureBoxZero;
private Collection<SmartLabel> CollectionLabelWeightValue;
private Collection<SmartProgressBar> CollectionProgressBar;
private Collection<PictureBox> CollectionPictureBoxBypass;
#endregion
#region Constructor
public ControlMainDisplayEachBarGraph6(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);
this.CollectionPictureBoxZero.Add(this.pictureBox5);
this.CollectionPictureBoxZero.Add(this.pictureBox6);
// LabelWeightValue
this.CollectionLabelWeightValue = new Collection<SmartLabel>();
this.CollectionLabelWeightValue.Clear();
this.CollectionLabelWeightValue.Add(this.labelWeightValue1);
this.CollectionLabelWeightValue.Add(this.labelWeightValue2);
this.CollectionLabelWeightValue.Add(this.labelWeightValue3);
this.CollectionLabelWeightValue.Add(this.labelWeightValue4);
this.CollectionLabelWeightValue.Add(this.labelWeightValue5);
this.CollectionLabelWeightValue.Add(this.labelWeightValue6);
// ProgressBar
this.CollectionProgressBar = new Collection<SmartProgressBar>();
this.CollectionProgressBar.Clear();
this.CollectionProgressBar.Add(this.progressBar1);
this.CollectionProgressBar.Add(this.progressBar2);
this.CollectionProgressBar.Add(this.progressBar3);
this.CollectionProgressBar.Add(this.progressBar4);
this.CollectionProgressBar.Add(this.progressBar5);
this.CollectionProgressBar.Add(this.progressBar6);
// 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);
this.CollectionPictureBoxBypass.Add(this.pictureBoxBypass5);
this.CollectionPictureBoxBypass.Add(this.pictureBoxBypass6);
}
private void InitializeControl()
{
foreach (PictureBox picture in this.CollectionPictureBoxZero)
picture.Visible = false;
foreach (SmartLabel label in this.CollectionLabelWeightValue)
{
if (this.ParentForm.ParentForm.SystemConfig.DecimalPlaces == 3)
label.Font = new Font("Arial", 17, FontStyle.Bold);
else
label.Font = new Font("Arial", 20, FontStyle.Bold);
label.Text = Helper.StringToDecimalPlaces("0", this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
}
foreach (SmartProgressBar bar in this.CollectionProgressBar)
bar.Value = bar.Minimum;
foreach (PictureBox picture in this.CollectionPictureBoxBypass)
picture.Visible = false;
this.SetCount(this.ParentForm.ParentForm.CollectionWeightData);
}
private void SetCount(Collection<WeightData> weightdatas)
{
string value = "";
#region Lane 1
value = weightdatas[0].TotalNGCount.ToString();
if (this.labelNGCount1.Text != value)
this.labelNGCount1.Text = value;
value = weightdatas[0].PassCount.ToString();
if (this.labelPassCount1.Text != value)
this.labelPassCount1.Text = value;
#endregion
#region Lane 2
value = weightdatas[1].TotalNGCount.ToString();
if (this.labelNGCount2.Text != value)
this.labelNGCount2.Text = value;
value = weightdatas[1].PassCount.ToString();
if (this.labelPassCount2.Text != value)
this.labelPassCount2.Text = value;
#endregion
#region Lane 3
value = weightdatas[2].TotalNGCount.ToString();
if (this.labelNGCount3.Text != value)
this.labelNGCount3.Text = value;
value = weightdatas[2].PassCount.ToString();
if (this.labelPassCount3.Text != value)
this.labelPassCount3.Text = value;
#endregion
#region Lane 4
value = weightdatas[3].TotalNGCount.ToString();
if (this.labelNGCount4.Text != value)
this.labelNGCount4.Text = value;
value = weightdatas[3].PassCount.ToString();
if (this.labelPassCount4.Text != value)
this.labelPassCount4.Text = value;
#endregion
#region Lane 5
value = weightdatas[4].TotalNGCount.ToString();
if (this.labelNGCount5.Text != value)
this.labelNGCount5.Text = value;
value = weightdatas[4].PassCount.ToString();
if (this.labelPassCount5.Text != value)
this.labelPassCount5.Text = value;
#endregion
#region Lane 6
value = weightdatas[5].TotalNGCount.ToString();
if (this.labelNGCount6.Text != value)
this.labelNGCount6.Text = value;
value = weightdatas[5].PassCount.ToString();
if (this.labelPassCount6.Text != value)
this.labelPassCount6.Text = value;
#endregion
this.ParentForm.SetTotalCount();
}
public void RescaleControl()
{
foreach (SmartProgressBar bar in this.CollectionProgressBar)
{
Helper.RescaleProgressBar(bar, this.ParentForm.ParentForm.CurrentProductItem.ProgressBarMaximum, this.ParentForm.ParentForm.CurrentProductItem.ProgressBarMinimum);
bar.Value = bar.Minimum;
}
}
public void Clear()
{
foreach (SmartX.SmartLabel label in this.CollectionLabelWeightValue)
{
label.Text = Helper.StringToDecimalPlaces("0", this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
label.ForeColor = Color.Black;
}
foreach (SmartX.SmartProgressBar bar in this.CollectionProgressBar)
bar.Value = bar.Minimum;
foreach (WeightData data in this.ParentForm.ParentForm.CollectionWeightData)
data.ClearCount();
this.SetCount(this.ParentForm.ParentForm.CollectionWeightData);
this.ParentForm.ParentForm.SaveCounterFile1(this.ParentForm.ParentForm.CollectionWeightData, this.ParentForm.ParentForm.SystemConfig.ProductNumber - 1);
}
public void UpdateEquipmentStatusDisplay(DataStore.EquipmentStatus status)
{
string temp = "";
foreach (SmartX.SmartLabel label in this.CollectionLabelWeightValue)
{
temp = Helper.StringToDecimalPlaces("0", this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
if (label.Text != temp)
label.Text = temp;
}
foreach (SmartProgressBar bar in this.CollectionProgressBar)
bar.Value = bar.Minimum;
}
public void UpdateCurrentProductDisplay(DataStore.EquipmentStatus status, Collection<WeightData> weightDatas)
{
foreach (SmartProgressBar bar in this.CollectionProgressBar)
bar.Value = bar.Minimum;
this.SetCount(this.ParentForm.ParentForm.CollectionWeightData);
}
public void UpdateBypassDisplay(Collection<WeightData> weightData)
{
for (int i = 0; i < this.CollectionPictureBoxBypass.Count; i++)
{
if (weightData[i].IsBypassMode == true)
this.CollectionPictureBoxBypass[i].Visible = true;
else
this.CollectionPictureBoxBypass[i].Visible = false;
}
}
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++)
{
// 중량
value = Helper.DoubleToString(weightDatas[i].Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
if (this.CollectionLabelWeightValue[i].Text != value)
this.CollectionLabelWeightValue[i].Text = value;
if (this.CollectionLabelWeightValue[i].ForeColor != Color.Black)
this.CollectionLabelWeightValue[i].ForeColor = Color.Black;
// 영점표시
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]);
this.UpdateStartWeightDisplay5(status, weightDatas[4]);
this.UpdateStartWeightDisplay6(status, weightDatas[5]);
}
public void UpdateStartWeightDisplay1(DataStore.EquipmentStatus status, WeightData weightData)
{
string value = "";
bool empty = false;
if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
return;
if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
empty = true;
// Weight
value = Helper.DoubleToString(weightData.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
if (this.labelWeightValue1.Text != value)
this.labelWeightValue1.Text = value;
if (empty == false)
{
this.labelWeightValue1.ForeColor = Color.Black;
value = weightData.PassCount.ToString();
if (this.labelPassCount1.Text != value)
this.labelPassCount1.Text = value;
value = weightData.TotalNGCount.ToString();
if (this.labelNGCount1.Text != value)
this.labelNGCount1.Text = value;
Helper.SetProgressBarValue(this.progressBar1, weightData.Weight, weightData.JudgmentStatus, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
}
else
{
this.labelWeightValue1.ForeColor = Color.Gray;
this.progressBar1.Value = this.progressBar1.Minimum;
this.progressBar1.BarColor1 = Color.Lime;
}
}
public void UpdateStartWeightDisplay2(DataStore.EquipmentStatus status, WeightData weightData)
{
string value = "";
bool empty = false;
if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
return;
if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
empty = true;
// Weight
value = Helper.DoubleToString(weightData.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
if (this.labelWeightValue2.Text != value)
this.labelWeightValue2.Text = value;
if (empty == false)
{
this.labelWeightValue2.ForeColor = Color.Black;
value = weightData.PassCount.ToString();
if (this.labelPassCount2.Text != value)
this.labelPassCount2.Text = value;
value = weightData.TotalNGCount.ToString();
if (this.labelNGCount2.Text != value)
this.labelNGCount2.Text = value;
Helper.SetProgressBarValue(this.progressBar2, weightData.Weight, weightData.JudgmentStatus, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
}
else
{
this.labelWeightValue2.ForeColor = Color.Gray;
this.progressBar2.Value = this.progressBar2.Minimum;
this.progressBar2.BarColor1 = Color.Lime;
}
}
public void UpdateStartWeightDisplay3(DataStore.EquipmentStatus status, WeightData weightData)
{
string value = "";
bool empty = false;
if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
return;
if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
empty = true;
// Weight
value = Helper.DoubleToString(weightData.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
if (this.labelWeightValue3.Text != value)
this.labelWeightValue3.Text = value;
if (empty == false)
{
this.labelWeightValue3.ForeColor = Color.Black;
value = weightData.PassCount.ToString();
if (this.labelPassCount3.Text != value)
this.labelPassCount3.Text = value;
value = weightData.TotalNGCount.ToString();
if (this.labelNGCount3.Text != value)
this.labelNGCount3.Text = value;
Helper.SetProgressBarValue(this.progressBar3, weightData.Weight, weightData.JudgmentStatus, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
}
else
{
this.labelWeightValue3.ForeColor = Color.Gray;
this.progressBar3.Value = this.progressBar3.Minimum;
this.progressBar3.BarColor1 = Color.Lime;
}
}
public void UpdateStartWeightDisplay4(DataStore.EquipmentStatus status, WeightData weightData)
{
string value = "";
bool empty = false;
if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
return;
if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
empty = true;
// Weight
value = Helper.DoubleToString(weightData.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
if (this.labelWeightValue4.Text != value)
this.labelWeightValue4.Text = value;
if (empty == false)
{
this.labelWeightValue4.ForeColor = Color.Black;
value = weightData.PassCount.ToString();
if (this.labelPassCount4.Text != value)
this.labelPassCount4.Text = value;
value = weightData.TotalNGCount.ToString();
if (this.labelNGCount4.Text != value)
this.labelNGCount4.Text = value;
Helper.SetProgressBarValue(this.progressBar4, weightData.Weight, weightData.JudgmentStatus, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
}
else
{
this.labelWeightValue4.ForeColor = Color.Gray;
this.progressBar4.Value = this.progressBar4.Minimum;
this.progressBar4.BarColor1 = Color.Lime;
}
}
public void UpdateStartWeightDisplay5(DataStore.EquipmentStatus status, WeightData weightData)
{
string value = "";
bool empty = false;
if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
return;
if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
empty = true;
// Weight
value = Helper.DoubleToString(weightData.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
if (this.labelWeightValue5.Text != value)
this.labelWeightValue5.Text = value;
if (empty == false)
{
this.labelWeightValue5.ForeColor = Color.Black;
value = weightData.PassCount.ToString();
if (this.labelPassCount5.Text != value)
this.labelPassCount5.Text = value;
value = weightData.TotalNGCount.ToString();
if (this.labelNGCount5.Text != value)
this.labelNGCount5.Text = value;
Helper.SetProgressBarValue(this.progressBar5, weightData.Weight, weightData.JudgmentStatus, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
}
else
{
this.labelWeightValue5.ForeColor = Color.Gray;
this.progressBar5.Value = this.progressBar5.Minimum;
this.progressBar5.BarColor1 = Color.Lime;
}
}
public void UpdateStartWeightDisplay6(DataStore.EquipmentStatus status, WeightData weightData)
{
string value = "";
bool empty = false;
if (weightData.JudgmentStatus == DataStore.JudgmentStatus.None)
return;
if (weightData.JudgmentStatus == DataStore.JudgmentStatus.Empty)
empty = true;
// Weight
value = Helper.DoubleToString(weightData.Weight, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
if (this.labelWeightValue6.Text != value)
this.labelWeightValue6.Text = value;
if (empty == false)
{
this.labelWeightValue6.ForeColor = Color.Black;
value = weightData.PassCount.ToString();
if (this.labelPassCount6.Text != value)
this.labelPassCount6.Text = value;
value = weightData.TotalNGCount.ToString();
if (this.labelNGCount6.Text != value)
this.labelNGCount6.Text = value;
Helper.SetProgressBarValue(this.progressBar6, weightData.Weight, weightData.JudgmentStatus, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
}
else
{
this.labelWeightValue6.ForeColor = Color.Gray;
this.progressBar6.Value = this.progressBar6.Minimum;
this.progressBar6.BarColor1 = Color.Lime;
}
}
#endregion
}
}