MainForm.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.Threading;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace HXX.Scanner.Starter
  12. {
  13. public partial class MainForm : Form
  14. {
  15. private SkinForm Skin;
  16. public MainForm()
  17. {
  18. InitializeComponent();
  19. //SetStyles();//减少闪烁
  20. ShowInTaskbar = false;//禁止控件层显示到任务栏
  21. FormBorderStyle = FormBorderStyle.None;//设置无边框的窗口样式
  22. }
  23. private void MainForm_Load(object sender, EventArgs e)
  24. {
  25. if (!DesignMode)
  26. {
  27. Skin = new SkinForm(this);//创建皮肤层
  28. BackgroundImage = null;//去除控件层背景
  29. TransparencyKey = BackColor;//使控件层背景透明
  30. Skin.Show();//显示皮肤层
  31. Skin.TopMost = true;
  32. this.TopMost = true;
  33. //Skin.ShowInTaskbar = false;
  34. //this.ShowInTaskbar = false;
  35. }
  36. }
  37. #region 属性
  38. private bool _skinmobile = true;
  39. [Category("Skin")]
  40. [Description("窗体是否可以移动")]
  41. [DefaultValue(typeof(bool), "true")]
  42. public bool SkinMovable
  43. {
  44. get { return _skinmobile; }
  45. set
  46. {
  47. if (_skinmobile != value)
  48. {
  49. _skinmobile = value;
  50. }
  51. }
  52. }
  53. #endregion
  54. #region 减少闪烁
  55. private void SetStyles()
  56. {
  57. SetStyle(
  58. ControlStyles.UserPaint |
  59. ControlStyles.AllPaintingInWmPaint |
  60. ControlStyles.OptimizedDoubleBuffer |
  61. ControlStyles.ResizeRedraw |
  62. ControlStyles.DoubleBuffer, true);
  63. //强制分配样式重新应用到控件上
  64. UpdateStyles();
  65. base.AutoScaleMode = AutoScaleMode.None;
  66. }
  67. #endregion
  68. }
  69. }