first commit

This commit is contained in:
lq
2026-09-07 08:07:08 +08:00
commit e703fb2752
2488 changed files with 2784663 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
// ***********************************************************************
// Assembly : JinYuan.ControlLib
// Created : 08-08-2019
//
// ***********************************************************************
// <copyright file="FrmBase.Designer.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
namespace JinYuan.ControlLib.Forms
{
/// <summary>
/// Class FrmBase.
/// Implements the <see cref="System.Windows.Forms.Form" />
/// </summary>
/// <seealso cref="System.Windows.Forms.Form" />
partial class FrmBase
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmBase));
this.SuspendLayout();
//
// FrmBase
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.ClientSize = new System.Drawing.Size(331, 371);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(66)))), ((int)(((byte)(66)))));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "FrmBase";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "FrmBase";
this.Load += new System.EventHandler(this.FrmBase_Load);
this.ResumeLayout(false);
}
#endregion
}
}
+625
View File
@@ -0,0 +1,625 @@
// ***********************************************************************
// Assembly : JinYuan.ControlLib
// Created : 08-08-2019
//
// ***********************************************************************
// <copyright file="FrmBase.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using JinYuan.ControlLib.UCHelper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace JinYuan.ControlLib.Forms
{
/// <summary>
/// Class FrmBase.
/// Implements the <see cref="System.Windows.Forms.Form" />
/// </summary>
/// <seealso cref="System.Windows.Forms.Form" />
[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(System.ComponentModel.Design.IDesigner))]
public partial class FrmBase : Form
{
/// <summary>
/// Gets or sets the hot keys.
/// </summary>
/// <value>The hot keys.</value>
[Description("定义的热键列表"), Category("自定义")]
public Dictionary<int, string> HotKeys { get; set; }
/// <summary>
/// Delegate HotKeyEventHandler
/// </summary>
/// <param name="strHotKey">The string hot key.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
public delegate bool HotKeyEventHandler(string strHotKey);
/// <summary>
/// 热键事件
/// </summary>
[Description("热键事件"), Category("自定义")]
public event HotKeyEventHandler HotKeyDown;
#region 字段属性
/// <summary>
/// 失去焦点关闭
/// </summary>
bool _isLoseFocusClose = false;
/// <summary>
/// 是否重绘边框样式
/// </summary>
private bool _redraw = false;
/// <summary>
/// 是否显示圆角
/// </summary>
private bool _isShowRegion = false;
/// <summary>
/// 边圆角大小
/// </summary>
private int _regionRadius = 10;
/// <summary>
/// 边框颜色
/// </summary>
private Color _borderStyleColor;
/// <summary>
/// 边框宽度
/// </summary>
private int _borderStyleSize;
/// <summary>
/// 边框样式
/// </summary>
private ButtonBorderStyle _borderStyleType;
/// <summary>
/// 是否显示模态
/// </summary>
private bool _isShowMaskDialog = false;
/// <summary>
/// 蒙版窗体
/// </summary>
/// <value><c>true</c> if this instance is show mask dialog; otherwise, <c>false</c>.</value>
[Description("是否显示蒙版窗体")]
public bool IsShowMaskDialog
{
get
{
return this._isShowMaskDialog;
}
set
{
this._isShowMaskDialog = value;
}
}
/// <summary>
/// 边框宽度
/// </summary>
/// <value>The size of the border style.</value>
[Description("边框宽度")]
public int BorderStyleSize
{
get
{
return this._borderStyleSize;
}
set
{
this._borderStyleSize = value;
}
}
/// <summary>
/// 边框颜色
/// </summary>
/// <value>The color of the border style.</value>
[Description("边框颜色")]
public Color BorderStyleColor
{
get
{
return this._borderStyleColor;
}
set
{
this._borderStyleColor = value;
}
}
/// <summary>
/// 边框样式
/// </summary>
/// <value>The type of the border style.</value>
[Description("边框样式")]
public ButtonBorderStyle BorderStyleType
{
get
{
return this._borderStyleType;
}
set
{
this._borderStyleType = value;
}
}
/// <summary>
/// 边框圆角
/// </summary>
/// <value>The region radius.</value>
[Description("边框圆角")]
public int RegionRadius
{
get
{
return this._regionRadius;
}
set
{
this._regionRadius = Math.Max(value, 1);
}
}
/// <summary>
/// 是否显示自定义绘制内容
/// </summary>
/// <value><c>true</c> if this instance is show region; otherwise, <c>false</c>.</value>
[Description("是否显示自定义绘制内容")]
public bool IsShowRegion
{
get
{
return this._isShowRegion;
}
set
{
this._isShowRegion = value;
}
}
/// <summary>
/// 是否显示重绘边框
/// </summary>
/// <value><c>true</c> if redraw; otherwise, <c>false</c>.</value>
[Description("是否显示重绘边框")]
public bool Redraw
{
get
{
return this._redraw;
}
set
{
this._redraw = value;
}
}
/// <summary>
/// The is full size
/// </summary>
private bool _isFullSize = true;
/// <summary>
/// 是否全屏
/// </summary>
/// <value><c>true</c> if this instance is full size; otherwise, <c>false</c>.</value>
[Description("是否全屏")]
public virtual bool IsFullSize
{
get { return _isFullSize; }
set { _isFullSize = value; }
}
/// <summary>
/// 失去焦点自动关闭
/// </summary>
/// <value><c>true</c> if this instance is lose focus close; otherwise, <c>false</c>.</value>
[Description("失去焦点自动关闭")]
public bool IsLoseFocusClose
{
get
{
return this._isLoseFocusClose;
}
set
{
this._isLoseFocusClose = value;
}
}
#endregion
/// <summary>
/// Gets a value indicating whether this instance is desing mode.
/// </summary>
/// <value><c>true</c> if this instance is desing mode; otherwise, <c>false</c>.</value>
private bool IsDesingMode
{
get
{
bool ReturnFlag = false;
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
ReturnFlag = true;
else if (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv")
ReturnFlag = true;
return ReturnFlag;
}
}
#region 初始化
/// <summary>
/// Initializes a new instance of the <see cref="FrmBase" /> class.
/// </summary>
public FrmBase()
{
InitializeComponent();
base.SetStyle(ControlStyles.UserPaint, true);
base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
base.SetStyle(ControlStyles.DoubleBuffer, true);
//base.HandleCreated += new EventHandler(this.FrmBase_HandleCreated);
//base.HandleDestroyed += new EventHandler(this.FrmBase_HandleDestroyed);
this.KeyDown += FrmBase_KeyDown;
this.FormClosing += FrmBase_FormClosing;
}
/// <summary>
/// Handles the FormClosing event of the FrmBase control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="FormClosingEventArgs" /> instance containing the event data.</param>
void FrmBase_FormClosing(object sender, FormClosingEventArgs e)
{
if (_isLoseFocusClose)
{
MouseHook.OnMouseActivity -= hook_OnMouseActivity;
}
}
/// <summary>
/// Handles the Load event of the FrmBase control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
private void FrmBase_Load(object sender, EventArgs e)
{
if (!IsDesingMode)
{
if (_isFullSize)
SetFullSize();
}
if (_isLoseFocusClose)
{
MouseHook.OnMouseActivity += hook_OnMouseActivity;
}
}
#endregion
#region 方法区
/// <summary>
/// Handles the OnMouseActivity event of the hook control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
void hook_OnMouseActivity(object sender, MouseEventArgs e)
{
try
{
if (this._isLoseFocusClose && e.Clicks > 0)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left || e.Button == System.Windows.Forms.MouseButtons.Right)
{
if (!this.IsDisposed)
{
if (!this.ClientRectangle.Contains(this.PointToClient(e.Location)))
{
base.Close();
}
}
}
}
}
catch { }
}
/// <summary>
/// 全屏
/// </summary>
public void SetFullSize()
{
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
}
/// <summary>
/// Does the escape.
/// </summary>
protected virtual void DoEsc()
{
base.Close();
}
/// <summary>
/// Does the enter.
/// </summary>
protected virtual void DoEnter()
{
}
/// <summary>
/// 设置重绘区域
/// </summary>
public void SetWindowRegion()
{
GraphicsPath path = new GraphicsPath();
Rectangle rect = new Rectangle(-1, -1, base.Width + 1, base.Height);
path = this.GetRoundedRectPath(rect, this._regionRadius);
base.Region = new Region(path);
}
/// <summary>
/// 获取重绘区域
/// </summary>
/// <param name="rect">The rect.</param>
/// <param name="radius">The radius.</param>
/// <returns>GraphicsPath.</returns>
private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
{
Rectangle rect2 = new Rectangle(rect.Location, new Size(radius, radius));
GraphicsPath graphicsPath = new GraphicsPath();
graphicsPath.AddArc(rect2, 180f, 90f);
rect2.X = rect.Right - radius;
graphicsPath.AddArc(rect2, 270f, 90f);
rect2.Y = rect.Bottom - radius;
rect2.Width += 1;
rect2.Height += 1;
graphicsPath.AddArc(rect2, 360f, 90f);
rect2.X = rect.Left;
graphicsPath.AddArc(rect2, 90f, 90f);
graphicsPath.CloseFigure();
return graphicsPath;
}
/// <summary>
/// 将窗体显示为具有指定所有者的模式对话框。
/// </summary>
/// <param name="owner">任何实现 <see cref="T:System.Windows.Forms.IWin32Window" />(表示将拥有模式对话框的顶级窗口)的对象。</param>
/// <returns><see cref="T:System.Windows.Forms.DialogResult" /> 值之一。</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// <IPermission class="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
public new DialogResult ShowDialog(IWin32Window owner)
{
try
{
if (this._isShowMaskDialog && owner != null)
{
var frmOwner = (Control)owner;
FrmTransparent _frmTransparent = new FrmTransparent();
_frmTransparent.Width = frmOwner.Width;
_frmTransparent.Height = frmOwner.Height;
Point location = frmOwner.PointToScreen(new Point(0, 0));
_frmTransparent.Location = location;
_frmTransparent.frmchild = this;
_frmTransparent.IsShowMaskDialog = false;
return _frmTransparent.ShowDialog(owner);
}
else
{
return base.ShowDialog(owner);
}
}
catch (NullReferenceException)
{
return System.Windows.Forms.DialogResult.None;
}
}
/// <summary>
/// 将窗体显示为模式对话框,并将当前活动窗口设置为它的所有者。
/// </summary>
/// <returns><see cref="T:System.Windows.Forms.DialogResult" /> 值之一。</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// <IPermission class="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
public new DialogResult ShowDialog()
{
return base.ShowDialog();
}
#endregion
#region 事件区
/// <summary>
/// 关闭时发生
/// </summary>
/// <param name="e">一个包含事件数据的 <see cref="T:System.EventArgs" />。</param>
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
if (base.Owner != null && base.Owner is FrmTransparent)
{
(base.Owner as FrmTransparent).Close();
}
}
/// <summary>
/// 快捷键
/// </summary>
/// <param name="msg">通过引用传递的 <see cref="T:System.Windows.Forms.Message" />,它表示要处理的 Win32 消息。</param>
/// <param name="keyData"><see cref="T:System.Windows.Forms.Keys" /> 值之一,它表示要处理的键。</param>
/// <returns>如果控件处理并使用击键,则为 true;否则为 false,以允许进一步处理。</returns>
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
int num = 256;
int num2 = 260;
bool result;
if (msg.Msg == num | msg.Msg == num2)
{
if (keyData == (Keys)262259)
{
result = true;
return result;
}
if (keyData != Keys.Enter)
{
if (keyData == Keys.Escape)
{
this.DoEsc();
}
}
else
{
this.DoEnter();
}
}
result = false;
if (result)
return result;
else
return base.ProcessCmdKey(ref msg, keyData);
}
/// <summary>
/// Handles the KeyDown event of the FrmBase control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="KeyEventArgs" /> instance containing the event data.</param>
protected void FrmBase_KeyDown(object sender, KeyEventArgs e)
{
if (HotKeyDown != null && HotKeys != null)
{
bool blnCtrl = false;
bool blnAlt = false;
bool blnShift = false;
if (e.Control)
blnCtrl = true;
if (e.Alt)
blnAlt = true;
if (e.Shift)
blnShift = true;
if (HotKeys.ContainsKey(e.KeyValue))
{
string strKey = string.Empty;
if (blnCtrl)
{
strKey += "Ctrl+";
}
if (blnAlt)
{
strKey += "Alt+";
}
if (blnShift)
{
strKey += "Shift+";
}
strKey += HotKeys[e.KeyValue];
if (HotKeyDown(strKey))
{
e.Handled = true;
e.SuppressKeyPress = true;
}
}
}
}
/// <summary>
/// 重绘事件
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.PaintEventArgs" />。</param>
protected override void OnPaint(PaintEventArgs e)
{
if (this._isShowRegion)
{
this.SetWindowRegion();
}
base.OnPaint(e);
if (this._redraw)
{
ControlPaint.DrawBorder(e.Graphics, base.ClientRectangle, this._borderStyleColor, this._borderStyleSize, this._borderStyleType, this._borderStyleColor, this._borderStyleSize, this._borderStyleType, this._borderStyleColor, this._borderStyleSize, this._borderStyleType, this._borderStyleColor, this._borderStyleSize, this._borderStyleType);
}
}
#endregion
#region 窗体拖动 English:Form drag
/// <summary>
/// Releases the capture.
/// </summary>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
/// <summary>
/// Sends the message.
/// </summary>
/// <param name="hwnd">The HWND.</param>
/// <param name="wMsg">The w MSG.</param>
/// <param name="wParam">The w parameter.</param>
/// <param name="lParam">The l parameter.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
/// <summary>
/// The wm syscommand
/// </summary>
public const int WM_SYSCOMMAND = 0x0112;
/// <summary>
/// The sc move
/// </summary>
public const int SC_MOVE = 0xF010;
/// <summary>
/// The htcaption
/// </summary>
public const int HTCAPTION = 0x0002;
/// <summary>
/// 通过Windows的API控制窗体的拖动
/// </summary>
/// <param name="hwnd">The HWND.</param>
public static void MouseDown(IntPtr hwnd)
{
ReleaseCapture();
SendMessage(hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
#endregion
/// <summary>
/// 在构造函数中调用设置窗体移动
/// </summary>
/// <param name="cs">The cs.</param>
protected void InitFormMove(params Control[] cs)
{
foreach (Control c in cs)
{
if (c != null && !c.IsDisposed)
c.MouseDown += c_MouseDown;
}
}
/// <summary>
/// Handles the MouseDown event of the c control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
void c_MouseDown(object sender, MouseEventArgs e)
{
MouseDown(this.Handle);
}
}
}
File diff suppressed because it is too large Load Diff
+73
View File
@@ -0,0 +1,73 @@
// ***********************************************************************
// Assembly : JinYuan.ControlLib
// Created : 08-08-2019
//
// ***********************************************************************
// <copyright file="FrmTransparent.Designer.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
namespace JinYuan.ControlLib.Forms
{
/// <summary>
/// Class FrmTransparent.
/// Implements the <see cref="JinYuan.ControlLib.Forms.FrmBase" />
/// </summary>
/// <seealso cref="JinYuan.ControlLib.Forms.FrmBase" />
partial class FrmTransparent
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmTransparent));
this.SuspendLayout();
//
// FrmTransparent
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FrmTransparent";
this.Opacity = 0.5D;
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "FrmTransparent";
this.Load += new System.EventHandler(this.FrmTransparent_Load);
this.ResumeLayout(false);
}
#endregion
}
}
+175
View File
@@ -0,0 +1,175 @@
// ***********************************************************************
// Assembly : JinYuan.ControlLib
// Created : 08-08-2019
//
// ***********************************************************************
// <copyright file="FrmTransparent.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace JinYuan.ControlLib.Forms
{
/// <summary>
/// Class FrmTransparent.
/// Implements the <see cref="JinYuan.ControlLib.Forms.FrmBase" />
/// </summary>
/// <seealso cref="JinYuan.ControlLib.Forms.FrmBase" />
public partial class FrmTransparent : FrmBase
{
/// <summary>
/// The wm activate
/// </summary>
private const int WM_ACTIVATE = 6;
/// <summary>
/// The wm activateapp
/// </summary>
private const int WM_ACTIVATEAPP = 28;
/// <summary>
/// The wm ncactivate
/// </summary>
private const int WM_NCACTIVATE = 134;
/// <summary>
/// The wa inactive
/// </summary>
private const int WA_INACTIVE = 0;
/// <summary>
/// The wm mouseactivate
/// </summary>
private const int WM_MOUSEACTIVATE = 33;
/// <summary>
/// The ma noactivate
/// </summary>
private const int MA_NOACTIVATE = 3;
/// <summary>
/// Gets the create parameters.
/// </summary>
/// <value>The create parameters.</value>
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp;
}
}
/// <summary>
/// Gets or sets the frmchild.
/// </summary>
/// <value>The frmchild.</value>
public FrmBase frmchild
{
get;
set;
}
/// <summary>
/// Initializes a new instance of the <see cref="FrmTransparent" /> class.
/// </summary>
public FrmTransparent()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.Selectable, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.UserPaint, true);
MethodInfo method = base.GetType().GetMethod("SetStyle", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod);
method.Invoke(this, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, new object[]
{
ControlStyles.Selectable,
false
}, Application.CurrentCulture);
}
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Form.Load" /> 事件。
/// </summary>
/// <param name="e">一个包含事件数据的 <see cref="T:System.EventArgs" />。</param>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
base.ShowInTaskbar = false;
base.ShowIcon = true;
}
/// <summary>
/// Sets the active window.
/// </summary>
/// <param name="handle">The handle.</param>
/// <returns>IntPtr.</returns>
[DllImport("user32.dll")]
private static extern IntPtr SetActiveWindow(IntPtr handle);
/// <summary>
/// WNDs the proc.
/// </summary>
/// <param name="m">要处理的 Windows <see cref="T:System.Windows.Forms.Message" />。</param>
protected override void WndProc(ref Message m)
{
if (m.Msg == 33)
{
m.Result = new IntPtr(3);
}
else
{
if (m.Msg == 134)
{
if (((int)m.WParam & 65535) != 0)
{
if (m.LParam != IntPtr.Zero)
{
FrmTransparent.SetActiveWindow(m.LParam);
}
else
{
FrmTransparent.SetActiveWindow(IntPtr.Zero);
}
}
}
else if (m.Msg == 2000)
{
}
base.WndProc(ref m);
}
}
/// <summary>
/// Handles the Load event of the FrmTransparent control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
private void FrmTransparent_Load(object sender, EventArgs e)
{
if (frmchild != null)
{
frmchild.IsShowMaskDialog = false;
var dia = frmchild.ShowDialog(this);
this.DialogResult = dia;
}
}
}
}
File diff suppressed because it is too large Load Diff
+162
View File
@@ -0,0 +1,162 @@
// ***********************************************************************
// Assembly : JinYuan.ControlLib
// Created : 08-08-2019
//
// ***********************************************************************
// <copyright file="FrmWaiting.Designer.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
namespace JinYuan.ControlLib.Forms
{
/// <summary>
/// Class FrmWaiting.
/// Implements the <see cref="JinYuan.ControlLib.Forms.FrmBase" />
/// </summary>
/// <seealso cref="JinYuan.ControlLib.Forms.FrmBase" />
partial class FrmWaiting
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmWaiting));
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.label1 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.label2 = new System.Windows.Forms.Label();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// imageList1
//
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.White;
this.imageList1.Images.SetKeyName(0, "0.png");
this.imageList1.Images.SetKeyName(1, "1.png");
this.imageList1.Images.SetKeyName(2, "2.png");
this.imageList1.Images.SetKeyName(3, "3.png");
this.imageList1.Images.SetKeyName(4, "4.png");
this.imageList1.Images.SetKeyName(5, "5.png");
this.imageList1.Images.SetKeyName(6, "6.png");
this.imageList1.Images.SetKeyName(7, "7.png");
this.imageList1.Images.SetKeyName(8, "8.png");
this.imageList1.Images.SetKeyName(9, "9.png");
this.imageList1.Images.SetKeyName(10, "10.png");
this.imageList1.Images.SetKeyName(11, "11.png");
this.imageList1.Images.SetKeyName(12, "12.png");
this.imageList1.Images.SetKeyName(13, "13.png");
this.imageList1.Images.SetKeyName(14, "14.png");
this.imageList1.Images.SetKeyName(15, "15.png");
this.imageList1.Images.SetKeyName(16, "16.png");
this.imageList1.Images.SetKeyName(17, "17.png");
this.imageList1.Images.SetKeyName(18, "18.png");
this.imageList1.Images.SetKeyName(19, "19.png");
//
// label1
//
this.label1.Dock = System.Windows.Forms.DockStyle.Top;
this.label1.Image = global::JinYuan.ControlLib.Properties.Resources.loading;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(276, 196);
this.label1.TabIndex = 0;
//
// timer1
//
this.timer1.Interval = 20;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// label2
//
this.label2.Dock = System.Windows.Forms.DockStyle.Top;
this.label2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.label2.Location = new System.Drawing.Point(0, 196);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(276, 30);
this.label2.TabIndex = 1;
this.label2.Text = "处理正在进行中,请稍候...";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// timer2
//
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// FrmWaiting
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.ClientSize = new System.Drawing.Size(276, 244);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.IsFullSize = false;
this.Name = "FrmWaiting";
this.Opacity = 0D;
this.RegionRadius = 20;
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "";
this.TopMost = true;
this.TransparencyKey = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
this.VisibleChanged += new System.EventHandler(this.FrmWaiting_VisibleChanged);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The image list1
/// </summary>
private System.Windows.Forms.ImageList imageList1;
/// <summary>
/// The label1
/// </summary>
private System.Windows.Forms.Label label1;
/// <summary>
/// The timer1
/// </summary>
private System.Windows.Forms.Timer timer1;
/// <summary>
/// The label2
/// </summary>
private System.Windows.Forms.Label label2;
/// <summary>
/// The timer2
/// </summary>
private System.Windows.Forms.Timer timer2;
}
}
+109
View File
@@ -0,0 +1,109 @@
// ***********************************************************************
// Assembly : JinYuan.ControlLib
// Created : 08-08-2019
//
// ***********************************************************************
// <copyright file="FrmWaiting.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace JinYuan.ControlLib.Forms
{
/// <summary>
/// Class FrmWaiting.
/// Implements the <see cref="JinYuan.ControlLib.Forms.FrmBase" />
/// </summary>
/// <seealso cref="JinYuan.ControlLib.Forms.FrmBase" />
public partial class FrmWaiting : FrmBase
{
/// <summary>
/// Gets or sets the MSG.
/// </summary>
/// <value>The MSG.</value>
public string Msg { get { return label2.Text; } set { label2.Text = value; } }
/// <summary>
/// Initializes a new instance of the <see cref="FrmWaiting" /> class.
/// </summary>
public FrmWaiting()
{
base.SetStyle(ControlStyles.UserPaint, true);
base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
base.SetStyle(ControlStyles.DoubleBuffer, true);
InitializeComponent();
}
/// <summary>
/// Handles the Tick event of the timer1 control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
private void timer1_Tick(object sender, EventArgs e)
{
if (this.label1.ImageIndex == this.imageList1.Images.Count - 1)
this.label1.ImageIndex = 0;
else
this.label1.ImageIndex++;
}
/// <summary>
/// Handles the VisibleChanged event of the FrmWaiting control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
private void FrmWaiting_VisibleChanged(object sender, EventArgs e)
{
//this.timer1.Enabled = this.Visible;
}
/// <summary>
/// Does the escape.
/// </summary>
protected override void DoEsc()
{
}
/// <summary>
/// Handles the Tick event of the timer2 control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
private void timer2_Tick(object sender, EventArgs e)
{
base.Opacity = 1.0;
this.timer2.Enabled = false;
}
/// <summary>
/// Shows the form.
/// </summary>
/// <param name="intSleep">The int sleep.</param>
public void ShowForm(int intSleep = 1)
{
base.Opacity = 0.0;
if (intSleep <= 0)
{
intSleep = 1;
}
base.Show();
this.timer2.Interval = intSleep;
this.timer2.Enabled = true;
}
}
}
File diff suppressed because it is too large Load Diff