📄 gform.cs
字号:
}
set
{
this.imageBottomCenter=value;
}
}
public Image ImageBottomRight
{
get
{
return this.imageBottomRight;
}
set
{
this.imageBottomRight=value;
}
}
private Image imageTopLeftA;
private Image imageTopCenterA;
private Image imageTopRightA;
private Image imageMiddleLeftA;
private Image imageMiddleCenterA;
private Image imageMiddleRightA;
private Image imageBottomLeftA;
private Image imageBottomCenterA;
private Image imageBottomRightA;
public Image ImageTopLeftA
{
get
{
return this.imageTopLeftA;
}
set
{
this.imageTopLeftA=value;
}
}
public Image ImageTopCenterA
{
get
{
return this.imageTopCenterA;
}
set
{
this.imageTopCenterA=value;
}
}
public Image ImageTopRightA
{
get
{
return this.imageTopRightA;
}
set
{
this.imageTopRightA=value;
}
}
public Image ImageMiddleLeftA
{
get
{
return this.imageMiddleLeftA;
}
set
{
this.imageMiddleLeftA=value;
}
}
public Image ImageMiddleCenterA
{
get
{
return this.imageMiddleCenterA;
}
set
{
this.imageMiddleCenterA=value;
}
}
public Image ImageMiddleRightA
{
get
{
return this.imageMiddleRightA;
}
set
{
this.imageMiddleRightA=value;
}
}
public Image ImageBottomLeftA
{
get
{
return this.imageBottomLeftA;
}
set
{
this.imageBottomLeftA=value;
}
}
public Image ImageBottomCenterA
{
get
{
return this.imageBottomCenterA;
}
set
{
this.imageBottomCenterA=value;
}
}
public Image ImageBottomRightA
{
get
{
return this.imageBottomRightA;
}
set
{
this.imageBottomRightA=value;
}
}
private Image imageTopLeftP;
private Image imageTopCenterP;
private Image imageTopRightP;
private Image imageMiddleLeftP;
private Image imageMiddleCenterP;
private Image imageMiddleRightP;
private Image imageBottomLeftP;
private Image imageBottomCenterP;
private Image imageBottomRightP;
public Image ImageTopLeftP
{
get
{
return this.imageTopLeftP;
}
set
{
this.imageTopLeftP=value;
}
}
public Image ImageTopCenterP
{
get
{
return this.imageTopCenterP;
}
set
{
this.imageTopCenterP=value;
}
}
public Image ImageTopRightP
{
get
{
return this.imageTopRightP;
}
set
{
this.imageTopRightP=value;
}
}
public Image ImageMiddleLeftP
{
get
{
return this.imageMiddleLeftP;
}
set
{
this.imageMiddleLeftP=value;
}
}
public Image ImageMiddleCenterP
{
get
{
return this.imageMiddleCenterP;
}
set
{
this.imageMiddleCenterP=value;
}
}
public Image ImageMiddleRightP
{
get
{
return this.imageMiddleRightP;
}
set
{
this.imageMiddleRightP=value;
}
}
public Image ImageBottomLeftP
{
get
{
return this.imageBottomLeftP;
}
set
{
this.imageBottomLeftP=value;
}
}
public Image ImageBottomCenterP
{
get
{
return this.imageBottomCenterP;
}
set
{
this.imageBottomCenterP=value;
}
}
public Image ImageBottomRightP
{
get
{
return this.imageBottomRightP;
}
set
{
this.imageBottomRightP=value;
}
}
#endregion
#region override
/* protected override void WndProc(ref Message m)
{
Point p=this.GetMousePosition();
switch(m.Msg)
{
case API.WM_ACTIVATE:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_NCACTIVATE:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_NCPAINT:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_PAINT:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_NCLBUTTONDBLCLK:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_NCLBUTTONDOWN:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_NCLBUTTONUP:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_NCMBUTTONDBLCLK:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_NCMOUSEMOVE:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_NCRBUTTONDBLCLK:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_NCRBUTTONDOWN:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_NCRBUTTONUP:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_NCHITTEST:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_MOVE:
base.WndProc(ref m);
this.DrawFrame();
break;
case API.WM_SIZE:
base.WndProc(ref m);
this.DrawFrame();
break;
default:
base.WndProc(ref m);
break;
}
}*/
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);
this.DrawBorder(e.Graphics);
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged (e);
if(this.ShellCreateBackgroundImage)
{
this.CreateAndSetBackgroundImage();
// this.SetDockPadding();
}
this.SetRegion();
this.sizing=false;
return;
/* using(Graphics g=this.CreateGraphics())
{
RectangleF rectf=this.Region.GetBounds(g);
this.Width=(int)rectf.Right;
this.Height=(int)rectf.Bottom;
}*/
}
//protected override void OnResize(EventArgs e)
//{
// base.OnResize (e);
// this.SetRegion();
//}
public override Image BackgroundImage
{
get
{
return base.BackgroundImage;
}
set
{
base.BackgroundImage = value;
SetRegion();
}
}
private void CreateAndSetBackgroundImage()
{
int w=this.ImageTopRight.Width+this.ImageTopCenter.Width+this.ImageTopLeft.Width;
int h=this.ImageTopRight.Height+this.ImageMiddleLeft.Height+this.ImageBottomLeft.Height;
this.MinimumSize=new Size(w,h);
Bitmap bm=new Bitmap(this.Width,this.Height);
Graphics g=Graphics.FromImage(bm);
this.DrawBackGround(g);
g.Dispose();
this.BackgroundImage=bm;
}
public bool ShellCreateBackgroundImage
{
get
{
return
this.ImageTopLeft!=null
&& this.ImageTopCenter!=null
&& this.ImageTopRight!=null
&& this.ImageMiddleLeft!=null
&& this.ImageMiddleCenter!=null
&& this.ImageMiddleRight!=null
&& this.ImageBottomLeft!=null
&& this.imageBottomCenter!=null
&& this.ImageBottomRight!=null;
}
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
Graphics g=pevent.Graphics;
if(this.BackgroundImage==null)
{
base.OnPaintBackground(pevent);//new PaintEventArgs(g,pevent.ClipRectangle));
}
else
{
g.FillRectangle(new SolidBrush(this.BackColor),this.ClientRectangle);
g.DrawImage(this.BackgroundImage,this.ClientRectangle);
}
// g.FillRegion(new SolidBrush(Color.Blue),UT.BitmapToRegion(new Bitmap(this.BackgroundImage),this.TransparencyKey));
// System.Diagnostics.Trace.WriteLine(this.BackColor.Equals(this.TransparencyKey).ToString());
// this.DrawBackGround(g);
/* Bitmap bm=new Bitmap(this.Width,this.Height);
Graphics g=Graphics.FromImage(bm);
if(this.BackgroundImage==null)
{
base.OnPaintBackground(pevent);//new PaintEventArgs(g,pevent.ClipRectangle));
}
else
{
pevent.Graphics.FillRectangle(new SolidBrush(this.BackColor),this.ClientRectangle);
pevent.Graphics.DrawImage(this.BackgroundImage,this.ClientRectangle);
}
this.DrawBackGround(g);
pevent.Graphics.DrawImage(bm,0,0);
g.Dispose();
bm.Dispose();*/
}
protected override CreateParams CreateParams
{
get
{
CreateParams par=base.CreateParams;
if(this.MaximizeBox)par.Style|=API.WS_MAXIMIZEBOX;
if(this.MinimizeBox)par.Style|=API.WS_MINIMIZEBOX;
if(this.showborder)par.Style|=API.WS_SIZEBOX;
if(this.captionBar)par.Style|=API.WS_CAPTION;
if(this.sysMenu)par.Style|=API.WS_SYSMENU;
return par;
}
}
private void SetCursor(int x,int y)
{
Cursor c=Cursors.Default;
Rectangle rect=this.ClientRectangle;
int b=10;
Rectangle r=rect;
r.Inflate(-b,-b);
if(r.Contains(x,y) )
{
Cursor.Current=Cursors.Default;return;
}
if(x-rect.X<b)
{
if(y-rect.Top<b)
c=Cursors.SizeNWSE;
else if(rect.Bottom-y<b)
c=Cursors.SizeNESW;
else
c=Cursors.SizeWE;
}
else if(rect.Right-x<b)
{
if(y-rect.Top<b)
c=Cursors.SizeNESW;
else if(rect.Bottom-y<b)
c=Cursors.SizeNWSE;
else
c=Cursors.SizeWE;
}
else
{
c=Cursors.SizeNS;
}
Cursor.Current=c;
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp (e);
this.SetCursor(e.X,e.Y);
this.sizing=false;
}
bool sizing;
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove (e);
if(!this.sizing)this.SetCursor(e.X,e.Y);
}
protected override void OnMouseDown(MouseEventArgs e)
{
this.sizing=true;
this.SetCursor(e.X,e.Y);
base.OnMouseDown (e);
this.Capture=false;
Rectangle r=this.ClientRectangle;
Rectangle r2=r;
r.Inflate(-10,-10);
if(r.Contains(e.X,e.Y))
{
foreach(Control c in this.Controls)
{
if(c.Bounds.Contains(e.X,e.Y))return;
}
this.MoveWindow();
}
else if(r2.Contains(e.X,e.Y))
{
this.ResizeWindow(e.X,e.Y);
}
this.Capture=true;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -