mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
Moving back to trunk!
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1602 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
ad265b2c54
commit
8d458998a1
332 changed files with 17647 additions and 9466 deletions
|
@ -21,29 +21,44 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Greenshot.Helpers
|
||||
{
|
||||
namespace Greenshot.Helpers {
|
||||
/// <summary>
|
||||
/// Description of GuiRectangle.
|
||||
/// Helper class for creating rectangles with positive dimensions, regardless of input coordinates
|
||||
/// </summary>
|
||||
public class GuiRectangle
|
||||
{
|
||||
private GuiRectangle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static class GuiRectangle {
|
||||
|
||||
public static Rectangle GetGuiRectangle(int x, int y, int w, int h) {
|
||||
if (w < 0) {
|
||||
x = x + w;
|
||||
w = -w;
|
||||
}
|
||||
if (h < 0) {
|
||||
y = y + h;
|
||||
h = -h;
|
||||
}
|
||||
return new Rectangle(x, y, w, h);
|
||||
Rectangle rect = new Rectangle(x, y, w, h);
|
||||
MakeGuiRectangle(ref rect);
|
||||
return rect;
|
||||
}
|
||||
|
||||
public static void MakeGuiRectangle(ref Rectangle rect) {
|
||||
if (rect.Width < 0) {
|
||||
rect.X += rect.Width;
|
||||
rect.Width = -rect.Width;
|
||||
}
|
||||
if (rect.Height < 0) {
|
||||
rect.Y += rect.Height;
|
||||
rect.Height = -rect.Height;
|
||||
}
|
||||
}
|
||||
|
||||
public static RectangleF GetGuiRectangleF(float x, float y, float w, float h) {
|
||||
RectangleF rect = new RectangleF(x, y, w, h);
|
||||
MakeGuiRectangleF(ref rect);
|
||||
return rect;
|
||||
}
|
||||
|
||||
public static void MakeGuiRectangleF(ref RectangleF rect) {
|
||||
if (rect.Width < 0) {
|
||||
rect.X += rect.Width;
|
||||
rect.Width = -rect.Width;
|
||||
}
|
||||
if (rect.Height < 0) {
|
||||
rect.Y += rect.Height;
|
||||
rect.Height = -rect.Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue