Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用GraphicsPath为面板创建自己的形状_C# - Fatal编程技术网

C# 使用GraphicsPath为面板创建自己的形状

C# 使用GraphicsPath为面板创建自己的形状,c#,C#,如何设置如下图所示的区域 我画的正方形是我要插入的面板。 假设面板尺寸为新尺寸(200500)。 然后我想删除中间的面板区域(带有标签B,区域是蓝色的)。 假设该区域的面积为50,50,位置为50,250 如何移除蓝色区域 这就是我所做的 GraphicsPath a = new GraphicsPath(); Rectangle RectangleRegion = new Rectangle(new point(50, 250), new Size(50,50));

如何设置如下图所示的区域

我画的正方形是我要插入的面板。 假设面板尺寸为新尺寸(200500)。 然后我想删除中间的面板区域(带有标签B,区域是蓝色的)。 假设该区域的面积为50,50,位置为50,250 如何移除蓝色区域

这就是我所做的

    GraphicsPath a = new GraphicsPath();
     Rectangle RectangleRegion = new Rectangle(new point(50, 250), new Size(50,50));
    graphicsPath.addRectangle (RectangleRegion) 

Panel myPanel = new panel(){new Size(200, 500), new Pont(0,0), region = new region(a);
使用这种方法,它不会删除我想要的区域
它只删除我想保留的另一部分,并保留我想删除的部分。

使用两个
区域和
区域。排除

Region r1 = new Region(new Rectangle(11,11,111,111));
Region r2 = new Region(new Rectangle(33,33,66,66));
r1.Exclude(r2);

panel1.Region = r1;


对于更复杂的形状,您确实需要从
图形创建
区域

使用两个区域和Region.Exclude。(并学习标点符号!)