c# winform如何取得两个region对象的交集的一个region
来源:百度知道 编辑:UC知道 时间:2024/05/21 01:51:03
为什么reg1.Intersect(reg2)没有用?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form6_Region类 : Form
{
public Form6_Region类()
{
InitializeComponent();
}
private void Form6_Region类_Paint(object sender, PaintEventArgs e)
{
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
Rectangle rect1=new Rectangle(10,10,100,100);
Rectangle rect2=new Rectangle(40,3,100,100);
Region reg1 = new Region(rect1);
Region reg2 = new Region(rect2);
g.Fi
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form6_Region类 : Form
{
public Form6_Region类()
{
InitializeComponent();
}
private void Form6_Region类_Paint(object sender, PaintEventArgs e)
{
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
Rectangle rect1=new Rectangle(10,10,100,100);
Rectangle rect2=new Rectangle(40,3,100,100);
Region reg1 = new Region(rect1);
Region reg2 = new Region(rect2);
g.Fi
System.Drawing.Graphics region00 = this.CreateGraphics();
Rectangle regionRect = new Rectangle(200, 200, 100, 100);
region00.DrawRectangle(Pens.Black, regionRect);
RectangleF complementRect = new RectangleF(290, 230, 100, 100);
region00.DrawRectangle(Pens.Red, Rectangle.Round(complementRect));
Region myRegion = new Region(regionRect);
myRegion.Intersect(complementRect);
SolidBrush myBrush = new SolidBrush(Color.Blue);
region00.FillRegion(myBrush, myRegion);