ITC81DB_2H/ITC81DB_0H/Controls/CenterSystem/ControlCenterSystemAutoZero.cs

235 lines
10 KiB
C#
Raw Normal View History

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 ITC81DB_0H.DialogForms;
using ITC81DB_0H.Forms;
using SmartX;
using ITC81DB_2H_ImageDll;
namespace ITC81DB_0H.Controls
{
public partial class ControlCenterSystemAutoZero : UserControl
{
#region Field
private FormMenu m_ParentForm;
#endregion
#region Constructor
public ControlCenterSystemAutoZero(FormMenu parent)
{
InitializeComponent();
this.ParentForm = parent;
this.InitializeDesign();
this.DefaultSetting();
}
#endregion
#region Property
public FormMenu ParentForm
{
get { return this.m_ParentForm; }
private set { this.m_ParentForm = value; }
}
#endregion
#region Method
public void InitializeDesign()
{
Class1 images = new Class1();
if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English)
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.engBackgroundAutoZero));
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.chnBackgroundAutoZero));
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech)
{
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian)
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.rusBackgroundAutoZero));
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.gerBackgroundAutoZero));
}
else
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.korBackgroundAutoZero));
}
}
private void DefaultSetting()
{
this.comboBoxVariate.SelectedIndexChanged -= new EventHandler(this.comboBoxVariate_SelectedIndexChanged);
this.comboBoxVariate.Items.Clear();
this.comboBoxVariate.Items.Add(0.1);
this.comboBoxVariate.Items.Add(0.2);
this.comboBoxVariate.Items.Add(0.5);
this.comboBoxVariate.Items.Add(1.0);
this.comboBoxVariate.SelectedIndex = 0;
this.comboBoxVariate.SelectedIndexChanged += new EventHandler(this.comboBoxVariate_SelectedIndexChanged);
}
private void ControlEnableMode1(bool time, bool range, bool variate)
{
if (time == true)
{
if (this.labelPlusRange.ForeColor != Color.White)
this.labelPlusRange.ForeColor = Color.White;
}
else
{
if (this.labelPlusRange.ForeColor != Color.DarkGray)
this.labelPlusRange.ForeColor = Color.DarkGray;
}
if (range == true)
{
if (this.labelMinusRange.ForeColor != Color.White)
this.labelMinusRange.ForeColor = Color.White;
}
else
{
if (this.labelMinusRange.ForeColor != Color.DarkGray)
this.labelMinusRange.ForeColor = Color.DarkGray;
}
if (this.labelPlusRange.Enabled != time)
this.labelPlusRange.Enabled = time;
if (this.labelMinusRange.Enabled != range)
this.labelMinusRange.Enabled = range;
if (this.comboBoxVariate.Enabled != variate)
this.comboBoxVariate.Enabled = variate;
}
private void UpdateZeroParameterDisplay(SystemParameter4 item)
{
int iValue = 0;
string value = "";
// Mode 1
iValue = int.Parse(item.MainAutoZeroMinusRange.Trim());
if (iValue == 4)
{
this.ControlEnableMode1(true, true, true);
}
else
{
this.ControlEnableMode1(false, false, false);
}
// Mode1 Time
value = item.MainAutoZeroPlusRange.Trim();
if (this.labelPlusRange.Text != value)
this.labelPlusRange.Text = value;
// Mode1 Range
if (item.MainAutoZeroIsAutoZeroUsing == true)
this.buttonIsAutoZeroUsing.ButtonDown();
else
this.buttonIsAutoZeroUsing.ButtonUp();
// Mode1 Variate
iValue = int.Parse(item.MainAutoZeroVariate.Trim());
this.comboBoxVariate.SelectedIndexChanged -= new EventHandler(this.comboBoxVariate_SelectedIndexChanged);
this.comboBoxVariate.SelectedIndex = iValue;
this.comboBoxVariate.SelectedIndexChanged += new EventHandler(this.comboBoxVariate_SelectedIndexChanged);
}
public void DisplayRefresh(SystemStatus status)
{
this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.SystemAutoZero;
this.ParentForm.ParentForm.SetDisplayMode(DataStore.DisplayMode.Menu);
this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);
//this.UpdateZeroParameterDisplay(this.ParentForm.ParentForm.CurrentSystemParameter4);
this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterRead4901, "");
this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterRead4902, "");
}
#endregion
#region Event Handler
private void buttonIsAutoZeroUsing_Click(object sender, EventArgs e)
{
if (this.buttonIsAutoZeroUsing.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZeroIsAutoZeroUsing = true;
else
this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZeroIsAutoZeroUsing = false;
this.ParentForm.ParentForm.SaveSystemParameter4File(this.ParentForm.ParentForm.CurrentSystemParameter4);
}
private void labelPlusRange_Click(object sender, EventArgs e)
{
string value = "";
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelPlusRange.Text, 5, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces, false, this.ParentForm.ParentForm.SystemConfig1.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue > 500.0)
{
// 입력범위를 확인하세요
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language);
myMsg.ShowDialog();
}
else
{
this.labelPlusRange.Text = myKeyPad.StringValue;
this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZeroPlusRange = myKeyPad.StringValue.Replace(".","");
this.ParentForm.ParentForm.SaveSystemParameter4File(this.ParentForm.ParentForm.CurrentSystemParameter4);
value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZeroPlusRange);
this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.AutoZeroPlusRange, value);
}
}
}
private void labelMinusRange_Click(object sender, EventArgs e)
{
string value = "";
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelMinusRange.Text, 5, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces, false, this.ParentForm.ParentForm.SystemConfig1.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue > 500.0)
{
// 입력범위를 확인하세요
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language);
myMsg.ShowDialog();
}
else
{
this.labelMinusRange.Text = myKeyPad.StringValue;
this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZeroMinusRange = myKeyPad.StringValue.Replace(".", "");
this.ParentForm.ParentForm.SaveSystemParameter4File(this.ParentForm.ParentForm.CurrentSystemParameter4);
value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZeroMinusRange);
this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.AutoZeroMinusRange, value);
}
}
}
private void comboBoxVariate_SelectedIndexChanged(object sender, EventArgs e)
{
string value = "";
this.ParentForm.ParentForm.CurrentSystemParameter4.LCDAutoZeroVariate = this.comboBoxVariate.SelectedIndex.ToString();
this.ParentForm.ParentForm.SaveSystemParameter4File(this.ParentForm.ParentForm.CurrentSystemParameter4);
value = Helper.StringZeroFillDigits4(this.comboBoxVariate.SelectedIndex.ToString());
this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.AutoZeroVariate, value);
}
#endregion
}
}