C♯相談室 Part7
■ このスレッドは過去ログ倉庫に格納されています
0292デフォルトの名無しさん
NGNGこんな感じでどう?
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
abstract class CustomShapeForm : Form
{
public CustomShapeForm() {
this.Resize += new EventHandler(this.Form_Resize);
SetRegion();
}
private void Form_Resize(object sender, EventArgs e) {
SetRegion();
}
protected abstract void SetRegion();
}
class RoundForm : CustomShapeForm
{
protected override void SetRegion() {
Size s = this.Size;
GraphicsPath path = new GraphicsPath();
path.AddArc(0, 0, s.Width, s.Height, 0, 360);
this.Region = new Region(path);
}
}
class TriangleForm : CustomShapeForm
{
protected override void SetRegion() {
Size s = this.Size;
Point p1 = new Point(s.Width / 2, 0);
Point p2 = new Point(0, s.Height);
Point p3 = new Point(s.Width, s.Height);
GraphicsPath path = new GraphicsPath();
path.AddPolygon(new Point[] { p1, p2, p3 });
this.Region = new Region(path);
}
}
class Test
{
[ STAThread ]
public static void Main() {
Application.Run(new RoundForm());
// Application.Run(new TriangleForm());
}
}
■ このスレッドは過去ログ倉庫に格納されています