frmAdminPage.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using Chromium.WebBrowser;
  2. using NetDimension.NanUI;
  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 LYFZ.Software.MainBusiness.MicroApplet
  12. {
  13. public partial class frmAdminPage : Formium
  14. {
  15. public frmAdminPage():
  16. base("")
  17. {
  18. InitializeComponent();
  19. try
  20. {
  21. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
  22. this.LifeSpanHandler.OnBeforePopup += LifeSpanHandler_OnBeforePopup;
  23. this.KeyboardHandler.OnKeyEvent += KeyboardHandler_OnKeyEvent;
  24. }
  25. catch { }
  26. }
  27. int oldKey = 0;
  28. private void KeyboardHandler_OnKeyEvent(object sender, Chromium.Event.CfxOnKeyEventEventArgs e)
  29. {
  30. if (e.Event.WindowsKeyCode == (int)Keys.F12 && oldKey == 17)
  31. {
  32. oldKey = 0;
  33. this.OpenShowDevTools();
  34. }
  35. else
  36. {
  37. oldKey = e.Event.WindowsKeyCode;
  38. }
  39. }
  40. public new BrowserCore Chromium => base.Chromium;
  41. delegate void ShowDevToolsDelegate();
  42. void OpenShowDevTools()
  43. {
  44. try
  45. {
  46. if (this.InvokeRequired)
  47. {
  48. ShowDevToolsDelegate setValue = new ShowDevToolsDelegate(OpenShowDevTools);
  49. this.Invoke(setValue);
  50. }
  51. else
  52. {
  53. //this.ShowDevTools(this.Handle);
  54. this.Chromium.ShowDevTools(this.Handle);
  55. }
  56. }
  57. catch
  58. {
  59. }
  60. finally
  61. {
  62. }
  63. }
  64. void LifeSpanHandler_OnBeforePopup(object sender, Chromium.Event.CfxOnBeforePopupEventArgs e)
  65. {
  66. }
  67. /// <summary>
  68. /// 设置为内嵌窗体
  69. /// </summary>
  70. public void SetEmbeddedWindows()
  71. {
  72. // this.BorderSize = 0;
  73. this.BorderWidth = 0;
  74. this.FormBorderStyle = FormBorderStyle.None;
  75. this.Dock = System.Windows.Forms.DockStyle.Fill;
  76. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
  77. this.EnableFormShadow = false;
  78. this.MaximizeBox = false;
  79. this.MinimizeBox = false;
  80. this.TopLevel = false;
  81. }
  82. /// <summary>
  83. /// 设置为内嵌窗体
  84. /// </summary>
  85. public void SetEmbeddedWindows(Control _Control)
  86. {
  87. this.SetEmbeddedWindows();
  88. _Control.Controls.Add(this);
  89. this.Show();
  90. }
  91. }
  92. }