BaseFormRelease.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.ComponentLibrary
  10. {
  11. public partial class BaseFormRelease : BaseForm360
  12. {
  13. public BaseFormRelease()
  14. {
  15. InitializeComponent();
  16. this.btnAppFormMenu.MouseClick += new MouseEventHandler(btnAppFormMenu_MouseClick);
  17. this.Load += BaseFormRelease_Load;
  18. this.BackColor = LYFZ.ComponentLibrary.GetUIResources.FrmContentBackgroundColor;
  19. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
  20. }
  21. bool isLoginValidation = false;
  22. /// <summary>
  23. /// 是否进行登录验证
  24. /// </summary>
  25. public bool IsLoginValidation
  26. {
  27. get { return isLoginValidation; }
  28. set { isLoginValidation = value; }
  29. }
  30. /// <summary>
  31. /// 登录超时提醒
  32. /// </summary>
  33. void LoginMessageBoxCustom(bool isMessageBoxCustom = true)
  34. {
  35. try
  36. {
  37. if (isMessageBoxCustom)
  38. {
  39. MessageBox.Show("用户登录超时,请重新登录。", "提示");
  40. this.Close();
  41. }
  42. }
  43. catch { }
  44. }
  45. void BaseFormRelease_Load(object sender, EventArgs e)
  46. {
  47. this.plFormMainContent.BackColor = LYFZ.ComponentLibrary.GetUIResources.FrmContentBackgroundColor;
  48. }
  49. /// <summary>
  50. /// 是否覆盖基窗体的OnPaint
  51. /// </summary>
  52. protected bool isOverrideOnPaint = false;
  53. protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  54. {
  55. base.OnPaint(e);
  56. if (!isOverrideOnPaint)
  57. {
  58. this.plFormMainContent.Location = new Point(0, this.TitleBgImageHeight);
  59. this.plFormMainContent.Width = this.Width;
  60. this.plFormMainContent.Height = this.Height - this.TitleBgImageHeight - this.BottomBgImageHeight;
  61. }
  62. }
  63. /// <summary>
  64. /// 显示系统菜单
  65. /// </summary>
  66. /// <param name="sender"></param>
  67. /// <param name="e"></param>
  68. private void btnAppFormMenu_MouseClick(object sender, MouseEventArgs e)
  69. {
  70. Button btn = sender as Button;
  71. Point point = new Point();
  72. point.Y = btn.Height;
  73. if (e.Button == MouseButtons.Left)
  74. {
  75. this.cmsSystemMeunList.Show(btn, point);
  76. }
  77. }
  78. static bool isRights = false;
  79. /// <summary>
  80. /// 是否开启权限控制
  81. /// </summary>
  82. public static bool IsRights
  83. {
  84. get { return BaseFormRelease.isRights; }
  85. set { BaseFormRelease.isRights = value; }
  86. }
  87. /// <summary>
  88. /// 设置菜单项单击事件 要在派生窗体中重写实现功能
  89. /// </summary>
  90. /// <param name="menuItem"></param>
  91. protected virtual void SetMenuItem_Click(ToolStripMenuItem menuItem)
  92. {
  93. //请在派生窗体中重写实现功能
  94. }
  95. /// <summary>
  96. /// 是否重写系统菜单
  97. /// </summary>
  98. public bool IsOverrideSystemMeun = false;
  99. protected override void CreateHandle()
  100. {
  101. if (!IsHandleCreated)
  102. {
  103. try
  104. {
  105. base.CreateHandle();
  106. }
  107. catch { }
  108. finally
  109. {
  110. if (!IsHandleCreated)
  111. {
  112. base.RecreateHandle();
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }