SimpleTitleForm.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using Azylee.WinformSkin.APIUtils;
  2. using Azylee.WinformSkin.FormUI.NoTitle;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. namespace Azylee.WinformSkin.FormUI.CustomTitle
  12. {
  13. public partial class SimpleTitleForm : NoTitleForm
  14. {
  15. private int HeadHeight = 52;
  16. public SimpleTitleForm()
  17. {
  18. InitializeComponent();
  19. }
  20. private void SimpleTitleForm_Load(object sender, EventArgs e)
  21. {
  22. HeadHeight = PNHead.Height;
  23. PBHeadIcon.Image = Icon.ToBitmap();
  24. }
  25. #region 窗口设置
  26. public void SetIcon()
  27. {
  28. }
  29. #endregion
  30. #region 窗口操作:拖动、边框、最小化、最大化、还原、双击标题栏最大化、拖动标题栏还原、关闭
  31. /// <summary>
  32. /// 拖动窗口移动
  33. /// </summary>
  34. /// <param name="sender"></param>
  35. /// <param name="e"></param>
  36. private void LBHeadTitle_MouseMove(object sender, MouseEventArgs e)
  37. {
  38. if (e.Button == MouseButtons.Left)
  39. {
  40. FormStyleAPI.ReleaseCapture();
  41. FormStyleAPI.SendMessage(Handle, FormStyleAPI.WM_NCLBUTTONDOWN, FormStyleAPI.HTCAPTION, 0);
  42. }
  43. }
  44. /// <summary>
  45. /// 大小改变,刷新边框
  46. /// </summary>
  47. /// <param name="sender"></param>
  48. /// <param name="e"></param>
  49. private void DarkTitleForm_SizeChanged(object sender, EventArgs e)
  50. {
  51. SetBorder();
  52. PNHead.Height = HeadHeight;
  53. }
  54. /// <summary>
  55. /// 最小化
  56. /// </summary>
  57. /// <param name="sender"></param>
  58. /// <param name="e"></param>
  59. private void BTFormMinBox_Click(object sender, EventArgs e)
  60. {
  61. WindowState = FormWindowState.Minimized;
  62. }
  63. /// <summary>
  64. /// 最大化及还原
  65. /// </summary>
  66. /// <param name="sender"></param>
  67. /// <param name="e"></param>
  68. private void BTFormMaxBox_Click(object sender, EventArgs e)
  69. {
  70. if (WindowState != FormWindowState.Maximized)
  71. WindowState = FormWindowState.Maximized;
  72. else
  73. WindowState = FormWindowState.Normal;
  74. }
  75. private void LBHeadTitle_DoubleClick(object sender, EventArgs e)
  76. {
  77. if (WindowState != FormWindowState.Maximized)
  78. WindowState = FormWindowState.Maximized;
  79. else
  80. WindowState = FormWindowState.Normal;
  81. }
  82. /// <summary>
  83. /// 关闭
  84. /// </summary>
  85. /// <param name="sender"></param>
  86. /// <param name="e"></param>
  87. private void BTFormCloseBox_Click(object sender, EventArgs e)
  88. {
  89. Close();
  90. }
  91. #endregion
  92. }
  93. }