650e2ef90a8814f05f4eb6c447fb2be05061d47a.svn-base 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. using System.Collections;
  9. namespace FPER
  10. {
  11. // cyim 2013.8.9 타수신기 화재 정보 팝업창 출력 기능 추가
  12. // 지금 이 폼의 경우 프로그램이 실행되면서 여러개가 생성되므로 해당 수신기 아이디는 프로그램 종료직전까지 알고 있어야 한다.
  13. // 이는 _Popup.EtcReceiverFireAlarmPopup 해쉬테이블에서 관리된다
  14. // 키값은 수신기 아이디이다. 데이타는 이 클래스 자체로 관리되며 데이타중 회로번호를 키로 가지는 해쉬테이블에서 화재정보표시문구를 저장해둔다
  15. public partial class Form_Popup_OtherFireAlarm : Form
  16. {
  17. // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  18. MDIParent mdi = null;
  19. // 크로스 스레드 처리
  20. public delegate void SetText_Callback(string Data);
  21. public delegate void SetHash_Callback(Hashtable Data);
  22. public delegate void SetList_Callback(ArrayList Data);
  23. public delegate void SetForm_Callback(Form Data);
  24. // 수신기정보
  25. // 맨처음 프로그램 기동시에 데이타베이스에서 읽어 들어온다
  26. public string POPUP_RECEIVER_ID = null;
  27. public string POPUP_RECEIVER_IP = null;
  28. public string POPUP_RECEIVER_NAME = null;
  29. // 화재정보표시되는 문구
  30. public ArrayList LIST_FIRE_INFO = new ArrayList();
  31. // 생성자
  32. public Form_Popup_OtherFireAlarm(string RECEIVER_ID, MDIParent mdiparent) // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  33. {
  34. InitializeComponent();
  35. mdi = mdiparent; // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  36. // 폼로드 이벤트 핸들러 등록
  37. this.Load += new EventHandler(Form_Popup_OtherFireAlarm_Load);
  38. // 폼닫기 이벤트 핸들러 등록
  39. this.FormClosing += new FormClosingEventHandler(Form_Popup_OtherFireAlarm_FormClosing);
  40. // 팝업창 갱신 이벤트 핸들러
  41. mdi.Event.EtcFirePopup_Update_Inform_Event += new _Event.EtcFirePopup_Update_Handler(_Event_EtcFirePopup_Update_Inform_Event); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  42. // 수신기 아이디
  43. POPUP_RECEIVER_ID = RECEIVER_ID;
  44. }
  45. // 폼로드
  46. public void Form_Popup_OtherFireAlarm_Load(object sender, EventArgs e)
  47. {
  48. _Event_EtcFirePopup_Update_Inform_Event(POPUP_RECEIVER_ID);
  49. }
  50. // 폼닫기
  51. public void Form_Popup_OtherFireAlarm_FormClosing(object sender, FormClosingEventArgs e)
  52. {
  53. // 이벤트 핸들러 해제
  54. mdi.Event.EtcFirePopup_Update_Inform_Event -= new _Event.EtcFirePopup_Update_Handler(_Event_EtcFirePopup_Update_Inform_Event); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  55. }
  56. // 팝업창 갱신 이벤트 핸들러
  57. public void _Event_EtcFirePopup_Update_Inform_Event(string RECEIVER_ID)
  58. {
  59. try // cyim 2015.10.23 보완 코드 추가
  60. {
  61. // 수신기 아이디에 의하여 이벤트를 거절할 수 있다
  62. if (POPUP_RECEIVER_ID == RECEIVER_ID)
  63. {
  64. // 수신기 정보
  65. Label_Receiver_Display(string.Format("ID [{0}] - [{1} , {2}]", POPUP_RECEIVER_ID, POPUP_RECEIVER_NAME, POPUP_RECEIVER_IP));
  66. // 화재 정보
  67. if (LIST_FIRE_INFO.Count == 0)
  68. {
  69. // 화재 상태
  70. Label_Fire_Status_1th_Display("");
  71. // 화재 상태 세부
  72. Label_Fire_Status_2st_Display("");
  73. // 화재 리스트
  74. Listview_Fire_Display(null);
  75. }
  76. else
  77. {
  78. // 최신 정보
  79. string Recently_FireText = ((_FIRE_LIST)LIST_FIRE_INFO[LIST_FIRE_INFO.Count - 1]).FIRE_TEXT;
  80. string Recently_FireTime = ((_FIRE_LIST)LIST_FIRE_INFO[LIST_FIRE_INFO.Count - 1]).FIRE_TIME;
  81. string Recently_FireType = ((_FIRE_LIST)LIST_FIRE_INFO[LIST_FIRE_INFO.Count - 1]).FIRE_TYPE == true ? "화재" : "복구"; ;
  82. // 화재 상태
  83. Label_Fire_Status_1th_Display(string.Format("{0} 에 {1} 정보 수신되었습니다", Recently_FireTime, Recently_FireType)); // cyim 2014.8.6 문구 수정 및 화면폼 크게 변경
  84. // 화재 상태 세부
  85. Label_Fire_Status_2st_Display(Recently_FireText);
  86. // 모든 정보를 표시하자
  87. Listview_Fire_Display(LIST_FIRE_INFO);
  88. }
  89. // 화면 업데이트
  90. Form_Update(this);
  91. }
  92. }
  93. catch
  94. { }
  95. }
  96. // Label : 수신기 정보
  97. public void Label_Receiver_Display(string Data)
  98. {
  99. if (this.label_Receiver.InvokeRequired)
  100. {
  101. SetText_Callback d = new SetText_Callback(Label_Receiver_Display);
  102. this.label_Receiver.Invoke(d, new object[] { Data });
  103. }
  104. else
  105. {
  106. this.label_Receiver.Text = "수신기 : " + Data;
  107. }
  108. }
  109. // Label : 상태 정보
  110. public void Label_Fire_Status_1th_Display(string Data)
  111. {
  112. if (this.label_Fire_Status_1th.InvokeRequired)
  113. {
  114. SetText_Callback d = new SetText_Callback(Label_Fire_Status_1th_Display);
  115. this.label_Fire_Status_1th.Invoke(d, new object[] { Data });
  116. }
  117. else
  118. {
  119. this.label_Fire_Status_1th.Text = "상 태 : " + Data;
  120. }
  121. }
  122. // Textbox : 화재 정보
  123. public void Label_Fire_Status_2st_Display(string Data)
  124. {
  125. if (this.label_Fire_Status_2st.InvokeRequired)
  126. {
  127. SetText_Callback d = new SetText_Callback(Label_Fire_Status_2st_Display);
  128. this.label_Fire_Status_2st.Invoke(d, new object[] { Data });
  129. }
  130. else
  131. {
  132. this.label_Fire_Status_2st.Text = Data;
  133. }
  134. }
  135. // ListView : 화재 리스트
  136. public void Listview_Fire_Display(ArrayList pData)
  137. {
  138. if (this.listView_FireList.InvokeRequired)
  139. {
  140. SetList_Callback d = new SetList_Callback(Listview_Fire_Display);
  141. this.listView_FireList.Invoke(d, new object[] { pData });
  142. }
  143. else
  144. {
  145. this.listView_FireList.Items.Clear();
  146. // cyim 2016.12.06 : 이벤트 로그 해쉬테이블을 복사본으로 현재내역 조회하도록 함
  147. ArrayList Data = (ArrayList)pData.Clone();
  148. // cyim 2015.10.23 1개 및 역순출력 오류 수정
  149. if (Data != null && Data.Count != 0)
  150. {
  151. if (Data.Count == 1)
  152. {
  153. Listview_AddItem((_FIRE_LIST)Data[0]);
  154. }
  155. else
  156. {
  157. // 인덱스가 작은것이 제일 오래된 데이타이므로 역순으로 출력시킨다
  158. for (int i = Data.Count -1 ; i > -1; i--)
  159. {
  160. Listview_AddItem((_FIRE_LIST)Data[i]);
  161. }
  162. }
  163. }
  164. }
  165. }
  166. // 화재리스트 항목 추가
  167. public void Listview_AddItem(_FIRE_LIST Data)
  168. {
  169. // 시간, 타입, 항목
  170. string temp_type = Data.FIRE_TYPE == true ? "화재" : "복구";
  171. string[] data = { Data.FIRE_TIME, temp_type, Data.FIRE_TEXT };
  172. ListViewItem item = new ListViewItem(data);
  173. item.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Bold);
  174. listView_FireList.Items.Add(item);
  175. }
  176. // 폼업데이트
  177. public void Form_Update(Form Data)
  178. {
  179. if (this.InvokeRequired)
  180. {
  181. SetForm_Callback d = new SetForm_Callback(Form_Update);
  182. this.Invoke(d, new object[] { Data });
  183. }
  184. else
  185. {
  186. this.Update();
  187. }
  188. }
  189. // 창닫기 버튼
  190. private void button_FirePopupClose_Click(object sender, EventArgs e)
  191. {
  192. // 리소스 해제 금지 : 차후에 다시 알람이 발생한 경우 메모리 할당 루틴은 없다
  193. this.Hide();
  194. }
  195. }
  196. }