是否可以在Windows窗体中使用三角形$file = file_get_contents('http://nbd.esy.es/json/jsondb.json');
$json = json_decode($file, true);
foreach ($json['PlayerInfo'] as $playerInfo) {
$lastName = $playerInfo['tLastName'];
}
控件而不是矩形控件?
答案 0 :(得分:4)
您有一些选择,例如:
示例1
在此示例中,控制区域限制为三角形。
public class TriangularPictureBox:PictureBox
{
protected override void OnPaint(PaintEventArgs pe)
{
using (var p = new GraphicsPath())
{
p.AddPolygon(new Point[] {
new Point(this.Width / 2, 0),
new Point(0, Height),
new Point(Width, Height) });
this.Region = new Region(p);
base.OnPaint(pe);
}
}
}
示例2
在此示例中,绘画仅在控件的三角形区域进行。
public class TriangularPictureBox:PictureBox
{
protected override void OnPaint(PaintEventArgs pe)
{
using (var p = new GraphicsPath())
{
p.AddPolygon(new Point[] {
new Point(this.Width / 2, 0),
new Point(0, Height),
new Point(Width, Height) });
pe.Graphics.SetClip(p);
base.OnPaint(pe);
}
}
}