frmPopup.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using CoreFS.CA06;
  5. using Infragistics.Win;
  6. using Infragistics.Win.Misc;
  7. using Infragistics.Win.UltraWinEditors;
  8. namespace Core.StlMes.Client.LgCommon
  9. {
  10. public partial class frmPopup : Form
  11. {
  12. protected Color _BACKCOLOR = Color.FromArgb(202, 222, 247);
  13. public frmPopup()
  14. {
  15. InitializeComponent();
  16. this.KeyPreview = true;
  17. SetModelFormStyle();
  18. }
  19. protected override void OnLoad(EventArgs e)
  20. {
  21. base.OnLoad(e);
  22. SetControlStyle(this);
  23. ClsControlPack.SetUltraGridAppearance(this);
  24. this.Location = ClsControlPack.GetChildWindowLocation(this.Size);
  25. }
  26. protected override void OnKeyPress(KeyPressEventArgs e)
  27. {
  28. base.OnKeyPress(e);
  29. if (e.KeyChar == (char)Keys.Escape)
  30. {
  31. this.Close();
  32. }
  33. }
  34. public new Color BackColor
  35. {
  36. get { return _BACKCOLOR; }
  37. set
  38. {
  39. if (_BACKCOLOR != base.BackColor)
  40. base.BackColor = _BACKCOLOR;
  41. }
  42. }
  43. public new FormBorderStyle FormBorderStyle
  44. {
  45. get { return FormBorderStyle.FixedDialog; }
  46. set { base.FormBorderStyle = FormBorderStyle.FixedDialog; }
  47. }
  48. public new bool MaximizeBox
  49. {
  50. get { return false; }
  51. set { base.MaximizeBox = false; }
  52. }
  53. public new bool MinimizeBox
  54. {
  55. get { return false; }
  56. set { base.MinimizeBox = false; }
  57. }
  58. public new FormWindowState WindowState
  59. {
  60. get { return FormWindowState.Normal; }
  61. set { base.WindowState = FormWindowState.Normal; }
  62. }
  63. public new FormStartPosition StartPosition
  64. {
  65. get { return FormStartPosition.Manual; }
  66. set { base.StartPosition = FormStartPosition.Manual; }
  67. }
  68. public new bool ShowInTaskbar
  69. {
  70. get { return false; }
  71. set { base.ShowInTaskbar = false; }
  72. }
  73. public new bool TopMost
  74. {
  75. get { return true; }
  76. set { if (!base.TopMost) base.TopMost = true; }
  77. }
  78. private void SetModelFormStyle()
  79. {
  80. this.BackColor = Color.Gainsboro;
  81. this.FormBorderStyle = FormBorderStyle.FixedDialog;
  82. this.MaximizeBox = false;
  83. this.MinimizeBox = false;
  84. this.TopMost = true;
  85. this.WindowState = FormWindowState.Normal;
  86. this.StartPosition = FormStartPosition.Manual;
  87. this.ShowInTaskbar = false;
  88. }
  89. private void SetControlAppearance(Control ctrl)
  90. {
  91. try
  92. {
  93. if (ClsControlPack.SpecificType(ctrl, typeof(Form)))
  94. ctrl.BackColor = _BACKCOLOR;
  95. else if (ctrl.GetType().Equals(typeof(Panel)))
  96. ctrl.BackColor = _BACKCOLOR;
  97. else if (ctrl.GetType().Equals(typeof(GroupBox)))
  98. ctrl.BackColor = _BACKCOLOR;
  99. else if (ctrl.GetType().Equals(typeof(ToolStrip)))
  100. ctrl.BackColor = _BACKCOLOR;
  101. else if (ClsControlPack.SpecificType(ctrl, typeof(Label)))
  102. ctrl.BackColor = _BACKCOLOR;
  103. else if (ClsControlPack.SpecificType(ctrl, typeof(UserControl)))
  104. ctrl.BackColor = _BACKCOLOR;
  105. if (ClsControlPack.SpecificType(ctrl, typeof(ControlBase)) &&
  106. !ClsControlPack.SpecificType(ctrl, typeof(EditorButtonControlBase)))
  107. ((ControlBase)ctrl).Appearance.BackColor = _BACKCOLOR;
  108. else if (ClsControlPack.SpecificType(ctrl, typeof(UltraGroupBox)))
  109. {
  110. ((UltraGroupBox)ctrl).ViewStyle = GroupBoxViewStyle.Default;
  111. ((UltraGroupBox)ctrl).HeaderBorderStyle = UIElementBorderStyle.RaisedSoft;
  112. ((UltraGroupBox)ctrl).BorderStyle = GroupBoxBorderStyle.Rectangular3D;
  113. ((UltraGroupBox)ctrl).Appearance.BackColor = _BACKCOLOR;
  114. ((UltraGroupBox)ctrl).Appearance.BackColor2 = _BACKCOLOR;
  115. }
  116. else if (ClsControlPack.SpecificType(ctrl, typeof(UltraPanel)))
  117. ((UltraPanel)ctrl).Appearance.BackColor = _BACKCOLOR;
  118. }
  119. catch { }
  120. }
  121. private void SetControlStyle(Control parentCtrl)
  122. {
  123. try
  124. {
  125. SetControlAppearance(parentCtrl);
  126. foreach (Control ctrl in parentCtrl.Controls)
  127. {
  128. SetControlStyle(ctrl);
  129. }
  130. }
  131. catch { }
  132. }
  133. }
  134. }