如何减去从另一个矩形? [英] How to subtract a rectangle from another?

查看:152
本文介绍了如何减去从另一个矩形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图确定甚至当任务栏被隐藏桌面上的工作区域。

I'm trying to determine the working area of the desktop even when the taskbar is hidden.

我有两个矩形,屏幕的范围和任务栏中的边界。我需要从屏幕矩形减去任务栏的边界矩形来确定桌面的可用工作区。基本上,我想拿出Screen.WorkingArea除了当任务栏被隐藏。

I have two Rectangles, the screen's bounds and the taskbar's bounds. I need to subtract the taskbar's bounds Rectangle from the screen Rectangle to determine the available working area of the desktop. Basically, I want to come up with Screen.WorkingArea except when the taskbar is hidden.

说出屏幕矩形 X,Y,W,H = 0,0,1680,1050 和任务栏 X,Y,W,H是0,1010,1680,40 。我需要从第一减去第二次以确定该工作区为 0,0,1680,1010

Say the screen rectangle X,Y,W,H = 0,0,1680,1050 and the taskbar X,Y,W,H is 0,1010,1680,40. I need to subtract the second from the first to determine that the working area is 0,0,1680,1010.

任务栏可以是在屏幕的四边,我知道我们有了比确定那里的任务栏,然后有一个代码单独的行生成一个新的矩形为四个可能的更好的方法位置。

The taskbar can be on either of the four sides of the screen and I know there's got to be a better method than determining where the taskbar is and then having a separate line of code to generate a new Rectangle for each of the four possible positions.

推荐答案

我不知道还有比你提到的一个较好的方法。问题是,在一般情况下,减去另一个的矩形区域是要在两者之间留下一个孔,这样的结果是不是一个真正的矩形。在你的情况,你知道,在任务栏完全适合在屏幕矩形的一侧,所以最好的方式确实搞清楚是哪一方,并从侧面减去宽/高。

I'm not sure there's a better method than the one you mentioned. The problem is that in the general case, subtracting a rectangular region from another is going to leave a hole somewhere in between, so the result isn't really a rectangle. In your case, you know that the taskbar fits exactly on one of the sides of the screen rectangle, so the "best" way is indeed figuring out which side it is and subtracting the width/height from that side.

这篇关于如何减去从另一个矩形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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