非矩形窗 [英] non-rectangular window
本文介绍了非矩形窗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个非矩形的窗口(花键形):
i have this non rectangular window (spline-shaped) :
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace Guitar
{
class GuitarForm : Form
{
Bitmap bmp;
GuitarForm()
{
// this.FormBorderStyle = FormBorderStyle.None;
bmp = new Bitmap("C:\\ok.jpg");
GraphicsPath gp = new GraphicsPath();
Point[] curves = new Point[]{
new Point(93,99), new Point(200, 55),
new Point(328, 128),new Point(450,100),new Point(560,200),
};
gp.AddCurve(curves);
gp.AddLine(560,200, 560, 500);
gp.AddLine(560, 500, 93, 500);
gp.AddLine(93, 500, 93, 99);
gp.CloseFigure();
this.Region = new Region(gp);
}
protected override void OnPaint(PaintEventArgs ea)
{
base.OnPaint(ea);
Graphics g = ea.Graphics;
g.DrawImage(bmp, new Point(0, 0));
Rectangle scaled = new Rectangle(20, 20, 60, 60);
g.DrawImage(bmp,scaled);
g.DrawRectangle(Pens.Red, scaled);
Point[] pGram = new Point[]{
new Point(50, 10),
new Point(100, 30),
new Point(20, 100),
};
g.DrawImage(bmp, pGram);
}
public static void Main()
{
Application.Run(new GuitarForm());
}
private void InitializeComponent()
{
this.SuspendLayout();
//
// GuitarForm
//
this.ClientSize = new System.Drawing.Size(560, 560);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "GuitarForm";
this.ResumeLayout(false);
}
}///:~
}
问题是,当我运行它时,仅显示窗口的一部分,并且我必须拖动到brders才能看到整个形状.它有什么方法可以按照我想要的方式运行全尺寸大小吗?
the problem is that when i run it, only one part of the window appears and i have to drag to brders in order to see the whole shape . Is there any way it can run all-ready sized the way i want it ?
推荐答案
难道就像this.Size = ...一样简单吗?
Could it be something as simple as this.Size = ...?
这篇关于非矩形窗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文