📄 formex.cs
字号:
namespace Imps.Client.Pc.BizControls
{
using Imps.Client.Pc;
using Imps.Client.Pc.Theme;
using Imps.Client.Resource;
using Imps.Client.Utils.Win32;
using Imps.Utils;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class FormEx : Form, IDisposable
{
protected Rectangle _bottom_leftfadeRegion;
private const int _bottom_leftfadeWidth = 0x83;
protected Rectangle _bottom_rightfadeRegion;
private const int _bottom_rightfadeWidth = 0x6c;
protected const int _bottomBorderHeight = 4;
protected Rectangle _bottomBorderRegion;
private System.Drawing.Region _bottomleftRegion;
private System.Drawing.Region _bottomrightRegion;
private int _bottomwidh;
private bool _bRegionCreated;
private bool _bSupportCaptionLink;
protected int _button_interval;
private const int _button_verIndent = 3;
private bool _canDragAnyWhere;
private int _captionHeight;
protected XFormWndlessLabel _captionLabel;
private Container _components;
protected Rectangle _controlBoxRect;
protected int _deltaX;
protected int _deltaY;
protected int _diagnosedHeight;
protected bool _extendCaption;
protected bool _firstAdjusted;
private XFormStyle _formStyle;
private int _height;
protected Rectangle _hemline_bar_rgn;
private const int _hemline_barWidth = 12;
protected Rectangle _hemline_left_rgn;
private const int _hemline_leftWidth = 0x83;
protected Rectangle _hemline_right_rgn;
private const int _hemline_rightWidth = 0x6c;
private Imps.Client.Pc.BizControls.HemlineStyle _hemline_style;
protected formCaptionIcon _iconImage;
private bool _inPosChanged;
protected int _interval;
private bool _isdisposed;
private System.Drawing.Point _lastMousePoint;
private const int _left_bottomfadeHeight = 0x5b;
protected Rectangle _left_bottomfadeRegion;
private const int _left_topfadeHeight = 0x3a;
protected Rectangle _left_topfadeRegion;
protected Rectangle _leftBorderRegion;
protected const int _leftBorderWidth = 4;
private int _leftheight;
private System.Drawing.Point _mouseDownLocation;
protected Rectangle _panelRegion;
protected WndlessImage _resizer;
private const int _right_bottomfadeHeight = 0x5b;
protected Rectangle _right_bottomfadeRegion;
private const int _right_topfadeHeight = 0x3a;
protected Rectangle _right_topfadeRegion;
protected Rectangle _rightBorderRegion;
protected const int _rightBorderWidth = 4;
private int _rightheight;
protected WndlessStatusBar _statusBar;
private bool _statusBarBox;
private static readonly Size _systemMenuButtonImageSize = new Size(14, 12);
private menu_widget _systemMenuStrip;
protected Rectangle _title_left_rgn;
protected Rectangle _title_left_rgn_2;
private const int _title_leftfadeWidth = 0x83;
protected Rectangle _title_rgn;
protected Rectangle _title_right_rgn;
protected Rectangle _title_right_rgn_2;
private const int _title_rightfadeWidth = 0x6c;
protected Rectangle _titlebar_rgn;
protected Rectangle _titlebar_rgn_2;
protected WndlessImage _TitleImage;
protected Rectangle _top_leftfadeRegion;
private const int _top_leftfadeWidth = 0x83;
protected Rectangle _top_rightfadeRegion;
private const int _top_rightfadeWidth = 0x6c;
protected const int _topBorderHeight = 4;
protected Rectangle _topBorderRegion;
private System.Drawing.Region _topleftRegion;
private System.Drawing.Region _topRightRegion;
private int _topwidth;
private Color _transparentColor;
private int _width;
protected WndlessControlManager _wndlessCtrlMgr;
private int _x;
private MenuStrip _xformContextMenu;
private int _y;
public bool bActived;
private bool bEventLoaded;
protected WndlessBoxButton closeButton;
protected WndlessBoxButton maxButton;
protected WndlessBoxButton minButton;
protected WndlessBoxButton restoreButton;
private const int SC_CLOSE = 0xf060;
private const int SC_MAXIMIZE = 0xf030;
private const int SC_MINIMIZE = 0xf020;
protected static XImFormStyle style = new XImFormStyle();
private ToolTip tip;
public FormEx() : this(false, (XFormStyle) 0)
{
}
public FormEx(XFormStyle style)
{
this._mouseDownLocation = System.Drawing.Point.Empty;
this._lastMousePoint = System.Drawing.Point.Empty;
this.bActived = true;
this._button_interval = 5;
this._interval = 2;
this.tip = new ToolTip();
this._captionHeight = SystemInformation.CaptionHeight * 2;
this._firstAdjusted = true;
this._transparentColor = Color.FromArgb(0xff, 0, 0xff);
this._canDragAnyWhere = true;
this._formStyle = style;
this.ConstructForm(false);
}
public FormEx(bool ExtendCaption, XFormStyle style)
{
this._mouseDownLocation = System.Drawing.Point.Empty;
this._lastMousePoint = System.Drawing.Point.Empty;
this.bActived = true;
this._button_interval = 5;
this._interval = 2;
this.tip = new ToolTip();
this._captionHeight = SystemInformation.CaptionHeight * 2;
this._firstAdjusted = true;
this._transparentColor = Color.FromArgb(0xff, 0, 0xff);
this._canDragAnyWhere = true;
this.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
this._formStyle = style;
base.AutoScale = false;
this.ConstructForm(ExtendCaption);
this.HemlineStyle = Imps.Client.Pc.BizControls.HemlineStyle.Normal;
BossKey.HiddenEvent += new EventHandler(this.BossKey_HiddenEvent);
}
private void _captionLabel_DoubleClick(object sender, EventArgs e)
{
if (base.WindowState == FormWindowState.Maximized)
{
this.doRestore();
}
else
{
this.doMax();
}
}
private void _editableLabel_DoubleClick(object sender, EventArgs e)
{
if (base.WindowState == FormWindowState.Maximized)
{
this.doRestore();
}
else
{
this.doMax();
}
}
private void _iconImage_DoubleClick(object sender, EventArgs e)
{
this.doClose();
}
private void _systemMenuStrip_Opening(object sender, CancelEventArgs e)
{
if (this.ExistWindowsState(XFormWindowState.Maximized))
{
this._systemMenuStrip.get_Items().get_Item(0).set_Enabled(false);
this._systemMenuStrip.get_Items().get_Item(2).set_Enabled(true);
}
else
{
if (base.MaximizeBox)
{
this._systemMenuStrip.get_Items().get_Item(0).set_Enabled(true);
}
else
{
this._systemMenuStrip.get_Items().get_Item(0).set_Enabled(false);
}
this._systemMenuStrip.get_Items().get_Item(2).set_Enabled(false);
}
if (this.ExistWindowsState(XFormWindowState.Minimized))
{
this._systemMenuStrip.get_Items().get_Item(1).set_Enabled(true);
}
else
{
this._systemMenuStrip.get_Items().get_Item(0).set_Enabled(false);
this._systemMenuStrip.get_Items().get_Item(1).set_Enabled(false);
}
this._systemMenuStrip.get_Items().get_Item(3).set_Enabled(true);
}
protected void AdjustForm()
{
if (!this.bEventLoaded)
{
base.SizeChanged += new EventHandler(this.FormEx_SizeChanged);
base.DoubleClick += new EventHandler(this.FormEx_DoubleClick);
base.Click += new EventHandler(this.FormEx_Click);
base.MouseMove += new MouseEventHandler(this.FormEx_MouseMove);
base.MouseLeave += new EventHandler(this.FormEx_MouseLeave);
base.MouseDown += new MouseEventHandler(this.FormEx_MouseDown);
base.MouseUp += new MouseEventHandler(this.FormEx_MouseUp);
this.bEventLoaded = true;
}
}
private void BossKey_HiddenEvent(object sender, EventArgs e)
{
this.HandleBossKey();
}
protected virtual void ChangeSizeParemeter()
{
}
public void ClearFormButtonState()
{
this._wndlessCtrlMgr.NcMouseLeave();
}
private void closeButton_Click(object sender, EventArgs e)
{
this.doClose();
}
private void ConstructForm(bool extendCaption)
{
this._extendCaption = extendCaption;
this._wndlessCtrlMgr = new WndlessControlManager(this);
this.set_DoubleBuffered(true);
this._wndlessCtrlMgr.Location = new System.Drawing.Point(this._deltaX, this._deltaY);
this.InitializeComponent();
base.set_DoubleBuffered(true);
base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
base.SetStyle(0x20000, true);
base.SetStyle(ControlStyles.ResizeRedraw, false);
base.SetStyle(ControlStyles.UserPaint, true);
base.Load += new EventHandler(this.FormEx_Load);
base.Disposed += new EventHandler(this.FormEx_Disposed);
style.StyleChanged += new EventHandler(this.style_StyleChanged);
base.SystemColorsChanged += new EventHandler(this.FormEx_SystemColorsChanged);
}
private void CreateCaptionRegion(int buttonTop, int buttonX, int captionLabelRight, bool nonClient)
{
buttonTop = Style.CaptionY;
if (this._iconImage != null)
{
buttonX = this._iconImage.Right + 3;
}
if (this._controlBoxRect.Left != 0)
{
if (base.MaximizeBox && base.MinimizeBox)
{
captionLabelRight = this._controlBoxRect.Left - 3;
}
else if (base.MinimizeBox)
{
captionLabelRight = this._controlBoxRect.Left + (this._controlBoxRect.Width / 3);
}
else
{
captionLabelRight = this._controlBoxRect.Left + ((this._controlBoxRect.Width / 3) * 2);
}
}
if (this._captionLabel == null)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -