GDI +地区平等 [英] Equality of GDI+ Regions

查看:126
本文介绍了GDI +地区平等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在以下code断言失败?为什么没有区域 A B 相等?

 地区=新区域(新的RectangleF(0.0,0.0,10.0f,10.0f));
  区域b =新区域();
  b.MakeEmpty();
  b.Union(新的RectangleF(0.0,0.0,10.0f,10.0f));
  Debug.Assert的(A == B区不等于);
 

解决方案

这是我所看到的, System.Drawing.Region 不覆盖对象的实施中的equals()。因此,你的 == 呼叫使用的ReferenceEquals 键,只是告诉你 A B 不在同一个对象。

请尝试使用 System.Drawing.Region.Equals(区,图形) 超载​​而是传递一个图形目标的背景下,你希望比较这两个地区。

Why does the assertion fail in the following code? Why aren't regions a and b equal?

  Region a = new Region(new RectangleF(0.0f, 0.0f, 10.0f, 10.0f));
  Region b = new Region();
  b.MakeEmpty();
  b.Union(new RectangleF(0.0f, 0.0f, 10.0f, 10.0f));
  Debug.Assert(a == b, "Regions not equal");

解决方案

From what I can see, System.Drawing.Region does not override Object's implementation of Equals(). Therefore your == call is using ReferenceEquals and simply telling you a and b are not the same object.

Try using the System.Drawing.Region.Equals(Region, Graphics) overload instead, passing in a Graphics object in the context you wish to compare the two regions.

这篇关于GDI +地区平等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆