frmModalUnitDataSelect.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. namespace FPER
  9. {
  10. public partial class frmModalUnitDataSelect : Form
  11. {
  12. // cyim 2015.2.23 회로차단시에는 사용불가 : 생성자 Overloading
  13. public frmModalUnitDataSelect(RepeaterDeviceTypeInfo Info)
  14. {
  15. InitializeComponent();
  16. if (Info.RepeaterType == "A")
  17. {
  18. if (Info.outDeviceTypeInfos[0] == null || Info.outDeviceTypeInfos[0].CutFlag == true)
  19. { checkBox1.Enabled = false; label0.BackColor = Color.Gray; }
  20. if (Info.outDeviceTypeInfos[1] == null || Info.outDeviceTypeInfos[1].CutFlag == true)
  21. { checkBox2.Enabled = false; label1.BackColor = Color.Gray; }
  22. }
  23. else if (Info.RepeaterType == "B")
  24. {
  25. if (Info.outDeviceTypeInfos[0] == null || Info.outDeviceTypeInfos[0].CutFlag == true)
  26. { checkBox1.Enabled = false; label0.BackColor = Color.Gray; }
  27. if (Info.outDeviceTypeInfos[1] == null || Info.outDeviceTypeInfos[1].CutFlag == true)
  28. { checkBox2.Enabled = false; label1.BackColor = Color.Gray; }
  29. if (Info.outDeviceTypeInfos[2] == null || Info.outDeviceTypeInfos[2].CutFlag == true)
  30. { checkBox3.Enabled = false; label2.BackColor = Color.Gray; }
  31. if (Info.outDeviceTypeInfos[3] == null || Info.outDeviceTypeInfos[3].CutFlag == true)
  32. { checkBox4.Enabled = false; label3.BackColor = Color.Gray; }
  33. }
  34. // cyim 2015.6.8 아날로그 감지기 연동 추가
  35. else if (Info.RepeaterType == "C" || Info.RepeaterType == "D")
  36. {
  37. if (Info.outDeviceTypeInfos[0] == null || Info.outDeviceTypeInfos[0].CutFlag == true)
  38. { checkBox1.Enabled = false; label0.BackColor = Color.Gray; }
  39. }
  40. }
  41. //입력값을 받고, 넘기기위한 VO
  42. private InputIDVo inputVo;
  43. public InputIDVo InputVo { get { return this.inputVo; } set { this.inputVo = value; } }
  44. //화면이동을 위해---------------
  45. private Boolean MoveOK = true;
  46. private Point mouseOffset;
  47. /********************************************************/
  48. /* MdiParent 화면이동 */
  49. /********************************************************/
  50. private void frmModalUnitDataSelect_MouseDown(object sender, MouseEventArgs e)
  51. {
  52. try
  53. {
  54. if (MoveOK)
  55. {
  56. mouseOffset = new Point(-e.X, -e.Y);
  57. }
  58. }
  59. catch (Exception ex)
  60. {
  61. Util.UErrorMessage(ex, 0, 0);
  62. }
  63. }
  64. private void frmModalUnitDataSelect_MouseMove(object sender, MouseEventArgs e)
  65. {
  66. try
  67. {
  68. if (MoveOK && (e.Button == MouseButtons.Left))
  69. {
  70. Point mousePos = Control.MousePosition;
  71. mousePos.Offset(mouseOffset.X, mouseOffset.Y);
  72. this.Location = mousePos;
  73. }
  74. }
  75. catch (Exception ex)
  76. {
  77. Util.UErrorMessage(ex, 0, 0);
  78. }
  79. }
  80. /********************************************************/
  81. private void frmModalUnitDataSelect_Load(object sender, EventArgs e)
  82. {
  83. try
  84. {
  85. checkBox1.Image = imageList1.Images[1];
  86. checkBox2.Image = imageList1.Images[1];
  87. checkBox3.Image = imageList1.Images[1];
  88. checkBox4.Image = imageList1.Images[1];
  89. checkBox1.Checked = false;
  90. checkBox2.Checked = false;
  91. checkBox3.Checked = false;
  92. checkBox4.Checked = false;
  93. if (inputVo != null)
  94. {
  95. if (inputVo.InoutType.Equals("I"))
  96. {
  97. //입력쓰기
  98. lblTitle.Text = "입력쓰기";
  99. InputDeviceStatus[] devData = inputVo.InputUnitData;
  100. if (inputVo.RepeaterType.Equals("A"))
  101. {
  102. checkBox3.Enabled = false;
  103. checkBox4.Enabled = false;
  104. if (devData[0] == InputDeviceStatus.Use) checkBox1.Checked = true; //ON
  105. if (devData[1] == InputDeviceStatus.Use) checkBox2.Checked = true; //ON
  106. }
  107. else if (inputVo.RepeaterType.Equals("B"))
  108. {
  109. if (devData[0] == InputDeviceStatus.Use) checkBox1.Checked = true; //ON
  110. if (devData[1] == InputDeviceStatus.Use) checkBox2.Checked = true; //ON
  111. if (devData[2] == InputDeviceStatus.Use) checkBox3.Checked = true; //ON
  112. if (devData[3] == InputDeviceStatus.Use) checkBox4.Checked = true; //ON
  113. }
  114. // cyim 2015.6.8 아날로그 감지기 연동 추가
  115. else if (inputVo.RepeaterType.Equals("C") || inputVo.RepeaterType.Equals("D"))
  116. {
  117. checkBox2.Enabled = false;
  118. checkBox3.Enabled = false;
  119. checkBox4.Enabled = false;
  120. // 아날로그 감지기는 1개만 출력쓰기가 가능하다 (차후에 방지해야 되는지는 차후에 살펴봄)
  121. if (devData[0] == InputDeviceStatus.Use) checkBox1.Checked = true; //ON
  122. }
  123. }
  124. else
  125. {
  126. //출력쓰기
  127. lblTitle.Text = "출력쓰기";
  128. OutputDeviceStatus[] devData = inputVo.OutputUnitData;
  129. if (inputVo.RepeaterType.Equals("A"))
  130. {
  131. checkBox3.Enabled = false;
  132. checkBox4.Enabled = false;
  133. if (devData[0] == OutputDeviceStatus.Write) checkBox1.Checked = true; //ON
  134. if (devData[1] == OutputDeviceStatus.Write) checkBox2.Checked = true; //ON
  135. }
  136. else if (inputVo.RepeaterType.Equals("B"))
  137. {
  138. if (devData[0] == OutputDeviceStatus.Write) checkBox1.Checked = true; //ON
  139. if (devData[1] == OutputDeviceStatus.Write) checkBox2.Checked = true; //ON
  140. if (devData[2] == OutputDeviceStatus.Write) checkBox3.Checked = true; //ON
  141. if (devData[3] == OutputDeviceStatus.Write) checkBox4.Checked = true; //ON
  142. }
  143. // cyim 2015.6.8 아날로그 감지기 연동 추가
  144. else if (inputVo.RepeaterType.Equals("C") || inputVo.RepeaterType.Equals("D"))
  145. {
  146. checkBox2.Enabled = false;
  147. checkBox3.Enabled = false;
  148. checkBox4.Enabled = false;
  149. // 아날로그 감지기는 1개만 출력쓰기가 가능하다 (차후에 방지해야 되는지는 차후에 살펴봄)
  150. if (devData[0] == OutputDeviceStatus.Write) checkBox1.Checked = true; //ON
  151. }
  152. }
  153. }
  154. }
  155. catch (Exception ex)
  156. {
  157. Util.UErrorMessage(ex, 0, 0);
  158. }
  159. }
  160. private void btnClose_Click(object sender, EventArgs e)
  161. {
  162. try
  163. {
  164. this.inputVo.InputOK = false;
  165. this.Close();
  166. }
  167. catch (Exception ex)
  168. {
  169. Util.UErrorMessage(ex, 0, 0);
  170. }
  171. }
  172. private void btnOK_Click(object sender, EventArgs e)
  173. {
  174. try
  175. {
  176. if (inputVo.InoutType.Equals("I"))
  177. {
  178. InputDeviceStatus[] devData = new InputDeviceStatus[4];
  179. devData[0] = checkBox1.Checked ? InputDeviceStatus.Use : InputDeviceStatus.Normal;
  180. devData[1] = checkBox2.Checked ? InputDeviceStatus.Use : InputDeviceStatus.Normal;
  181. devData[2] = checkBox3.Checked ? InputDeviceStatus.Use : InputDeviceStatus.Normal;
  182. devData[3] = checkBox4.Checked ? InputDeviceStatus.Use : InputDeviceStatus.Normal;
  183. this.inputVo.InputUnitData = devData;
  184. this.inputVo.InputOK = true;
  185. }
  186. else
  187. {
  188. OutputDeviceStatus[] devData = new OutputDeviceStatus[4];
  189. devData[0] = checkBox1.Checked ? OutputDeviceStatus.Write : OutputDeviceStatus.NotWrite;
  190. devData[1] = checkBox2.Checked ? OutputDeviceStatus.Write : OutputDeviceStatus.NotWrite;
  191. devData[2] = checkBox3.Checked ? OutputDeviceStatus.Write : OutputDeviceStatus.NotWrite;
  192. devData[3] = checkBox4.Checked ? OutputDeviceStatus.Write : OutputDeviceStatus.NotWrite;
  193. this.inputVo.OutputUnitData = devData;
  194. this.inputVo.InputOK = true;
  195. }
  196. this.Close();
  197. }
  198. catch (Exception ex)
  199. {
  200. Util.UErrorMessage(ex, 0, 0);
  201. }
  202. }
  203. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  204. {
  205. try
  206. {
  207. if (checkBox1.Checked) checkBox1.Image = imageList1.Images[0];
  208. else checkBox1.Image = imageList1.Images[1];
  209. }
  210. catch (Exception ex)
  211. {
  212. Util.UErrorMessage(ex, 0, 0);
  213. }
  214. }
  215. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  216. {
  217. try
  218. {
  219. if (checkBox2.Checked) checkBox2.Image = imageList1.Images[0];
  220. else checkBox2.Image = imageList1.Images[1];
  221. }
  222. catch (Exception ex)
  223. {
  224. Util.UErrorMessage(ex, 0, 0);
  225. }
  226. }
  227. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  228. {
  229. try
  230. {
  231. if (checkBox3.Checked) checkBox3.Image = imageList1.Images[0];
  232. else checkBox3.Image = imageList1.Images[1];
  233. }
  234. catch (Exception ex)
  235. {
  236. Util.UErrorMessage(ex, 0, 0);
  237. }
  238. }
  239. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  240. {
  241. try
  242. {
  243. if (checkBox4.Checked) checkBox4.Image = imageList1.Images[0];
  244. else checkBox4.Image = imageList1.Images[1];
  245. }
  246. catch (Exception ex)
  247. {
  248. Util.UErrorMessage(ex, 0, 0);
  249. }
  250. }
  251. }
  252. }