using System; using System.Linq; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using BMS_D1000H.BMSConstData; using BMS_D1000H.DataStructs; using BMS_D1000H.Utils.Functions; namespace BMS_D1000H { public partial class fmSystemSetCmd : Form { #region VARIABLES SmartX.SmartLabel[] lbSysSetItem; SmartX.SmartLabel[] lbModuleQty; TextBox[] tbNewValue; DeviceDataSystem disBMSData; public int SetID = 0; short Reg_Addr; short Reg_Count; short[] Reg_Data; #endregion #region CONSTRUCTORS public fmSystemSetCmd() { InitializeComponent(); CreateComponent(); ResetControl(); tmrDisplay.Start(); } #endregion #region CREATE COMPONENT private void CreateComponent() { lbSysSetItem = new SmartX.SmartLabel[2]; for (int i = 0; i < 2; i++) { lbSysSetItem[i] = new SmartX.SmartLabel(); //lbNetItem[i].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(192)))), ((int)(((byte)(255))))); lbSysSetItem[i].BackPictureBox = null; lbSysSetItem[i].BackPictureBox1 = null; lbSysSetItem[i].BackPictureBox2 = null; lbSysSetItem[i].BorderColor = System.Drawing.Color.Black; lbSysSetItem[i].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; lbSysSetItem[i].Font = new System.Drawing.Font("Arial Black", 11F, System.Drawing.FontStyle.Bold); lbSysSetItem[i].InitVisible = true; lbSysSetItem[i].LineSpacing = 0F; lbSysSetItem[i].Location = new System.Drawing.Point(2, 91 + (i * 37)); if (i == 0) lbSysSetItem[i].Name = String.Format("CURRENT"); else lbSysSetItem[i].Name = String.Format("SETTING"); lbSysSetItem[i].Size = new System.Drawing.Size(249, 33); lbSysSetItem[i].TabIndex = 70; lbSysSetItem[i].Text = lbSysSetItem[i].Name; lbSysSetItem[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Middle; lbSysSetItem[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle; lbSysSetItem[i].Wordwrap = false; } lbModuleQty = new SmartX.SmartLabel[1]; for (int i = 0; i < 1; i++) { lbModuleQty[i] = new SmartX.SmartLabel(); lbModuleQty[i].BackPictureBox = null; lbModuleQty[i].BackPictureBox1 = null; lbModuleQty[i].BackPictureBox2 = null; lbModuleQty[i].BorderColor = System.Drawing.Color.Black; lbModuleQty[i].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; lbModuleQty[i].Font = new System.Drawing.Font("Arial Black", 11F, System.Drawing.FontStyle.Bold); lbModuleQty[i].InitVisible = true; lbModuleQty[i].LineSpacing = 0F; lbModuleQty[i].Location = new System.Drawing.Point(254 + (i * 102), 91); lbModuleQty[i].Name = String.Format("MODULE QTY"); lbModuleQty[i].Size = new System.Drawing.Size(152, 33); lbModuleQty[i].TabIndex = 70; lbModuleQty[i].Text = "0"; lbModuleQty[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Middle; lbModuleQty[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle; lbModuleQty[i].Wordwrap = false; } tbNewValue = new TextBox[1]; for (int i = 0; i < 1; i++) { tbNewValue[i] = new TextBox(); tbNewValue[i].Font = new System.Drawing.Font("Tahoma", 16F, System.Drawing.FontStyle.Regular); tbNewValue[i].Location = new System.Drawing.Point(254 + (i * 102), 91 + 37); tbNewValue[i].Name = "0"; tbNewValue[i].Size = new System.Drawing.Size(152, 33); tbNewValue[i].TabIndex = i; tbNewValue[i].GotFocus += new System.EventHandler(this.tbClass_GotFocus); } } #endregion #region RESET CONTROL private void ResetControl() { this.SuspendLayout(); this.Controls.Clear(); for (int i = 0; i < 2; i++) { this.Controls.Add(lbSysSetItem[i]); } for (int i = 0; i < 1; i++) { this.Controls.Add(lbModuleQty[i]); this.Controls.Add(tbNewValue[i]); } this.Controls.Add(this.lbSetResult); this.Controls.Add(this.kbdValue); this.Controls.Add(this.btnSet); this.Controls.Add(this.btnCancel); this.Controls.Add(this.lnHdSysSetItemName); this.Controls.Add(this.lbHdConfigName); this.Controls.Add(this.lnHdSysSetItemName); this.Controls.Add(this.lbSystemSet); this.Controls.Add(this.sfmSysConfigCmd); this.ResumeLayout(false); } #endregion private void tbClass_GotFocus(object sender, EventArgs e) { int i = ((TextBox)(sender)).TabIndex; switch (i) { case 0: kbdValue.Location = new System.Drawing.Point(254 + (i * 102), 172); break; case 1: kbdValue.Location = new System.Drawing.Point(254 + (i * 102), 172); break; case 2: kbdValue.Location = new System.Drawing.Point(254 + (i * 102), 172); break; case 3: kbdValue.Location = new System.Drawing.Point(254 + (i * 102), 172); break; } kbdValue.TargetInputObject = ((TextBox)(sender)); kbdValue.Show(); } private void btnSet_Click(object sender, EventArgs e) { ((fmBMSMain)(Owner)).ScreenSaverTimeReset(); if (tbNewValue[0].Text == "") { lbSetResult.Text = "Cannot empty parameter"; return; } Reg_Addr = Convert.ToInt16(90); Reg_Count = 1; Reg_Data = new short[Reg_Count]; Reg_Data[0] = Convert.ToInt16(double.Parse(tbNewValue[0].Text)); ((fmBMSMain)(Owner)).SetModBusWriteCmd(1, Reg_Addr, Reg_Count, Reg_Data, 1); ((fmBMSMain)(Owner)).ChangeScreen(0, 0, ScreenID.SYSTEM_SET_SCREEN); } private void btnCancel_Click(object sender, EventArgs e) { ((fmBMSMain)(Owner)).ChangeScreen(0, 0, ScreenID.NET_CONFIG_SCREEN_ID); } private void tmrDisplay_Tick(object sender, EventArgs e) { DisplaySysConfigCmd(true); } #region DISPLAY FUNCTIONS private void DisplaySysConfigCmd(bool p) { DeviceDataSystem aBMSData; aBMSData = ((fmBMSMain)(Owner)).GetBmsSystemData(); if (p || (disBMSData.ModuleQuantity != aBMSData.ModuleQuantity)) { lbModuleQty[0].Text = String.Format("{0}", aBMSData.ModuleQuantity); disBMSData.ModuleQuantity = aBMSData.ModuleQuantity; } } #endregion } }