123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace FPER
- {
- public partial class frmModalUnitDataSelect : Form
- {
- // cyim 2015.2.23 회로차단시에는 사용불가 : 생성자 Overloading
- public frmModalUnitDataSelect(RepeaterDeviceTypeInfo Info)
- {
- InitializeComponent();
- if (Info.RepeaterType == "A")
- {
- if (Info.outDeviceTypeInfos[0] == null || Info.outDeviceTypeInfos[0].CutFlag == true)
- { checkBox1.Enabled = false; label0.BackColor = Color.Gray; }
- if (Info.outDeviceTypeInfos[1] == null || Info.outDeviceTypeInfos[1].CutFlag == true)
- { checkBox2.Enabled = false; label1.BackColor = Color.Gray; }
- }
- else if (Info.RepeaterType == "B")
- {
- if (Info.outDeviceTypeInfos[0] == null || Info.outDeviceTypeInfos[0].CutFlag == true)
- { checkBox1.Enabled = false; label0.BackColor = Color.Gray; }
- if (Info.outDeviceTypeInfos[1] == null || Info.outDeviceTypeInfos[1].CutFlag == true)
- { checkBox2.Enabled = false; label1.BackColor = Color.Gray; }
- if (Info.outDeviceTypeInfos[2] == null || Info.outDeviceTypeInfos[2].CutFlag == true)
- { checkBox3.Enabled = false; label2.BackColor = Color.Gray; }
- if (Info.outDeviceTypeInfos[3] == null || Info.outDeviceTypeInfos[3].CutFlag == true)
- { checkBox4.Enabled = false; label3.BackColor = Color.Gray; }
- }
- // cyim 2015.6.8 아날로그 감지기 연동 추가
- else if (Info.RepeaterType == "C" || Info.RepeaterType == "D")
- {
- if (Info.outDeviceTypeInfos[0] == null || Info.outDeviceTypeInfos[0].CutFlag == true)
- { checkBox1.Enabled = false; label0.BackColor = Color.Gray; }
- }
- }
- //입력값을 받고, 넘기기위한 VO
- private InputIDVo inputVo;
- public InputIDVo InputVo { get { return this.inputVo; } set { this.inputVo = value; } }
- //화면이동을 위해---------------
- private Boolean MoveOK = true;
- private Point mouseOffset;
- /********************************************************/
- /* MdiParent 화면이동 */
- /********************************************************/
- private void frmModalUnitDataSelect_MouseDown(object sender, MouseEventArgs e)
- {
- try
- {
- if (MoveOK)
- {
- mouseOffset = new Point(-e.X, -e.Y);
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void frmModalUnitDataSelect_MouseMove(object sender, MouseEventArgs e)
- {
- try
- {
- if (MoveOK && (e.Button == MouseButtons.Left))
- {
- Point mousePos = Control.MousePosition;
- mousePos.Offset(mouseOffset.X, mouseOffset.Y);
- this.Location = mousePos;
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- /********************************************************/
- private void frmModalUnitDataSelect_Load(object sender, EventArgs e)
- {
- try
- {
- checkBox1.Image = imageList1.Images[1];
- checkBox2.Image = imageList1.Images[1];
- checkBox3.Image = imageList1.Images[1];
- checkBox4.Image = imageList1.Images[1];
- checkBox1.Checked = false;
- checkBox2.Checked = false;
- checkBox3.Checked = false;
- checkBox4.Checked = false;
- if (inputVo != null)
- {
- if (inputVo.InoutType.Equals("I"))
- {
- //입력쓰기
- lblTitle.Text = "입력쓰기";
- InputDeviceStatus[] devData = inputVo.InputUnitData;
- if (inputVo.RepeaterType.Equals("A"))
- {
- checkBox3.Enabled = false;
- checkBox4.Enabled = false;
- if (devData[0] == InputDeviceStatus.Use) checkBox1.Checked = true; //ON
- if (devData[1] == InputDeviceStatus.Use) checkBox2.Checked = true; //ON
- }
- else if (inputVo.RepeaterType.Equals("B"))
- {
- if (devData[0] == InputDeviceStatus.Use) checkBox1.Checked = true; //ON
- if (devData[1] == InputDeviceStatus.Use) checkBox2.Checked = true; //ON
- if (devData[2] == InputDeviceStatus.Use) checkBox3.Checked = true; //ON
- if (devData[3] == InputDeviceStatus.Use) checkBox4.Checked = true; //ON
- }
- // cyim 2015.6.8 아날로그 감지기 연동 추가
- else if (inputVo.RepeaterType.Equals("C") || inputVo.RepeaterType.Equals("D"))
- {
- checkBox2.Enabled = false;
- checkBox3.Enabled = false;
- checkBox4.Enabled = false;
- // 아날로그 감지기는 1개만 출력쓰기가 가능하다 (차후에 방지해야 되는지는 차후에 살펴봄)
- if (devData[0] == InputDeviceStatus.Use) checkBox1.Checked = true; //ON
- }
- }
- else
- {
- //출력쓰기
- lblTitle.Text = "출력쓰기";
- OutputDeviceStatus[] devData = inputVo.OutputUnitData;
- if (inputVo.RepeaterType.Equals("A"))
- {
- checkBox3.Enabled = false;
- checkBox4.Enabled = false;
- if (devData[0] == OutputDeviceStatus.Write) checkBox1.Checked = true; //ON
- if (devData[1] == OutputDeviceStatus.Write) checkBox2.Checked = true; //ON
- }
- else if (inputVo.RepeaterType.Equals("B"))
- {
- if (devData[0] == OutputDeviceStatus.Write) checkBox1.Checked = true; //ON
- if (devData[1] == OutputDeviceStatus.Write) checkBox2.Checked = true; //ON
- if (devData[2] == OutputDeviceStatus.Write) checkBox3.Checked = true; //ON
- if (devData[3] == OutputDeviceStatus.Write) checkBox4.Checked = true; //ON
- }
- // cyim 2015.6.8 아날로그 감지기 연동 추가
- else if (inputVo.RepeaterType.Equals("C") || inputVo.RepeaterType.Equals("D"))
- {
- checkBox2.Enabled = false;
- checkBox3.Enabled = false;
- checkBox4.Enabled = false;
- // 아날로그 감지기는 1개만 출력쓰기가 가능하다 (차후에 방지해야 되는지는 차후에 살펴봄)
- if (devData[0] == OutputDeviceStatus.Write) checkBox1.Checked = true; //ON
- }
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void btnClose_Click(object sender, EventArgs e)
- {
- try
- {
- this.inputVo.InputOK = false;
- this.Close();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void btnOK_Click(object sender, EventArgs e)
- {
- try
- {
- if (inputVo.InoutType.Equals("I"))
- {
- InputDeviceStatus[] devData = new InputDeviceStatus[4];
- devData[0] = checkBox1.Checked ? InputDeviceStatus.Use : InputDeviceStatus.Normal;
- devData[1] = checkBox2.Checked ? InputDeviceStatus.Use : InputDeviceStatus.Normal;
- devData[2] = checkBox3.Checked ? InputDeviceStatus.Use : InputDeviceStatus.Normal;
- devData[3] = checkBox4.Checked ? InputDeviceStatus.Use : InputDeviceStatus.Normal;
- this.inputVo.InputUnitData = devData;
- this.inputVo.InputOK = true;
- }
- else
- {
- OutputDeviceStatus[] devData = new OutputDeviceStatus[4];
- devData[0] = checkBox1.Checked ? OutputDeviceStatus.Write : OutputDeviceStatus.NotWrite;
- devData[1] = checkBox2.Checked ? OutputDeviceStatus.Write : OutputDeviceStatus.NotWrite;
- devData[2] = checkBox3.Checked ? OutputDeviceStatus.Write : OutputDeviceStatus.NotWrite;
- devData[3] = checkBox4.Checked ? OutputDeviceStatus.Write : OutputDeviceStatus.NotWrite;
- this.inputVo.OutputUnitData = devData;
- this.inputVo.InputOK = true;
- }
- this.Close();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- try
- {
- if (checkBox1.Checked) checkBox1.Image = imageList1.Images[0];
- else checkBox1.Image = imageList1.Images[1];
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void checkBox2_CheckedChanged(object sender, EventArgs e)
- {
- try
- {
- if (checkBox2.Checked) checkBox2.Image = imageList1.Images[0];
- else checkBox2.Image = imageList1.Images[1];
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void checkBox3_CheckedChanged(object sender, EventArgs e)
- {
- try
- {
- if (checkBox3.Checked) checkBox3.Image = imageList1.Images[0];
- else checkBox3.Image = imageList1.Images[1];
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void checkBox4_CheckedChanged(object sender, EventArgs e)
- {
- try
- {
- if (checkBox4.Checked) checkBox4.Image = imageList1.Images[0];
- else checkBox4.Image = imageList1.Images[1];
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- }
- }
|