3d1538875931362b0131b6d4037474eafa288bcf.svn-base 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Forms;
  6. using Janus.Windows.EditControls;
  7. namespace IControls_FireManager
  8. {
  9. // 크로스 스레드 에러 문제 해결 :
  10. public static class _Crossthread
  11. {
  12. ///
  13. /// CallBack Attribute
  14. ///
  15. // 폼의 텍스트를 변경하는 경우
  16. delegate void CallBack_Form_SetText(Form target, string text);
  17. // 폼을 나타내는 경우
  18. delegate void CallBack_Form_Show(Form target);
  19. // 컨트롤 텍스트를 변경하는 경우 (일반 텍스트박스 혹은 라벨이 해당됨)
  20. delegate void CallBack_Control_SetText(Control target, string text);
  21. // 컨트롤 활성화를 변경하는 경우
  22. delegate void CallBack_Control_SetEnable(Control target, bool Enable);
  23. // 컨트롤 포커스를 지정하는 경우
  24. delegate void CallBack_Control_SetFocus(Control target);
  25. // 프로그레스바의 값을 변경하는 경우
  26. delegate void CallBack_UIProgressBar_Value(UIProgressBar target, int Value);
  27. ///
  28. /// Target UI : Form
  29. ///
  30. public static void Form_SetText(Form target, string text)
  31. {
  32. if (target.InvokeRequired)
  33. {
  34. CallBack_Form_SetText d = new CallBack_Form_SetText(Form_SetText);
  35. target.Invoke(d, new object[] { target, text });
  36. }
  37. else
  38. {
  39. target.Text = text;
  40. }
  41. }
  42. public static void Form_Close(Form target)
  43. {
  44. if (target.InvokeRequired)
  45. {
  46. CallBack_Form_Show d = new CallBack_Form_Show(Form_Show);
  47. target.Invoke(d, new object[] { target });
  48. }
  49. else
  50. {
  51. target.Close();
  52. }
  53. }
  54. public static void Form_Show(Form target)
  55. {
  56. if (target.InvokeRequired)
  57. {
  58. CallBack_Form_Show d = new CallBack_Form_Show(Form_Show);
  59. target.Invoke(d, new object[] { target });
  60. }
  61. else
  62. {
  63. target.Show();
  64. }
  65. }
  66. public static void Form_Hide(Form target)
  67. {
  68. if (target.InvokeRequired)
  69. {
  70. CallBack_Form_Show d = new CallBack_Form_Show(Form_Show);
  71. target.Invoke(d, new object[] { target });
  72. }
  73. else
  74. {
  75. target.Hide();
  76. }
  77. }
  78. ///
  79. /// Target UI : Control
  80. ///
  81. public static void Control_SetText(Control target, string text)
  82. {
  83. if (target.InvokeRequired)
  84. {
  85. CallBack_Control_SetText d = new CallBack_Control_SetText(Control_SetText);
  86. target.Invoke(d, new object[] { target, text });
  87. }
  88. else
  89. {
  90. target.Text = text;
  91. }
  92. }
  93. public static void Control_SetEnable(Control target, bool Enable)
  94. {
  95. if (target.InvokeRequired)
  96. {
  97. CallBack_Control_SetEnable d = new CallBack_Control_SetEnable(Control_SetEnable);
  98. target.Invoke(d, new object[] { target, Enable });
  99. }
  100. else
  101. {
  102. target.Enabled = Enable;
  103. }
  104. }
  105. public static void Control_SetFocus(Control target)
  106. {
  107. if (target.InvokeRequired)
  108. {
  109. CallBack_Control_SetFocus d = new CallBack_Control_SetFocus(Control_SetFocus);
  110. target.Invoke(d, new object[] { target });
  111. }
  112. else
  113. {
  114. target.Focus();
  115. }
  116. }
  117. ///
  118. /// Target UI : UIProgressBar
  119. ///
  120. public static void UIProgressBar_SetValue(UIProgressBar target, int Value)
  121. {
  122. if (target.InvokeRequired)
  123. {
  124. CallBack_UIProgressBar_Value d = new CallBack_UIProgressBar_Value(UIProgressBar_SetValue);
  125. target.Invoke(d, new object[] { target, Value });
  126. }
  127. else
  128. {
  129. target.Value = Value;
  130. }
  131. }
  132. }
  133. }