16505a881536fce488654eb9f295ae0e6fbf499a.svn-base 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Forms;
  6. using System.Drawing; // Color
  7. using Janus.Windows.Ribbon;
  8. using Janus.Windows.EditControls;
  9. namespace IControls_FireManager
  10. {
  11. // 팝업 메세지는 여기 클래스에서 전담한다
  12. /// <summary>
  13. /// 지정자 정의
  14. /// </summary>
  15. // 팝업 타입
  16. public enum Popup_Type
  17. {
  18. Confirm, Dialog, Progress, ConfirmNoBtn
  19. }
  20. // 확인 팝업 타입중 세분화시킨 타입
  21. public enum Popup_Style
  22. {
  23. Normal, Return, Alarm
  24. }
  25. public static class _Popup
  26. {
  27. ///
  28. /// 모달 메세지 박스 (윈도우에서 기본적으로 제공하는 팝업창)
  29. /// 제어권을 반납하지 않으므로 켜져있는동안 부모 윈도우에서 작업을 하지 못하므로 사용에 주의바람.
  30. ///
  31. // 타입은 아래와 같다
  32. //public enum MessageBoxButtons
  33. //{
  34. // // 요약:
  35. // // 메시지 상자에 확인 단추가 있습니다.
  36. // OK = 0,
  37. // //
  38. // // 요약:
  39. // // 메시지 상자에 확인 및 취소 단추가 있습니다.
  40. // OKCancel = 1,
  41. // //
  42. // // 요약:
  43. // // 메시지 상자에 중단, 다시 시도 및 무시 단추가 있습니다
  44. // AbortRetryIgnore = 2,
  45. // //
  46. // // 요약:
  47. // // 메시지 상자에 예, 아니요 및 취소 단추가 있습니다.
  48. // YesNoCancel = 3,
  49. // //
  50. // // 요약:
  51. // // 메시지 상자에 예 및 아니요 단추가 있습니다.
  52. // YesNo = 4,
  53. // //
  54. // // 요약:
  55. // // 메시지 상자에 다시 시도 및 취소 단추가 있습니다.
  56. // RetryCancel = 5,
  57. //}
  58. public static DialogResult MessageBoxPopup_Dialog(MessageBoxButtons Type, string Message, string ButtonText)
  59. {
  60. return MessageBox.Show(Message, ButtonText, Type);
  61. }
  62. public static void MessageBoxPopup(MessageBoxButtons Type, string Message, string ButtonText)
  63. {
  64. MessageBox.Show(Message, ButtonText, Type);
  65. }
  66. ///
  67. /// 모달리스 메세지 박스 (팝업 윈도우를 동적 생성함)
  68. /// 팝업창을 닫지 않아도 부모에 제어권이 유지되는 장점이 있지만, 종료 및 기타 이벤트 처리를 직접 구현해야하므로 타입에 맞게 이벤트 핸들러를 등록해야 함.
  69. /// 단,타입에 따라 배경색도 바뀌고 텍스트 글자 길이에 의해 가변적으로 창 사이즈가 변경된다
  70. ///
  71. // 팝업창은 3가지 타입이 있다.
  72. // 1.알림 팝업 (버튼 : OK, 일반 / 복구 / 경보 에 의해 배경색이 변경)
  73. // 2.대화 팝업 (버튼 : Yes / NO , 사용자의 선택을 유도함)
  74. // 3.진행 팝업 (버튼 : OK, 시간 진행 혹은 작업 진행 순으로 진행바가 늘어남)
  75. //
  76. // 알림 팝업 (Confirm)
  77. //
  78. // 예시
  79. //// 일반 팝업
  80. // _Popup.Create(Popup_Type.Confirm,Popup_Style.Normal, _Text.OK, 250, 150, _Text.SaveDataInform,0);
  81. // // 복귀 팝업
  82. // _Popup.Create(Popup_Type.Confirm,Popup_Style.Return, _Text.OK, 600, 150, "ㄴㅇ란ㅇ란ㅇㄹㄴㅇ러ㅏㅣㄴㅇ러ㅏㅣㄴㅇ러ㅏㅣㄴㅇㄹㄴㅇ러ㅏㅣㅓㅏㅣㄴㅇ러ㅏㅣ",0);
  83. //// 경보 팝업
  84. // _Popup.Create(Popup_Type.Confirm,Popup_Style.Alarm, _Text.OK, 250, 150, _Text.SaveDataInform,0);
  85. //
  86. // 대화 팝업 (Dialog)
  87. //
  88. // 예시
  89. //Form test = new Form();
  90. //private void button2_Click(object sender, EventArgs e)
  91. //{
  92. // // 대화 팝업
  93. // test = _Popup.Create(Popup_Type.Dialog, Popup_Style.Normal, _Text.OK, 250, 150, _Text.SaveDataInform,0);
  94. // // 대화 팝업은 특별처리
  95. // _Event.PopupClose_SendMessage_Event += new _Event.PopupClose_SendMessage_Handler(_Event_PopupClose_SendMessage_Event);
  96. //}
  97. //public void _Event_PopupClose_SendMessage_Event(object sender, object etc)
  98. //{
  99. // // 대화 팝업 주체
  100. // Form popup = (Form)sender;
  101. // if (test.Name == popup.Name && etc.ToString() == _Text.OK)
  102. // {
  103. // ;
  104. // }
  105. // // 대화 팝업은 특별처리
  106. // _Event.PopupClose_SendMessage_Event -= new _Event.PopupClose_SendMessage_Handler(_Event_PopupClose_SendMessage_Event);
  107. //}
  108. //
  109. // 진행 팝업 (Progress)
  110. //
  111. // 예시
  112. //Form_Popup tst = new Form();
  113. //private void button2_Click(object sender, EventArgs e)
  114. //{
  115. // // 진행 팝업
  116. // test = _Popup.Create(Popup_Type.Progress, Popup_Style.Normal, _Text.OK, 250, 200, _Text.SaveDataInform, 10);
  117. //}
  118. //static int a = 0;
  119. //// 타이머 시작버튼 (기본 타이머 사용 , interval 은 250)
  120. //private void uiButton1_Click(object sender, EventArgs e)
  121. //{
  122. // a = 0;
  123. // timer1.Start();
  124. //}
  125. //// 타이머 tick 핸들러
  126. //private void timer1_Tick(object sender, EventArgs e)
  127. //{
  128. // // 클릭하면서 카운터가 증가한다
  129. // _Event.ProgressPopupCount_SendMessage(test, ++a);
  130. //}
  131. // 모달리스 메세지 팝업중에 진행 팝업 타입에서만 사용하는 변수
  132. // 진행 팝업 활성화 상태
  133. public static bool ProcessPopup_Enable = false;
  134. // 진행 팝업 프로그레스바 총 프로세스 개수
  135. public static int ProcessPopup_Processbar_AllCnt = 0;
  136. // 진행 팝업 프로그레스바 현재 프로세스
  137. public static int ProcessPopup_Processbar_Cnt = 0;
  138. public static UIProgressBar ProcessPopup_progressbar = null;
  139. // 생성자
  140. public static Form Create(
  141. Popup_Type Type, Popup_Style Style,
  142. string FormText, int FormWidth, int FormHeight,
  143. string ContentsText,
  144. int ProgressbarAllcount)
  145. {
  146. // 진행타입 체크 (프로그레스바의 경우 진행중이엿다면 관련 변수는 모두 초기화하고 진행한다) // cyim 2013.5.27
  147. if (Type == Popup_Type.Progress && (ProcessPopup_Enable == true || ProgressbarAllcount <= 0))
  148. {
  149. ProcessPopup_Enable = false;
  150. ProcessPopup_Processbar_AllCnt = 0;
  151. ProcessPopup_Processbar_Cnt = 0;
  152. //return null;
  153. }
  154. // 팝업창
  155. Form Popup = new Form();
  156. // 폼 스타일에 의하여 아래의 변수가 변경됨
  157. Office2007ColorScheme HeaderScheme = Office2007ColorScheme.Default;
  158. Color HeaderColor = new Color();
  159. //Color FormBackground = new Color();
  160. Janus.Windows.UI.Dock.PanelVisualStyle GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Office2007;
  161. Janus.Windows.UI.Office2007ColorScheme ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Default;
  162. switch (Style)
  163. {
  164. case Popup_Style.Normal:
  165. if (_Data.Style_VisualStyle == Janus.Windows.UI.VisualStyle.Office2007)
  166. {
  167. HeaderScheme = Office2007ColorScheme.Custom;
  168. HeaderColor = System.Drawing.SystemColors.GradientInactiveCaption;
  169. //FormBackground = System.Drawing.SystemColors.InactiveCaptionText;
  170. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Office2007;
  171. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Blue;
  172. }
  173. else if (_Data.Style_VisualStyle == Janus.Windows.UI.VisualStyle.Office2003)
  174. {
  175. HeaderScheme = Office2007ColorScheme.Custom;
  176. HeaderColor = System.Drawing.SystemColors.GradientInactiveCaption;
  177. //FormBackground = System.Drawing.SystemColors.InactiveCaptionText;
  178. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Office2003;
  179. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Blue;
  180. }
  181. else if (_Data.Style_VisualStyle == Janus.Windows.UI.VisualStyle.Standard)
  182. {
  183. HeaderScheme = Office2007ColorScheme.Custom;
  184. HeaderColor = System.Drawing.Color.DarkGray;
  185. //FormBackground = System.Drawing.SystemColors.Control;
  186. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Standard;
  187. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Default;
  188. }
  189. else if (_Data.Style_VisualStyle == Janus.Windows.UI.VisualStyle.VS2005)
  190. {
  191. HeaderScheme = Office2007ColorScheme.Custom;
  192. HeaderColor = System.Drawing.Color.LightGray;
  193. //FormBackground = System.Drawing.SystemColors.ControlLight;
  194. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.VS2005;
  195. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Default;
  196. }
  197. else
  198. {
  199. HeaderScheme = Office2007ColorScheme.Custom;
  200. HeaderColor = System.Drawing.SystemColors.GradientInactiveCaption;
  201. //FormBackground = System.Drawing.SystemColors.InactiveCaptionText;
  202. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Office2007;
  203. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Default;
  204. }
  205. break;
  206. case Popup_Style.Alarm:
  207. HeaderScheme = Office2007ColorScheme.Custom;
  208. HeaderColor = Color.Red;
  209. //FormBackground = Color.Tomato;
  210. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Office2007;
  211. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Custom;
  212. break;
  213. case Popup_Style.Return:
  214. HeaderScheme = Office2007ColorScheme.Custom;
  215. HeaderColor = Color.Gold;
  216. //FormBackground = Color.LemonChiffon;
  217. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Office2007;
  218. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Custom;
  219. break;
  220. }
  221. // 위치 : 가운데 생성
  222. Popup.StartPosition = FormStartPosition.CenterScreen;
  223. // 폼텍스트
  224. Popup.Text = FormText;
  225. // 폼크기
  226. Popup.Size = new Size(FormWidth + ContentsText.Length, FormHeight);
  227. // 제일 위로 보이게 한다
  228. Popup.TopMost = true;
  229. // 폼의 배경색
  230. Popup.BackColor = System.Drawing.SystemColors.Control; //FormBackground
  231. // 폼의 컨트롤박스는 삭제
  232. Popup.ControlBox = false;
  233. // 폼 사이즈 변경 금지
  234. Popup.FormBorderStyle = FormBorderStyle.FixedSingle;
  235. // 폼 키이벤트 추가
  236. Popup.KeyPreview = true;
  237. Popup.KeyDown += new KeyEventHandler(Popup_KeyDown);
  238. // 옵션 (OfficeFormAdorner 추가)
  239. OfficeFormAdorner FormAdorner = new OfficeFormAdorner();
  240. FormAdorner.Form = Popup;
  241. FormAdorner.Office2007ColorScheme = HeaderScheme;
  242. FormAdorner.Office2007CustomColor = HeaderColor;
  243. // 옵션 (그룹박스 추가)
  244. UIGroupBox uiGroupBox = new UIGroupBox();
  245. uiGroupBox.BackgroundStyle = Janus.Windows.EditControls.BackgroundStyle.Panel;
  246. uiGroupBox.BorderColor = System.Drawing.Color.Transparent;
  247. uiGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
  248. //uiGroupBox.Location = new System.Drawing.Point(0, 0);
  249. uiGroupBox.Name = "uiGroupBox";
  250. //uiGroupBox.Size = new System.Drawing.Size(781, 442);
  251. uiGroupBox.TabIndex = 0;
  252. uiGroupBox.VisualStyle = GroupBoxPanelStyle;
  253. // 옵션 (라벨추가)
  254. Label label = new Label();
  255. // 글자
  256. label.Text = ContentsText;
  257. // 배경색
  258. label.BackColor = System.Drawing.Color.Transparent;
  259. // 라벨은 사이즈는 가변
  260. label.AutoSize = true;
  261. // 폼에 포함
  262. //Popup.Controls.Add(label);
  263. uiGroupBox.Controls.Add(label);
  264. // 팝업 태그에 라벨 추가
  265. Popup.Tag = label;
  266. // 옵션 (확인버튼추가)
  267. UIButton button_OK = new UIButton();
  268. // 이름
  269. button_OK.Name = "button_OK";
  270. // 글자
  271. if (Type == Popup_Type.Dialog)
  272. button_OK.Text = _Text.Yes;
  273. else
  274. button_OK.Text = _Text.OK;
  275. // 부모 지정
  276. button_OK.Tag = Popup;
  277. // 스타일 지정
  278. button_OK.VisualStyle = _Data.Style_VisualStyle;
  279. // 색지정
  280. button_OK.Office2007ColorScheme = ButtonScheme;
  281. button_OK.Office2007CustomColor = HeaderColor;
  282. // 이벤트 핸들러 등록
  283. if (Type == Popup_Type.Progress)
  284. button_OK.Click += new EventHandler(Progress_OK_Click);
  285. else
  286. button_OK.Click += new EventHandler(Button_OK_Click);
  287. // 버튼 보여주기 속성
  288. if (Type == Popup_Type.ConfirmNoBtn)
  289. button_OK.Visible = false;
  290. // 폼에 포함
  291. //Popup.Controls.Add(button_OK);
  292. uiGroupBox.Controls.Add(button_OK);
  293. // 옵션 (취소버튼추가)
  294. UIButton button_Cancle = new UIButton();
  295. if (Type == Popup_Type.Dialog)
  296. {
  297. // 이름
  298. button_Cancle.Name = "button_Cancle";
  299. // 글자
  300. button_Cancle.Text = _Text.No;
  301. // 부모 지정
  302. button_Cancle.Tag = Popup;
  303. // 스타일 지정
  304. button_Cancle.VisualStyle = _Data.Style_VisualStyle;
  305. // 색지정
  306. button_Cancle.Office2007ColorScheme = ButtonScheme;
  307. button_Cancle.Office2007CustomColor = HeaderColor;
  308. // 이벤트 핸들러 등록
  309. button_Cancle.Click += new EventHandler(Button_Cancle_Click);
  310. // 폼에 포함
  311. //Popup.Controls.Add(button_Cancle);
  312. uiGroupBox.Controls.Add(button_Cancle);
  313. }
  314. // 옵션 (진행 프로그레스바 추가)
  315. if (Type == Popup_Type.Progress)
  316. {
  317. // 관련 COM 변수 메모리 할당
  318. ProcessPopup_progressbar = new UIProgressBar();
  319. // 진행팝업창은 중간에 확인 버튼을 누를수가 없다
  320. button_OK.Enabled = false;
  321. // 총 진행개수
  322. ProcessPopup_Processbar_AllCnt = ProgressbarAllcount;
  323. // 현재 진행개수 초기화
  324. ProcessPopup_Processbar_Cnt = 0;
  325. // 시작
  326. ProcessPopup_Enable = true;
  327. // 진행
  328. ProcessPopup_progressbar.Value = 0;
  329. // 부모 지정
  330. ProcessPopup_progressbar.Tag = Popup;
  331. // 스타일 지정
  332. ProcessPopup_progressbar.VisualStyle = _Data.Style_VisualStyle;
  333. // 색지정
  334. ProcessPopup_progressbar.Office2007ColorScheme = ButtonScheme;
  335. ProcessPopup_progressbar.Office2007CustomColor = HeaderColor;
  336. // 진행바 크기
  337. ProcessPopup_progressbar.Width = Popup.Width / 3 * 2;
  338. ProcessPopup_progressbar.Height = 30;
  339. // 카운트 이벤트 핸들로 등록
  340. _Event.ProgressPopupCount_SendMessage_Event += new _Event.ProgressPopupCount_SendMessage_Handler(_Event_ProgressPopupCount_SendMessage_Event);
  341. // 폼에 포함
  342. //Popup.Controls.Add(ProcessPopup_progressbar);
  343. uiGroupBox.Controls.Add(ProcessPopup_progressbar);
  344. }
  345. // 보여주기
  346. Popup.StartPosition = FormStartPosition.CenterScreen;
  347. Popup.Controls.Add(uiGroupBox);// 그룹박스 추가
  348. Popup.Show();
  349. // 위치 정보
  350. switch (Type)
  351. {
  352. case Popup_Type.Confirm:
  353. case Popup_Type.ConfirmNoBtn:
  354. // 라벨 위치
  355. label.Location = new System.Drawing.Point((Popup.Width - label.Width) / 2, (Popup.Height - label.Height) / 4 * 1);
  356. // 확인 버튼 위치
  357. button_OK.Location = new System.Drawing.Point((Popup.Width - button_OK.Width) / 2 * 1, (Popup.Height - button_OK.Height) / 8 * 5);
  358. break;
  359. case Popup_Type.Dialog:
  360. // 라벨 위치
  361. label.Location = new System.Drawing.Point((Popup.Width - label.Width) / 2, (Popup.Height - label.Height) / 4 * 1);
  362. // 확인 버튼 위치
  363. button_OK.Location = new System.Drawing.Point((Popup.Width / 2) - 80, (Popup.Height - button_OK.Height) / 9 * 5);
  364. // 취소 버튼 위치
  365. button_Cancle.Location = new System.Drawing.Point((Popup.Width / 2) + 5 / 11 * 8, (Popup.Height - button_OK.Height) / 9 * 5);
  366. break;
  367. case Popup_Type.Progress:
  368. // 라벨 위치
  369. label.Location = new System.Drawing.Point((Popup.Width - label.Width) / 2, (Popup.Height - label.Height) / 5 * 1);
  370. // 프로그레스바 위치
  371. ProcessPopup_progressbar.Location = new System.Drawing.Point((Popup.Width - ProcessPopup_progressbar.Width) / 2 * 1, (Popup.Height - ProcessPopup_progressbar.Height) / 9 * 4);
  372. // 확인 버튼 위치
  373. button_OK.Location = new System.Drawing.Point((Popup.Width - button_OK.Width) / 2 * 1, (Popup.Height - button_OK.Height) / 7 * 5);
  374. break;
  375. }
  376. // 버튼 포커스 해결
  377. label.Focus();
  378. // 업데이트
  379. Popup.Update();
  380. // 팝업창 정보 리턴
  381. return Popup;
  382. }
  383. // 확인 버튼을 누르는 경우
  384. public static void Button_OK_Click(object sender, EventArgs e)
  385. {
  386. // 버튼 정보
  387. UIButton senderForm = (UIButton)sender;
  388. // 버튼의 태그를 이용하여 폼정보 받아옴
  389. Form poupup = (Form)senderForm.Tag;
  390. // 잔상 정리
  391. poupup.Hide();
  392. // 이벤트 발생
  393. _Event.PopupClose_SendMessage(poupup, _Text.OK);
  394. // 폼종료
  395. poupup.Close();
  396. }
  397. // 취소 버튼을 누르는 경우
  398. public static void Button_Cancle_Click(object sender, EventArgs e)
  399. {
  400. // 버튼 정보
  401. UIButton senderForm = (UIButton)sender;
  402. // 버튼의 태그를 이용하여 폼정보 받아옴
  403. Form poupup = (Form)senderForm.Tag;
  404. // 잔상 정리
  405. poupup.Hide();
  406. // 이벤트 발생
  407. _Event.PopupClose_SendMessage(poupup, _Text.Cancle);
  408. // 폼종료
  409. poupup.Close();
  410. }
  411. // 프로그레스 팝업 확인 버튼을 누르는 경우
  412. public static void Progress_OK_Click(object sender, EventArgs e)
  413. {
  414. // 버튼 정보
  415. UIButton senderForm = (UIButton)sender;
  416. // 버튼의 태그를 이용하여 폼정보 받아옴
  417. Form poupup = (Form)senderForm.Tag;
  418. // 잔상 정리
  419. poupup.Hide();
  420. // 이벤트 발생
  421. _Event.PopupClose_SendMessage(poupup, _Text.OK);
  422. // 현재 진행개수 초기화
  423. ProcessPopup_Processbar_Cnt = 0;
  424. // 총 진행개수 초기화
  425. ProcessPopup_Processbar_AllCnt = 0;
  426. // 시작
  427. ProcessPopup_Enable = false;
  428. // 진행 팝업
  429. _Event.ProgressPopupCount_SendMessage_Event -= new _Event.ProgressPopupCount_SendMessage_Handler(_Event_ProgressPopupCount_SendMessage_Event);
  430. // 폼종료
  431. poupup.Close();
  432. }
  433. // 특별키 처리 (O : OK , P : Cancle)
  434. public static void Popup_KeyDown(object sender, KeyEventArgs e)
  435. {
  436. switch (e.KeyCode)
  437. {
  438. case Keys.O:
  439. {
  440. // 버튼의 태그를 이용하여 폼정보 받아옴
  441. Form poupup = (Form)sender;
  442. // 잔상 정리
  443. poupup.Hide();
  444. // 이벤트 발생
  445. _Event.PopupClose_SendMessage(poupup, _Text.OK);
  446. // 폼종료
  447. poupup.Close();
  448. }
  449. break;
  450. case Keys.P:
  451. {
  452. // 버튼의 태그를 이용하여 폼정보 받아옴
  453. Form poupup = (Form)sender;
  454. // 잔상 정리
  455. poupup.Hide();
  456. // 이벤트 발생
  457. _Event.PopupClose_SendMessage(poupup, _Text.Cancle);
  458. // 폼종료
  459. poupup.Close();
  460. }
  461. break;
  462. }
  463. }
  464. // 팝업 셋팅을 위한 전용 델리게이트
  465. delegate void Popup_SetCallback(object sender, object etc);
  466. // 이벤트로 인하여 진행됨
  467. public static void _Event_ProgressPopupCount_SendMessage_Event(object sender, object etc)
  468. {
  469. // 카운터가 증가하면 포커스가 여기로
  470. Form popup = (Form)sender;
  471. if (popup == null) return;
  472. if (popup.InvokeRequired)
  473. {
  474. Popup_SetCallback d = new Popup_SetCallback(_Event_ProgressPopupCount_SendMessage_Event);
  475. popup.Invoke(d, new object[] { sender, etc });
  476. }
  477. else
  478. {
  479. popup.TopMost = true;
  480. popup.Focus();
  481. // 값
  482. ProcessPopup_Processbar_Cnt = (int)etc;
  483. // 전체 진행개수가 더 작다면 동작 안함
  484. if (ProcessPopup_Processbar_Cnt <= ProcessPopup_Processbar_AllCnt)
  485. {
  486. // 진행바 표시
  487. ProcessPopup_progressbar.Value = (int)((ProcessPopup_Processbar_Cnt * 100) / ProcessPopup_Processbar_AllCnt);
  488. // 진행바가 모두 진행되면 타이머종료
  489. if (ProcessPopup_progressbar.Value >= 100)
  490. {
  491. // 진행팝업창은 중간에 확인 버튼을 누를수가 없지만 진행이 완료되면 해제 된다
  492. Control[] Btn = popup.Controls.Find("button_OK", true);
  493. ((UIButton)Btn[0]).Enabled = true;
  494. // 팝업창의 라벨정보를 얻음
  495. Label label = (Label)(popup.Tag);
  496. // 완료되었습니다
  497. label.Text = _Data.Result_Text;
  498. // 라벨 위치
  499. label.Location = new System.Drawing.Point((popup.Width - label.Width) / 2, (popup.Height - label.Height) / 5 * 1);
  500. }
  501. }
  502. }
  503. }
  504. }
  505. //
  506. // 특별히 다이얼로그 (예: 사용자에게 예 혹은 아니오 묻는경우)의 경우에 한해서 특별처리를 위함, 반드시 Popup_Type.Dialog 에서만 사용하도록한다
  507. //
  508. public static class _PopupDialog
  509. {
  510. // 중복 처리
  511. public static string DialogPopupText = null;
  512. // 팝업창에 종료 핸들러 추가
  513. public static Form Create(
  514. Popup_Type Type, Popup_Style Style,
  515. string FormText, int FormWidth, int FormHeight,
  516. string ContentsText,
  517. _Event.PopupClose_SendMessage_Handler PopupClose_Func
  518. )
  519. {
  520. // 팝업창
  521. Form Popup = new Form();
  522. // 특별처리 다이얼로그 팝업창 (사용자의 예,아니오 선택을 유도하는 팝업창)의 경우 불필요한 중복 클릭을 방지하기 위하여 동일한 텍스트가 들어오면 못하게 방지한다
  523. // 나머지 알림의 팝업창은 중복여부와는 상관없이 활성화되도록 한다
  524. if (Type == Popup_Type.Dialog)
  525. {
  526. if (DialogPopupText == ContentsText)
  527. return Popup;
  528. else
  529. DialogPopupText = ContentsText;
  530. }
  531. else
  532. return Popup; // 나머지 타입은 받아들일수 없다
  533. if (PopupClose_Func != null)
  534. {
  535. // 폼닫을때 발생하는 이벤트 해제를 위하여 함수포인터 등록
  536. Popup.Tag = PopupClose_Func;
  537. // 폼닫기 이벤트 등록
  538. Popup.FormClosing += new FormClosingEventHandler(CreateForm_FormClosing);
  539. // 폼닫을때 발생하는 이벤트 등록
  540. _Event.PopupClose_SendMessage_Event += new _Event.PopupClose_SendMessage_Handler(PopupClose_Func);
  541. }
  542. // 폼 스타일에 의하여 아래의 변수가 변경됨
  543. Office2007ColorScheme HeaderScheme = Office2007ColorScheme.Default;
  544. Color HeaderColor = new Color();
  545. //Color FormBackground = new Color();
  546. Janus.Windows.UI.Dock.PanelVisualStyle GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Office2007;
  547. Janus.Windows.UI.Office2007ColorScheme ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Default;
  548. switch (Style)
  549. {
  550. case Popup_Style.Normal:
  551. if (_Data.Style_VisualStyle == Janus.Windows.UI.VisualStyle.Office2007)
  552. {
  553. HeaderScheme = Office2007ColorScheme.Custom;
  554. HeaderColor = System.Drawing.SystemColors.GradientInactiveCaption;
  555. //FormBackground = System.Drawing.SystemColors.InactiveCaptionText;
  556. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Office2007;
  557. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Blue;
  558. }
  559. else if (_Data.Style_VisualStyle == Janus.Windows.UI.VisualStyle.Office2003)
  560. {
  561. HeaderScheme = Office2007ColorScheme.Custom;
  562. HeaderColor = System.Drawing.SystemColors.GradientInactiveCaption;
  563. //FormBackground = System.Drawing.SystemColors.InactiveCaptionText;
  564. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Office2003;
  565. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Blue;
  566. }
  567. else if (_Data.Style_VisualStyle == Janus.Windows.UI.VisualStyle.Standard)
  568. {
  569. HeaderScheme = Office2007ColorScheme.Custom;
  570. HeaderColor = System.Drawing.Color.DarkGray;
  571. //FormBackground = System.Drawing.SystemColors.Control;
  572. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Standard;
  573. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Default;
  574. }
  575. else if (_Data.Style_VisualStyle == Janus.Windows.UI.VisualStyle.VS2005)
  576. {
  577. HeaderScheme = Office2007ColorScheme.Custom;
  578. HeaderColor = System.Drawing.Color.LightGray;
  579. //FormBackground = System.Drawing.SystemColors.ControlLight;
  580. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.VS2005;
  581. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Default;
  582. }
  583. else
  584. {
  585. HeaderScheme = Office2007ColorScheme.Custom;
  586. HeaderColor = System.Drawing.SystemColors.GradientInactiveCaption;
  587. //FormBackground = System.Drawing.SystemColors.InactiveCaptionText;
  588. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Office2007;
  589. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Default;
  590. }
  591. break;
  592. case Popup_Style.Alarm:
  593. HeaderScheme = Office2007ColorScheme.Custom;
  594. HeaderColor = Color.Red;
  595. //FormBackground = Color.Tomato;
  596. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Office2007;
  597. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Custom;
  598. break;
  599. case Popup_Style.Return:
  600. HeaderScheme = Office2007ColorScheme.Custom;
  601. HeaderColor = Color.Gold;
  602. //FormBackground = Color.LemonChiffon;
  603. GroupBoxPanelStyle = Janus.Windows.UI.Dock.PanelVisualStyle.Office2007;
  604. ButtonScheme = Janus.Windows.UI.Office2007ColorScheme.Custom;
  605. break;
  606. }
  607. // 위치 : 가운데 생성
  608. Popup.StartPosition = FormStartPosition.CenterScreen;
  609. // 폼텍스트
  610. Popup.Text = FormText;
  611. // 동적으로 팝업창 사이즈 변경
  612. FormWidth = ContentsText.Length * 10 + 100;
  613. // 폼크기
  614. Popup.Size = new Size(FormWidth + ContentsText.Length, FormHeight);
  615. // 제일 위로 보이게 한다
  616. Popup.TopMost = true;
  617. // 폼의 배경색
  618. Popup.BackColor = System.Drawing.SystemColors.Control; //FormBackground
  619. // 폼의 컨트롤박스는 삭제
  620. Popup.ControlBox = false;
  621. // 폼 사이즈 변경 금지
  622. Popup.FormBorderStyle = FormBorderStyle.FixedSingle;
  623. Popup.MaximizeBox = false;
  624. // 옵션 (OfficeFormAdorner 추가)
  625. OfficeFormAdorner FormAdorner = new OfficeFormAdorner();
  626. FormAdorner.Form = Popup;
  627. FormAdorner.Office2007ColorScheme = HeaderScheme;
  628. FormAdorner.Office2007CustomColor = HeaderColor;
  629. // 옵션 (그룹박스 추가)
  630. UIGroupBox uiGroupBox = new UIGroupBox();
  631. uiGroupBox.BackgroundStyle = Janus.Windows.EditControls.BackgroundStyle.Panel;
  632. uiGroupBox.BorderColor = System.Drawing.Color.Transparent;
  633. uiGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
  634. //uiGroupBox.Location = new System.Drawing.Point(0, 0);
  635. uiGroupBox.Name = "uiGroupBox";
  636. //uiGroupBox.Size = new System.Drawing.Size(781, 442);
  637. uiGroupBox.TabIndex = 0;
  638. uiGroupBox.VisualStyle = GroupBoxPanelStyle;
  639. // 옵션 (라벨추가)
  640. Label label = new Label();
  641. // 글자
  642. label.Text = ContentsText;
  643. // 배경색
  644. label.BackColor = System.Drawing.Color.Transparent;
  645. // 라벨은 사이즈는 가변
  646. label.AutoSize = true;
  647. // 폼에 포함
  648. //Popup.Controls.Add(label);
  649. uiGroupBox.Controls.Add(label);
  650. // 팝업 태그에 라벨 추가
  651. //Popup.Tag = label;
  652. // 옵션 (확인버튼추가)
  653. UIButton button_OK = new UIButton();
  654. // 이름
  655. button_OK.Name = "button_OK";
  656. // 글자
  657. if (Type == Popup_Type.Dialog)
  658. button_OK.Text = _Text.Yes;
  659. else
  660. button_OK.Text = _Text.OK;
  661. // 부모 지정
  662. button_OK.Tag = Popup;
  663. // 스타일 지정
  664. button_OK.VisualStyle = _Data.Style_VisualStyle;
  665. // 색지정
  666. button_OK.Office2007ColorScheme = ButtonScheme;
  667. button_OK.Office2007CustomColor = HeaderColor;
  668. // 이벤트 핸들러 등록
  669. button_OK.Click += new EventHandler(Button_OK_Click);
  670. button_OK.HighlightActiveButton = false;
  671. // 버튼 보여주기 속성
  672. if (Type == Popup_Type.ConfirmNoBtn)
  673. button_OK.Visible = false;
  674. // 폼에 포함
  675. //Popup.Controls.Add(button_OK);
  676. uiGroupBox.Controls.Add(button_OK);
  677. // 옵션 (취소버튼추가)
  678. UIButton button_Cancle = new UIButton();
  679. if (Type == Popup_Type.Dialog)
  680. {
  681. // 이름
  682. button_Cancle.Name = "button_Cancle";
  683. // 글자
  684. button_Cancle.Text = _Text.No;
  685. // 부모 지정
  686. button_Cancle.Tag = Popup;
  687. // 스타일 지정
  688. button_Cancle.VisualStyle = _Data.Style_VisualStyle;
  689. // 색지정
  690. button_Cancle.Office2007ColorScheme = ButtonScheme;
  691. button_Cancle.Office2007CustomColor = HeaderColor;
  692. // 이벤트 핸들러 등록
  693. button_Cancle.Click += new EventHandler(Button_Cancle_Click);
  694. button_Cancle.HighlightActiveButton = false;
  695. // 폼에 포함
  696. //Popup.Controls.Add(button_Cancle);
  697. uiGroupBox.Controls.Add(button_Cancle);
  698. }
  699. // 보여주기
  700. Popup.StartPosition = FormStartPosition.CenterScreen;
  701. Popup.Controls.Add(uiGroupBox);// 그룹박스 추가
  702. Popup.Show();
  703. //
  704. // 위치 정보
  705. //
  706. // 라벨 위치
  707. label.Location = new System.Drawing.Point((Popup.Width - label.Width) / 2, (Popup.Height - label.Height) / 4 * 1);
  708. // 확인 버튼 위치
  709. button_OK.Location = new System.Drawing.Point((Popup.Width / 2) - 80, (Popup.Height - button_OK.Height) / 9 * 5);
  710. // 취소 버튼 위치
  711. button_Cancle.Location = new System.Drawing.Point((Popup.Width / 2) + 5 / 11 * 8, (Popup.Height - button_OK.Height) / 9 * 5);
  712. // 버튼 포커스 해결
  713. label.Focus();
  714. // 업데이트
  715. Popup.Update();
  716. // 팝업창 정보 리턴
  717. return Popup;
  718. }
  719. public static void CreateForm_FormClosing(object sender, FormClosingEventArgs e)
  720. {
  721. Form form = (Form)sender;
  722. DialogPopupText = null;// 텍스트는 초기화
  723. _Event.PopupClose_SendMessage_Event -= new _Event.PopupClose_SendMessage_Handler((_Event.PopupClose_SendMessage_Handler)form.Tag);
  724. }
  725. // 확인 버튼을 누르는 경우
  726. public static void Button_OK_Click(object sender, EventArgs e)
  727. {
  728. // 버튼 정보
  729. UIButton senderForm = (UIButton)sender;
  730. // 버튼의 태그를 이용하여 폼정보 받아옴
  731. Form poupup = (Form)senderForm.Tag;
  732. // 잔상 정리
  733. poupup.Hide();
  734. // 이벤트 발생
  735. _Event.PopupClose_SendMessage(poupup, _Text.OK);
  736. // 폼종료
  737. poupup.Close();
  738. }
  739. // 취소 버튼을 누르는 경우
  740. public static void Button_Cancle_Click(object sender, EventArgs e)
  741. {
  742. // 버튼 정보
  743. UIButton senderForm = (UIButton)sender;
  744. // 버튼의 태그를 이용하여 폼정보 받아옴
  745. Form poupup = (Form)senderForm.Tag;
  746. // 잔상 정리
  747. poupup.Hide();
  748. // 이벤트 발생
  749. _Event.PopupClose_SendMessage(poupup, _Text.Cancle);
  750. // 폼종료
  751. poupup.Close();
  752. }
  753. }
  754. }