Removed BarotraumaServer's MonoGame dependency
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Xna.Framework.Graphics
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines sprite visual options for mirroring.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum SpriteEffects
|
||||
{
|
||||
/// <summary>
|
||||
/// No options specified.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Render the sprite reversed along the X axis.
|
||||
/// </summary>
|
||||
FlipHorizontally = 1,
|
||||
/// <summary>
|
||||
/// Render the sprite reversed along the Y axis.
|
||||
/// </summary>
|
||||
FlipVertically = 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
#region License
|
||||
// /*
|
||||
// Microsoft Public License (Ms-PL)
|
||||
// MonoGame - Copyright © 2009 The MonoGame Team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
|
||||
// accept the license, do not use the software.
|
||||
//
|
||||
// 1. Definitions
|
||||
// The terms "reproduce, " "reproduction, " "derivative works, " and "distribution" have the same meaning here as under
|
||||
// U.S. copyright law.
|
||||
//
|
||||
// A "contribution" is the original software, or any additions or changes to the software.
|
||||
// A "contributor" is any person that distributes its contribution under this license.
|
||||
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
||||
//
|
||||
// 2. Grant of Rights
|
||||
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
|
||||
// each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
//
|
||||
// 3. Conditions and Limitations
|
||||
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
||||
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
|
||||
// your patent license from such contributor to the software ends automatically.
|
||||
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
|
||||
// notices that are present in the software.
|
||||
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
|
||||
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object
|
||||
// code form, you may only do so under a license that complies with this license.
|
||||
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
|
||||
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
|
||||
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
|
||||
// purpose and non-infringement.
|
||||
// */
|
||||
#endregion License
|
||||
|
||||
namespace Microsoft.Xna.Framework.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the state of a keyboard key.
|
||||
/// </summary>
|
||||
public enum KeyState
|
||||
{
|
||||
/// <summary>
|
||||
/// Key is released.
|
||||
/// </summary>
|
||||
Up,
|
||||
|
||||
/// <summary>
|
||||
/// Key is pressed.
|
||||
/// </summary>
|
||||
Down,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Xna.Framework.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the state of keystrokes by a keyboard.
|
||||
/// </summary>
|
||||
public struct KeyboardState
|
||||
{
|
||||
// Used for the common situation where GetPressedKeys will return an empty array
|
||||
static Keys[] empty = new Keys[0];
|
||||
|
||||
#region Key Data
|
||||
|
||||
// Array of 256 bits:
|
||||
uint keys0, keys1, keys2, keys3, keys4, keys5, keys6, keys7;
|
||||
|
||||
bool InternalGetKey(Keys key)
|
||||
{
|
||||
uint mask = (uint)1 << (((int)key) & 0x1f);
|
||||
|
||||
uint element;
|
||||
switch (((int)key) >> 5)
|
||||
{
|
||||
case 0: element = keys0; break;
|
||||
case 1: element = keys1; break;
|
||||
case 2: element = keys2; break;
|
||||
case 3: element = keys3; break;
|
||||
case 4: element = keys4; break;
|
||||
case 5: element = keys5; break;
|
||||
case 6: element = keys6; break;
|
||||
case 7: element = keys7; break;
|
||||
default: element = 0; break;
|
||||
}
|
||||
|
||||
return (element & mask) != 0;
|
||||
}
|
||||
|
||||
void InternalSetKey(Keys key)
|
||||
{
|
||||
uint mask = (uint)1 << (((int)key) & 0x1f);
|
||||
switch (((int)key) >> 5)
|
||||
{
|
||||
case 0: keys0 |= mask; break;
|
||||
case 1: keys1 |= mask; break;
|
||||
case 2: keys2 |= mask; break;
|
||||
case 3: keys3 |= mask; break;
|
||||
case 4: keys4 |= mask; break;
|
||||
case 5: keys5 |= mask; break;
|
||||
case 6: keys6 |= mask; break;
|
||||
case 7: keys7 |= mask; break;
|
||||
}
|
||||
}
|
||||
|
||||
void InternalClearKey(Keys key)
|
||||
{
|
||||
uint mask = (uint)1 << (((int)key) & 0x1f);
|
||||
switch (((int)key) >> 5)
|
||||
{
|
||||
case 0: keys0 &= ~mask; break;
|
||||
case 1: keys1 &= ~mask; break;
|
||||
case 2: keys2 &= ~mask; break;
|
||||
case 3: keys3 &= ~mask; break;
|
||||
case 4: keys4 &= ~mask; break;
|
||||
case 5: keys5 &= ~mask; break;
|
||||
case 6: keys6 &= ~mask; break;
|
||||
case 7: keys7 &= ~mask; break;
|
||||
}
|
||||
}
|
||||
|
||||
void InternalClearAllKeys()
|
||||
{
|
||||
keys0 = 0;
|
||||
keys1 = 0;
|
||||
keys2 = 0;
|
||||
keys3 = 0;
|
||||
keys4 = 0;
|
||||
keys5 = 0;
|
||||
keys6 = 0;
|
||||
keys7 = 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region XNA Interface
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current state of the Caps Lock key.
|
||||
/// </summary>
|
||||
public bool CapsLock { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current state of the Num Lock key.
|
||||
/// </summary>
|
||||
public bool NumLock { get; private set; }
|
||||
|
||||
internal KeyboardState(List<Keys> keys, bool capsLock = false, bool numLock = false) : this()
|
||||
{
|
||||
CapsLock = capsLock;
|
||||
NumLock = numLock;
|
||||
|
||||
keys0 = 0;
|
||||
keys1 = 0;
|
||||
keys2 = 0;
|
||||
keys3 = 0;
|
||||
keys4 = 0;
|
||||
keys5 = 0;
|
||||
keys6 = 0;
|
||||
keys7 = 0;
|
||||
|
||||
if (keys != null)
|
||||
foreach (Keys k in keys)
|
||||
InternalSetKey(k);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="KeyboardState"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keys">List of keys to be flagged as pressed on initialization.</param>
|
||||
/// <param name="capsLock">Caps Lock state.</param>
|
||||
/// <param name="numLock">Num Lock state.</param>
|
||||
public KeyboardState(Keys[] keys, bool capsLock = false, bool numLock = false) : this()
|
||||
{
|
||||
CapsLock = capsLock;
|
||||
NumLock = numLock;
|
||||
|
||||
keys0 = 0;
|
||||
keys1 = 0;
|
||||
keys2 = 0;
|
||||
keys3 = 0;
|
||||
keys4 = 0;
|
||||
keys5 = 0;
|
||||
keys6 = 0;
|
||||
keys7 = 0;
|
||||
|
||||
if (keys != null)
|
||||
foreach (Keys k in keys)
|
||||
InternalSetKey(k);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="KeyboardState"/> class.
|
||||
/// </summary>
|
||||
/// <param name="keys">List of keys to be flagged as pressed on initialization.</param>
|
||||
public KeyboardState(params Keys[] keys) : this()
|
||||
{
|
||||
CapsLock = false;
|
||||
NumLock = false;
|
||||
|
||||
keys0 = 0;
|
||||
keys1 = 0;
|
||||
keys2 = 0;
|
||||
keys3 = 0;
|
||||
keys4 = 0;
|
||||
keys5 = 0;
|
||||
keys6 = 0;
|
||||
keys7 = 0;
|
||||
|
||||
if (keys != null)
|
||||
foreach (Keys k in keys)
|
||||
InternalSetKey(k);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the state of a specified key.
|
||||
/// </summary>
|
||||
/// <param name="key">The key to query.</param>
|
||||
/// <returns>The state of the key.</returns>
|
||||
public KeyState this[Keys key]
|
||||
{
|
||||
get { return InternalGetKey(key) ? KeyState.Down : KeyState.Up; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether given key is currently being pressed.
|
||||
/// </summary>
|
||||
/// <param name="key">The key to query.</param>
|
||||
/// <returns>true if the key is pressed; false otherwise.</returns>
|
||||
public bool IsKeyDown(Keys key)
|
||||
{
|
||||
return InternalGetKey(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether given key is currently being not pressed.
|
||||
/// </summary>
|
||||
/// <param name="key">The key to query.</param>
|
||||
/// <returns>true if the key is not pressed; false otherwise.</returns>
|
||||
public bool IsKeyUp(Keys key)
|
||||
{
|
||||
return !InternalGetKey(key);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region GetPressedKeys()
|
||||
|
||||
private static uint CountBits(uint v)
|
||||
{
|
||||
// http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
|
||||
v = v - ((v >> 1) & 0x55555555); // reuse input as temporary
|
||||
v = (v & 0x33333333) + ((v >> 2) & 0x33333333); // temp
|
||||
return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; // count
|
||||
}
|
||||
|
||||
private static int AddKeysToArray(uint keys, int offset, Keys[] pressedKeys, int index)
|
||||
{
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
if ((keys & (1 << i)) != 0)
|
||||
pressedKeys[index++] = (Keys)(offset + i);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an array of values holding keys that are currently being pressed.
|
||||
/// </summary>
|
||||
/// <returns>The keys that are currently being pressed.</returns>
|
||||
public Keys[] GetPressedKeys()
|
||||
{
|
||||
uint count = CountBits(keys0) + CountBits(keys1) + CountBits(keys2) + CountBits(keys3)
|
||||
+ CountBits(keys4) + CountBits(keys5) + CountBits(keys6) + CountBits(keys7);
|
||||
if (count == 0)
|
||||
return empty;
|
||||
Keys[] keys = new Keys[count];
|
||||
|
||||
int index = 0;
|
||||
if (keys0 != 0) index = AddKeysToArray(keys0, 0 * 32, keys, index);
|
||||
if (keys1 != 0) index = AddKeysToArray(keys1, 1 * 32, keys, index);
|
||||
if (keys2 != 0) index = AddKeysToArray(keys2, 2 * 32, keys, index);
|
||||
if (keys3 != 0) index = AddKeysToArray(keys3, 3 * 32, keys, index);
|
||||
if (keys4 != 0) index = AddKeysToArray(keys4, 4 * 32, keys, index);
|
||||
if (keys5 != 0) index = AddKeysToArray(keys5, 5 * 32, keys, index);
|
||||
if (keys6 != 0) index = AddKeysToArray(keys6, 6 * 32, keys, index);
|
||||
if (keys7 != 0) index = AddKeysToArray(keys7, 7 * 32, keys, index);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Objet and Equality
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code for <see cref="KeyboardState"/> instance.
|
||||
/// </summary>
|
||||
/// <returns>Hash code of the object.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (int)(keys0 ^ keys1 ^ keys2 ^ keys3 ^ keys4 ^ keys5 ^ keys6 ^ keys7);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="KeyboardState"/> instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="KeyboardState"/> instance to the left of the equality operator.</param>
|
||||
/// <param name="b"><see cref="KeyboardState"/> instance to the right of the equality operator.</param>
|
||||
/// <returns>true if the instances are equal; false otherwise.</returns>
|
||||
public static bool operator ==(KeyboardState a, KeyboardState b)
|
||||
{
|
||||
return a.keys0 == b.keys0
|
||||
&& a.keys1 == b.keys1
|
||||
&& a.keys2 == b.keys2
|
||||
&& a.keys3 == b.keys3
|
||||
&& a.keys4 == b.keys4
|
||||
&& a.keys5 == b.keys5
|
||||
&& a.keys6 == b.keys6
|
||||
&& a.keys7 == b.keys7;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="KeyboardState"/> instances are not equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="KeyboardState"/> instance to the left of the inequality operator.</param>
|
||||
/// <param name="b"><see cref="KeyboardState"/> instance to the right of the inequality operator.</param>
|
||||
/// <returns>true if the instances are different; false otherwise.</returns>
|
||||
public static bool operator !=(KeyboardState a, KeyboardState b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="KeyboardState"/> to compare.</param>
|
||||
/// <returns>true if the provided <see cref="KeyboardState"/> instance is same with current; false otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is KeyboardState && this == (KeyboardState)obj;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,653 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
namespace Microsoft.Xna.Framework.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the keys on a keyboard.
|
||||
/// </summary>
|
||||
public enum Keys
|
||||
{
|
||||
/// <summary>
|
||||
/// Reserved.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// BACKSPACE key.
|
||||
/// </summary>
|
||||
Back = 8,
|
||||
/// <summary>
|
||||
/// TAB key.
|
||||
/// </summary>
|
||||
Tab = 9,
|
||||
/// <summary>
|
||||
/// ENTER key.
|
||||
/// </summary>
|
||||
Enter = 13,
|
||||
/// <summary>
|
||||
/// CAPS LOCK key.
|
||||
/// </summary>
|
||||
CapsLock = 20,
|
||||
/// <summary>
|
||||
/// ESC key.
|
||||
/// </summary>
|
||||
Escape = 27,
|
||||
/// <summary>
|
||||
/// SPACEBAR key.
|
||||
/// </summary>
|
||||
Space = 32,
|
||||
/// <summary>
|
||||
/// PAGE UP key.
|
||||
/// </summary>
|
||||
PageUp = 33,
|
||||
/// <summary>
|
||||
/// PAGE DOWN key.
|
||||
/// </summary>
|
||||
PageDown = 34,
|
||||
/// <summary>
|
||||
/// END key.
|
||||
/// </summary>
|
||||
End = 35,
|
||||
/// <summary>
|
||||
/// HOME key.
|
||||
/// </summary>
|
||||
Home = 36,
|
||||
/// <summary>
|
||||
/// LEFT ARROW key.
|
||||
/// </summary>
|
||||
Left = 37,
|
||||
/// <summary>
|
||||
/// UP ARROW key.
|
||||
/// </summary>
|
||||
Up = 38,
|
||||
/// <summary>
|
||||
/// RIGHT ARROW key.
|
||||
/// </summary>
|
||||
Right = 39,
|
||||
/// <summary>
|
||||
/// DOWN ARROW key.
|
||||
/// </summary>
|
||||
Down = 40,
|
||||
/// <summary>
|
||||
/// SELECT key.
|
||||
/// </summary>
|
||||
Select = 41,
|
||||
/// <summary>
|
||||
/// PRINT key.
|
||||
/// </summary>
|
||||
Print = 42,
|
||||
/// <summary>
|
||||
/// EXECUTE key.
|
||||
/// </summary>
|
||||
Execute = 43,
|
||||
/// <summary>
|
||||
/// PRINT SCREEN key.
|
||||
/// </summary>
|
||||
PrintScreen = 44,
|
||||
/// <summary>
|
||||
/// INS key.
|
||||
/// </summary>
|
||||
Insert = 45,
|
||||
/// <summary>
|
||||
/// DEL key.
|
||||
/// </summary>
|
||||
Delete = 46,
|
||||
/// <summary>
|
||||
/// HELP key.
|
||||
/// </summary>
|
||||
Help = 47,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D0 = 48,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D1 = 49,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D2 = 50,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D3 = 51,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D4 = 52,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D5 = 53,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D6 = 54,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D7 = 55,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D8 = 56,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
D9 = 57,
|
||||
/// <summary>
|
||||
/// A key.
|
||||
/// </summary>
|
||||
A = 65,
|
||||
/// <summary>
|
||||
/// B key.
|
||||
/// </summary>
|
||||
B = 66,
|
||||
/// <summary>
|
||||
/// C key.
|
||||
/// </summary>
|
||||
C = 67,
|
||||
/// <summary>
|
||||
/// D key.
|
||||
/// </summary>
|
||||
D = 68,
|
||||
/// <summary>
|
||||
/// E key.
|
||||
/// </summary>
|
||||
E = 69,
|
||||
/// <summary>
|
||||
/// F key.
|
||||
/// </summary>
|
||||
F = 70,
|
||||
/// <summary>
|
||||
/// G key.
|
||||
/// </summary>
|
||||
G = 71,
|
||||
/// <summary>
|
||||
/// H key.
|
||||
/// </summary>
|
||||
H = 72,
|
||||
/// <summary>
|
||||
/// I key.
|
||||
/// </summary>
|
||||
I = 73,
|
||||
/// <summary>
|
||||
/// J key.
|
||||
/// </summary>
|
||||
J = 74,
|
||||
/// <summary>
|
||||
/// K key.
|
||||
/// </summary>
|
||||
K = 75,
|
||||
/// <summary>
|
||||
/// L key.
|
||||
/// </summary>
|
||||
L = 76,
|
||||
/// <summary>
|
||||
/// M key.
|
||||
/// </summary>
|
||||
M = 77,
|
||||
/// <summary>
|
||||
/// N key.
|
||||
/// </summary>
|
||||
N = 78,
|
||||
/// <summary>
|
||||
/// O key.
|
||||
/// </summary>
|
||||
O = 79,
|
||||
/// <summary>
|
||||
/// P key.
|
||||
/// </summary>
|
||||
P = 80,
|
||||
/// <summary>
|
||||
/// Q key.
|
||||
/// </summary>
|
||||
Q = 81,
|
||||
/// <summary>
|
||||
/// R key.
|
||||
/// </summary>
|
||||
R = 82,
|
||||
/// <summary>
|
||||
/// S key.
|
||||
/// </summary>
|
||||
S = 83,
|
||||
/// <summary>
|
||||
/// T key.
|
||||
/// </summary>
|
||||
T = 84,
|
||||
/// <summary>
|
||||
/// U key.
|
||||
/// </summary>
|
||||
U = 85,
|
||||
/// <summary>
|
||||
/// V key.
|
||||
/// </summary>
|
||||
V = 86,
|
||||
/// <summary>
|
||||
/// W key.
|
||||
/// </summary>
|
||||
W = 87,
|
||||
/// <summary>
|
||||
/// X key.
|
||||
/// </summary>
|
||||
X = 88,
|
||||
/// <summary>
|
||||
/// Y key.
|
||||
/// </summary>
|
||||
Y = 89,
|
||||
/// <summary>
|
||||
/// Z key.
|
||||
/// </summary>
|
||||
Z = 90,
|
||||
/// <summary>
|
||||
/// Left Windows key.
|
||||
/// </summary>
|
||||
LeftWindows = 91,
|
||||
/// <summary>
|
||||
/// Right Windows key.
|
||||
/// </summary>
|
||||
RightWindows = 92,
|
||||
/// <summary>
|
||||
/// Applications key.
|
||||
/// </summary>
|
||||
Apps = 93,
|
||||
/// <summary>
|
||||
/// Computer Sleep key.
|
||||
/// </summary>
|
||||
Sleep = 95,
|
||||
/// <summary>
|
||||
/// Numeric keypad 0 key.
|
||||
/// </summary>
|
||||
NumPad0 = 96,
|
||||
/// <summary>
|
||||
/// Numeric keypad 1 key.
|
||||
/// </summary>
|
||||
NumPad1 = 97,
|
||||
/// <summary>
|
||||
/// Numeric keypad 2 key.
|
||||
/// </summary>
|
||||
NumPad2 = 98,
|
||||
/// <summary>
|
||||
/// Numeric keypad 3 key.
|
||||
/// </summary>
|
||||
NumPad3 = 99,
|
||||
/// <summary>
|
||||
/// Numeric keypad 4 key.
|
||||
/// </summary>
|
||||
NumPad4 = 100,
|
||||
/// <summary>
|
||||
/// Numeric keypad 5 key.
|
||||
/// </summary>
|
||||
NumPad5 = 101,
|
||||
/// <summary>
|
||||
/// Numeric keypad 6 key.
|
||||
/// </summary>
|
||||
NumPad6 = 102,
|
||||
/// <summary>
|
||||
/// Numeric keypad 7 key.
|
||||
/// </summary>
|
||||
NumPad7 = 103,
|
||||
/// <summary>
|
||||
/// Numeric keypad 8 key.
|
||||
/// </summary>
|
||||
NumPad8 = 104,
|
||||
/// <summary>
|
||||
/// Numeric keypad 9 key.
|
||||
/// </summary>
|
||||
NumPad9 = 105,
|
||||
/// <summary>
|
||||
/// Multiply key.
|
||||
/// </summary>
|
||||
Multiply = 106,
|
||||
/// <summary>
|
||||
/// Add key.
|
||||
/// </summary>
|
||||
Add = 107,
|
||||
/// <summary>
|
||||
/// Separator key.
|
||||
/// </summary>
|
||||
Separator = 108,
|
||||
/// <summary>
|
||||
/// Subtract key.
|
||||
/// </summary>
|
||||
Subtract = 109,
|
||||
/// <summary>
|
||||
/// Decimal key.
|
||||
/// </summary>
|
||||
Decimal = 110,
|
||||
/// <summary>
|
||||
/// Divide key.
|
||||
/// </summary>
|
||||
Divide = 111,
|
||||
/// <summary>
|
||||
/// F1 key.
|
||||
/// </summary>
|
||||
F1 = 112,
|
||||
/// <summary>
|
||||
/// F2 key.
|
||||
/// </summary>
|
||||
F2 = 113,
|
||||
/// <summary>
|
||||
/// F3 key.
|
||||
/// </summary>
|
||||
F3 = 114,
|
||||
/// <summary>
|
||||
/// F4 key.
|
||||
/// </summary>
|
||||
F4 = 115,
|
||||
/// <summary>
|
||||
/// F5 key.
|
||||
/// </summary>
|
||||
F5 = 116,
|
||||
/// <summary>
|
||||
/// F6 key.
|
||||
/// </summary>
|
||||
F6 = 117,
|
||||
/// <summary>
|
||||
/// F7 key.
|
||||
/// </summary>
|
||||
F7 = 118,
|
||||
/// <summary>
|
||||
/// F8 key.
|
||||
/// </summary>
|
||||
F8 = 119,
|
||||
/// <summary>
|
||||
/// F9 key.
|
||||
/// </summary>
|
||||
F9 = 120,
|
||||
/// <summary>
|
||||
/// F10 key.
|
||||
/// </summary>
|
||||
F10 = 121,
|
||||
/// <summary>
|
||||
/// F11 key.
|
||||
/// </summary>
|
||||
F11 = 122,
|
||||
/// <summary>
|
||||
/// F12 key.
|
||||
/// </summary>
|
||||
F12 = 123,
|
||||
/// <summary>
|
||||
/// F13 key.
|
||||
/// </summary>
|
||||
F13 = 124,
|
||||
/// <summary>
|
||||
/// F14 key.
|
||||
/// </summary>
|
||||
F14 = 125,
|
||||
/// <summary>
|
||||
/// F15 key.
|
||||
/// </summary>
|
||||
F15 = 126,
|
||||
/// <summary>
|
||||
/// F16 key.
|
||||
/// </summary>
|
||||
F16 = 127,
|
||||
/// <summary>
|
||||
/// F17 key.
|
||||
/// </summary>
|
||||
F17 = 128,
|
||||
/// <summary>
|
||||
/// F18 key.
|
||||
/// </summary>
|
||||
F18 = 129,
|
||||
/// <summary>
|
||||
/// F19 key.
|
||||
/// </summary>
|
||||
F19 = 130,
|
||||
/// <summary>
|
||||
/// F20 key.
|
||||
/// </summary>
|
||||
F20 = 131,
|
||||
/// <summary>
|
||||
/// F21 key.
|
||||
/// </summary>
|
||||
F21 = 132,
|
||||
/// <summary>
|
||||
/// F22 key.
|
||||
/// </summary>
|
||||
F22 = 133,
|
||||
/// <summary>
|
||||
/// F23 key.
|
||||
/// </summary>
|
||||
F23 = 134,
|
||||
/// <summary>
|
||||
/// F24 key.
|
||||
/// </summary>
|
||||
F24 = 135,
|
||||
/// <summary>
|
||||
/// NUM LOCK key.
|
||||
/// </summary>
|
||||
NumLock = 144,
|
||||
/// <summary>
|
||||
/// SCROLL LOCK key.
|
||||
/// </summary>
|
||||
Scroll = 145,
|
||||
/// <summary>
|
||||
/// Left SHIFT key.
|
||||
/// </summary>
|
||||
LeftShift = 160,
|
||||
/// <summary>
|
||||
/// Right SHIFT key.
|
||||
/// </summary>
|
||||
RightShift = 161,
|
||||
/// <summary>
|
||||
/// Left CONTROL key.
|
||||
/// </summary>
|
||||
LeftControl = 162,
|
||||
/// <summary>
|
||||
/// Right CONTROL key.
|
||||
/// </summary>
|
||||
RightControl = 163,
|
||||
/// <summary>
|
||||
/// Left ALT key.
|
||||
/// </summary>
|
||||
LeftAlt = 164,
|
||||
/// <summary>
|
||||
/// Right ALT key.
|
||||
/// </summary>
|
||||
RightAlt = 165,
|
||||
/// <summary>
|
||||
/// Browser Back key.
|
||||
/// </summary>
|
||||
BrowserBack = 166,
|
||||
/// <summary>
|
||||
/// Browser Forward key.
|
||||
/// </summary>
|
||||
BrowserForward = 167,
|
||||
/// <summary>
|
||||
/// Browser Refresh key.
|
||||
/// </summary>
|
||||
BrowserRefresh = 168,
|
||||
/// <summary>
|
||||
/// Browser Stop key.
|
||||
/// </summary>
|
||||
BrowserStop = 169,
|
||||
/// <summary>
|
||||
/// Browser Search key.
|
||||
/// </summary>
|
||||
BrowserSearch = 170,
|
||||
/// <summary>
|
||||
/// Browser Favorites key.
|
||||
/// </summary>
|
||||
BrowserFavorites = 171,
|
||||
/// <summary>
|
||||
/// Browser Start and Home key.
|
||||
/// </summary>
|
||||
BrowserHome = 172,
|
||||
/// <summary>
|
||||
/// Volume Mute key.
|
||||
/// </summary>
|
||||
VolumeMute = 173,
|
||||
/// <summary>
|
||||
/// Volume Down key.
|
||||
/// </summary>
|
||||
VolumeDown = 174,
|
||||
/// <summary>
|
||||
/// Volume Up key.
|
||||
/// </summary>
|
||||
VolumeUp = 175,
|
||||
/// <summary>
|
||||
/// Next Track key.
|
||||
/// </summary>
|
||||
MediaNextTrack = 176,
|
||||
/// <summary>
|
||||
/// Previous Track key.
|
||||
/// </summary>
|
||||
MediaPreviousTrack = 177,
|
||||
/// <summary>
|
||||
/// Stop Media key.
|
||||
/// </summary>
|
||||
MediaStop = 178,
|
||||
/// <summary>
|
||||
/// Play/Pause Media key.
|
||||
/// </summary>
|
||||
MediaPlayPause = 179,
|
||||
/// <summary>
|
||||
/// Start Mail key.
|
||||
/// </summary>
|
||||
LaunchMail = 180,
|
||||
/// <summary>
|
||||
/// Select Media key.
|
||||
/// </summary>
|
||||
SelectMedia = 181,
|
||||
/// <summary>
|
||||
/// Start Application 1 key.
|
||||
/// </summary>
|
||||
LaunchApplication1 = 182,
|
||||
/// <summary>
|
||||
/// Start Application 2 key.
|
||||
/// </summary>
|
||||
LaunchApplication2 = 183,
|
||||
/// <summary>
|
||||
/// The OEM Semicolon key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemSemicolon = 186,
|
||||
/// <summary>
|
||||
/// For any country/region, the '+' key.
|
||||
/// </summary>
|
||||
OemPlus = 187,
|
||||
/// <summary>
|
||||
/// For any country/region, the ',' key.
|
||||
/// </summary>
|
||||
OemComma = 188,
|
||||
/// <summary>
|
||||
/// For any country/region, the '-' key.
|
||||
/// </summary>
|
||||
OemMinus = 189,
|
||||
/// <summary>
|
||||
/// For any country/region, the '.' key.
|
||||
/// </summary>
|
||||
OemPeriod = 190,
|
||||
/// <summary>
|
||||
/// The OEM question mark key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemQuestion = 191,
|
||||
/// <summary>
|
||||
/// The OEM tilde key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemTilde = 192,
|
||||
/// <summary>
|
||||
/// The OEM open bracket key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemOpenBrackets = 219,
|
||||
/// <summary>
|
||||
/// The OEM pipe key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemPipe = 220,
|
||||
/// <summary>
|
||||
/// The OEM close bracket key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemCloseBrackets = 221,
|
||||
/// <summary>
|
||||
/// The OEM singled/double quote key on a US standard keyboard.
|
||||
/// </summary>
|
||||
OemQuotes = 222,
|
||||
/// <summary>
|
||||
/// Used for miscellaneous characters; it can vary by keyboard.
|
||||
/// </summary>
|
||||
Oem8 = 223,
|
||||
/// <summary>
|
||||
/// The OEM angle bracket or backslash key on the RT 102 key keyboard.
|
||||
/// </summary>
|
||||
OemBackslash = 226,
|
||||
/// <summary>
|
||||
/// IME PROCESS key.
|
||||
/// </summary>
|
||||
ProcessKey = 229,
|
||||
/// <summary>
|
||||
/// Attn key.
|
||||
/// </summary>
|
||||
Attn = 246,
|
||||
/// <summary>
|
||||
/// CrSel key.
|
||||
/// </summary>
|
||||
Crsel = 247,
|
||||
/// <summary>
|
||||
/// ExSel key.
|
||||
/// </summary>
|
||||
Exsel = 248,
|
||||
/// <summary>
|
||||
/// Erase EOF key.
|
||||
/// </summary>
|
||||
EraseEof = 249,
|
||||
/// <summary>
|
||||
/// Play key.
|
||||
/// </summary>
|
||||
Play = 250,
|
||||
/// <summary>
|
||||
/// Zoom key.
|
||||
/// </summary>
|
||||
Zoom = 251,
|
||||
/// <summary>
|
||||
/// PA1 key.
|
||||
/// </summary>
|
||||
Pa1 = 253,
|
||||
/// <summary>
|
||||
/// CLEAR key.
|
||||
/// </summary>
|
||||
OemClear = 254,
|
||||
/// <summary>
|
||||
/// Green ChatPad key.
|
||||
/// </summary>
|
||||
ChatPadGreen = 0xCA,
|
||||
/// <summary>
|
||||
/// Orange ChatPad key.
|
||||
/// </summary>
|
||||
ChatPadOrange = 0xCB,
|
||||
/// <summary>
|
||||
/// PAUSE key.
|
||||
/// </summary>
|
||||
Pause = 0x13,
|
||||
/// <summary>
|
||||
/// IME Convert key.
|
||||
/// </summary>
|
||||
ImeConvert = 0x1c,
|
||||
/// <summary>
|
||||
/// IME NoConvert key.
|
||||
/// </summary>
|
||||
ImeNoConvert = 0x1d,
|
||||
/// <summary>
|
||||
/// Kana key on Japanese keyboards.
|
||||
/// </summary>
|
||||
Kana = 0x15,
|
||||
/// <summary>
|
||||
/// Kanji key on Japanese keyboards.
|
||||
/// </summary>
|
||||
Kanji = 0x19,
|
||||
/// <summary>
|
||||
/// OEM Auto key.
|
||||
/// </summary>
|
||||
OemAuto = 0xf3,
|
||||
/// <summary>
|
||||
/// OEM Copy key.
|
||||
/// </summary>
|
||||
OemCopy = 0xf2,
|
||||
/// <summary>
|
||||
/// OEM Enlarge Window key.
|
||||
/// </summary>
|
||||
OemEnlW = 0xf4
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a 2D-point.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
||||
public struct Point : IEquatable<Point>
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static readonly Point zeroPoint = new Point();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// The x coordinate of this <see cref="Point"/>.
|
||||
/// </summary>
|
||||
public int X;
|
||||
|
||||
/// <summary>
|
||||
/// The y coordinate of this <see cref="Point"/>.
|
||||
/// </summary>
|
||||
public int Y;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="Point"/> with coordinates 0, 0.
|
||||
/// </summary>
|
||||
public static Point Zero
|
||||
{
|
||||
get { return zeroPoint; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Properties
|
||||
|
||||
internal string DebugDisplayString
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Concat(
|
||||
this.X.ToString(), " ",
|
||||
this.Y.ToString()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a point with X and Y from two values.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate in 2d-space.</param>
|
||||
/// <param name="y">The y coordinate in 2d-space.</param>
|
||||
public Point(int x, int y)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a point with X and Y set to the same value.
|
||||
/// </summary>
|
||||
/// <param name="value">The x and y coordinates in 2d-space.</param>
|
||||
public Point(int value)
|
||||
{
|
||||
this.X = value;
|
||||
this.Y = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
/// <summary>
|
||||
/// Adds two points.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source <see cref="Point"/> on the left of the add sign.</param>
|
||||
/// <param name="value2">Source <see cref="Point"/> on the right of the add sign.</param>
|
||||
/// <returns>Sum of the points.</returns>
|
||||
public static Point operator +(Point value1, Point value2)
|
||||
{
|
||||
return new Point(value1.X + value2.X, value1.Y + value2.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts a <see cref="Point"/> from a <see cref="Point"/>.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source <see cref="Point"/> on the left of the sub sign.</param>
|
||||
/// <param name="value2">Source <see cref="Point"/> on the right of the sub sign.</param>
|
||||
/// <returns>Result of the subtraction.</returns>
|
||||
public static Point operator -(Point value1, Point value2)
|
||||
{
|
||||
return new Point(value1.X - value2.X, value1.Y - value2.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies the components of two points by each other.
|
||||
/// </summary>
|
||||
/// <param name="value1">Source <see cref="Point"/> on the left of the mul sign.</param>
|
||||
/// <param name="value2">Source <see cref="Point"/> on the right of the mul sign.</param>
|
||||
/// <returns>Result of the multiplication.</returns>
|
||||
public static Point operator *(Point value1, Point value2)
|
||||
{
|
||||
return new Point(value1.X * value2.X, value1.Y * value2.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Divides the components of a <see cref="Point"/> by the components of another <see cref="Point"/>.
|
||||
/// </summary>
|
||||
/// <param name="source">Source <see cref="Point"/> on the left of the div sign.</param>
|
||||
/// <param name="divisor">Divisor <see cref="Point"/> on the right of the div sign.</param>
|
||||
/// <returns>The result of dividing the points.</returns>
|
||||
public static Point operator /(Point source, Point divisor)
|
||||
{
|
||||
return new Point(source.X / divisor.X, source.Y / divisor.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Point"/> instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Point"/> instance on the left of the equal sign.</param>
|
||||
/// <param name="b"><see cref="Point"/> instance on the right of the equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator ==(Point a, Point b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Point"/> instances are not equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Point"/> instance on the left of the not equal sign.</param>
|
||||
/// <param name="b"><see cref="Point"/> instance on the right of the not equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are not equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator !=(Point a, Point b)
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Object"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Object"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Point) && Equals((Point)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Point"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="Point"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public bool Equals(Point other)
|
||||
{
|
||||
return ((X == other.X) && (Y == other.Y));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code of this <see cref="Point"/>.
|
||||
/// </summary>
|
||||
/// <returns>Hash code of this <see cref="Point"/>.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hash = 17;
|
||||
hash = hash * 23 + X.GetHashCode();
|
||||
hash = hash * 23 + Y.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="String"/> representation of this <see cref="Point"/> in the format:
|
||||
/// {X:[<see cref="X"/>] Y:[<see cref="Y"/>]}
|
||||
/// </summary>
|
||||
/// <returns><see cref="String"/> representation of this <see cref="Point"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "{X:" + X + " Y:" + Y + "}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Vector2"/> representation for this object.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Vector2"/> representation for this object.</returns>
|
||||
public Vector2 ToVector2()
|
||||
{
|
||||
return new Vector2(X, Y);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,524 @@
|
||||
// MIT License - Copyright (C) The Mono.Xna Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.Xna.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a 2D-rectangle.
|
||||
/// </summary>
|
||||
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
||||
public struct Rectangle : IEquatable<Rectangle>
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static Rectangle emptyRectangle = new Rectangle();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// The x coordinate of the top-left corner of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
|
||||
public int X;
|
||||
|
||||
/// <summary>
|
||||
/// The y coordinate of the top-left corner of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
|
||||
public int Y;
|
||||
|
||||
/// <summary>
|
||||
/// The width of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
|
||||
public int Width;
|
||||
|
||||
/// <summary>
|
||||
/// The height of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
|
||||
public int Height;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="Rectangle"/> with X=0, Y=0, Width=0, Height=0.
|
||||
/// </summary>
|
||||
public static Rectangle Empty
|
||||
{
|
||||
get { return emptyRectangle; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the x coordinate of the left edge of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public int Left
|
||||
{
|
||||
get { return this.X; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the x coordinate of the right edge of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public int Right
|
||||
{
|
||||
get { return (this.X + this.Width); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the y coordinate of the top edge of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public int Top
|
||||
{
|
||||
get { return this.Y; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the y coordinate of the bottom edge of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public int Bottom
|
||||
{
|
||||
get { return (this.Y + this.Height); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not this <see cref="Rectangle"/> has a <see cref="Width"/> and
|
||||
/// <see cref="Height"/> of 0, and a <see cref="Location"/> of (0, 0).
|
||||
/// </summary>
|
||||
public bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((((this.Width == 0) && (this.Height == 0)) && (this.X == 0)) && (this.Y == 0));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The top-left coordinates of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public Point Location
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Point(this.X, this.Y);
|
||||
}
|
||||
set
|
||||
{
|
||||
X = value.X;
|
||||
Y = value.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The width-height coordinates of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
public Point Size
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Point(this.Width,this.Height);
|
||||
}
|
||||
set
|
||||
{
|
||||
Width = value.X;
|
||||
Height = value.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="Point"/> located in the center of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If <see cref="Width"/> or <see cref="Height"/> is an odd number,
|
||||
/// the center point will be rounded down.
|
||||
/// </remarks>
|
||||
public Point Center
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Point(this.X + (this.Width / 2), this.Y + (this.Height / 2));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Properties
|
||||
|
||||
internal string DebugDisplayString
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Concat(
|
||||
this.X, " ",
|
||||
this.Y, " ",
|
||||
this.Width, " ",
|
||||
this.Height
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="Rectangle"/> struct, with the specified
|
||||
/// position, width, and height.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate of the top-left corner of the created <see cref="Rectangle"/>.</param>
|
||||
/// <param name="y">The y coordinate of the top-left corner of the created <see cref="Rectangle"/>.</param>
|
||||
/// <param name="width">The width of the created <see cref="Rectangle"/>.</param>
|
||||
/// <param name="height">The height of the created <see cref="Rectangle"/>.</param>
|
||||
public Rectangle(int x, int y, int width, int height)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
this.Width = width;
|
||||
this.Height = height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="Rectangle"/> struct, with the specified
|
||||
/// location and size.
|
||||
/// </summary>
|
||||
/// <param name="location">The x and y coordinates of the top-left corner of the created <see cref="Rectangle"/>.</param>
|
||||
/// <param name="size">The width and height of the created <see cref="Rectangle"/>.</param>
|
||||
public Rectangle(Point location,Point size)
|
||||
{
|
||||
this.X = location.X;
|
||||
this.Y = location.Y;
|
||||
this.Width = size.X;
|
||||
this.Height = size.Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Rectangle"/> instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Rectangle"/> instance on the left of the equal sign.</param>
|
||||
/// <param name="b"><see cref="Rectangle"/> instance on the right of the equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator ==(Rectangle a, Rectangle b)
|
||||
{
|
||||
return ((a.X == b.X) && (a.Y == b.Y) && (a.Width == b.Width) && (a.Height == b.Height));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Rectangle"/> instances are not equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Rectangle"/> instance on the left of the not equal sign.</param>
|
||||
/// <param name="b"><see cref="Rectangle"/> instance on the right of the not equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are not equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator !=(Rectangle a, Rectangle b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided coordinates lie within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate of the point to check for containment.</param>
|
||||
/// <param name="y">The y coordinate of the point to check for containment.</param>
|
||||
/// <returns><c>true</c> if the provided coordinates lie inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(int x, int y)
|
||||
{
|
||||
return ((((this.X <= x) && (x < (this.X + this.Width))) && (this.Y <= y)) && (y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided coordinates lie within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate of the point to check for containment.</param>
|
||||
/// <param name="y">The y coordinate of the point to check for containment.</param>
|
||||
/// <returns><c>true</c> if the provided coordinates lie inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(float x, float y)
|
||||
{
|
||||
return ((((this.X <= x) && (x < (this.X + this.Width))) && (this.Y <= y)) && (y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Point"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Point"/> lies inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(Point value)
|
||||
{
|
||||
return ((((this.X <= value.X) && (value.X < (this.X + this.Width))) && (this.Y <= value.Y)) && (value.Y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Point"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Point"/> lies inside this <see cref="Rectangle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Contains(ref Point value, out bool result)
|
||||
{
|
||||
result = ((((this.X <= value.X) && (value.X < (this.X + this.Width))) && (this.Y <= value.Y)) && (value.Y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Vector2"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Vector2"/> lies inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(Vector2 value)
|
||||
{
|
||||
return ((((this.X <= value.X) && (value.X < (this.X + this.Width))) && (this.Y <= value.Y)) && (value.Y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Vector2"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Vector2"/> lies inside this <see cref="Rectangle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Contains(ref Vector2 value, out bool result)
|
||||
{
|
||||
result = ((((this.X <= value.X) && (value.X < (this.X + this.Width))) && (this.Y <= value.Y)) && (value.Y < (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Rectangle"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="Rectangle"/> to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Rectangle"/>'s bounds lie entirely inside this <see cref="Rectangle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(Rectangle value)
|
||||
{
|
||||
return ((((this.X <= value.X) && ((value.X + value.Width) <= (this.X + this.Width))) && (this.Y <= value.Y)) && ((value.Y + value.Height) <= (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Rectangle"/> lies within the bounds of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="Rectangle"/> to check for inclusion in this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Rectangle"/>'s bounds lie entirely inside this <see cref="Rectangle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Contains(ref Rectangle value,out bool result)
|
||||
{
|
||||
result = ((((this.X <= value.X) && ((value.X + value.Width) <= (this.X + this.Width))) && (this.Y <= value.Y)) && ((value.Y + value.Height) <= (this.Y + this.Height)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Object"/>.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="Object"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Rectangle) && this == ((Rectangle)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="Rectangle"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public bool Equals(Rectangle other)
|
||||
{
|
||||
return this == other;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <returns>Hash code of this <see cref="Rectangle"/>.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hash = 17;
|
||||
hash = hash * 23 + X.GetHashCode();
|
||||
hash = hash * 23 + Y.GetHashCode();
|
||||
hash = hash * 23 + Width.GetHashCode();
|
||||
hash = hash * 23 + Height.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjusts the edges of this <see cref="Rectangle"/> by specified horizontal and vertical amounts.
|
||||
/// </summary>
|
||||
/// <param name="horizontalAmount">Value to adjust the left and right edges.</param>
|
||||
/// <param name="verticalAmount">Value to adjust the top and bottom edges.</param>
|
||||
public void Inflate(int horizontalAmount, int verticalAmount)
|
||||
{
|
||||
X -= horizontalAmount;
|
||||
Y -= verticalAmount;
|
||||
Width += horizontalAmount * 2;
|
||||
Height += verticalAmount * 2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjusts the edges of this <see cref="Rectangle"/> by specified horizontal and vertical amounts.
|
||||
/// </summary>
|
||||
/// <param name="horizontalAmount">Value to adjust the left and right edges.</param>
|
||||
/// <param name="verticalAmount">Value to adjust the top and bottom edges.</param>
|
||||
public void Inflate(float horizontalAmount, float verticalAmount)
|
||||
{
|
||||
X -= (int)horizontalAmount;
|
||||
Y -= (int)verticalAmount;
|
||||
Width += (int)horizontalAmount * 2;
|
||||
Height += (int)verticalAmount * 2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the other <see cref="Rectangle"/> intersects with this rectangle.
|
||||
/// </summary>
|
||||
/// <param name="value">The other rectangle for testing.</param>
|
||||
/// <returns><c>true</c> if other <see cref="Rectangle"/> intersects with this rectangle; <c>false</c> otherwise.</returns>
|
||||
public bool Intersects(Rectangle value)
|
||||
{
|
||||
return value.Left < Right &&
|
||||
Left < value.Right &&
|
||||
value.Top < Bottom &&
|
||||
Top < value.Bottom;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the other <see cref="Rectangle"/> intersects with this rectangle.
|
||||
/// </summary>
|
||||
/// <param name="value">The other rectangle for testing.</param>
|
||||
/// <param name="result"><c>true</c> if other <see cref="Rectangle"/> intersects with this rectangle; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Intersects(ref Rectangle value, out bool result)
|
||||
{
|
||||
result = value.Left < Right &&
|
||||
Left < value.Right &&
|
||||
value.Top < Bottom &&
|
||||
Top < value.Bottom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle"/> that contains overlapping region of two other rectangles.
|
||||
/// </summary>
|
||||
/// <param name="value1">The first <see cref="Rectangle"/>.</param>
|
||||
/// <param name="value2">The second <see cref="Rectangle"/>.</param>
|
||||
/// <returns>Overlapping region of the two rectangles.</returns>
|
||||
public static Rectangle Intersect(Rectangle value1, Rectangle value2)
|
||||
{
|
||||
Rectangle rectangle;
|
||||
Intersect(ref value1, ref value2, out rectangle);
|
||||
return rectangle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle"/> that contains overlapping region of two other rectangles.
|
||||
/// </summary>
|
||||
/// <param name="value1">The first <see cref="Rectangle"/>.</param>
|
||||
/// <param name="value2">The second <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result">Overlapping region of the two rectangles as an output parameter.</param>
|
||||
public static void Intersect(ref Rectangle value1, ref Rectangle value2, out Rectangle result)
|
||||
{
|
||||
if (value1.Intersects(value2))
|
||||
{
|
||||
int right_side = Math.Min(value1.X + value1.Width, value2.X + value2.Width);
|
||||
int left_side = Math.Max(value1.X, value2.X);
|
||||
int top_side = Math.Max(value1.Y, value2.Y);
|
||||
int bottom_side = Math.Min(value1.Y + value1.Height, value2.Y + value2.Height);
|
||||
result = new Rectangle(left_side, top_side, right_side - left_side, bottom_side - top_side);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new Rectangle(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="offsetX">The x coordinate to add to this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="offsetY">The y coordinate to add to this <see cref="Rectangle"/>.</param>
|
||||
public void Offset(int offsetX, int offsetY)
|
||||
{
|
||||
X += offsetX;
|
||||
Y += offsetY;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="offsetX">The x coordinate to add to this <see cref="Rectangle"/>.</param>
|
||||
/// <param name="offsetY">The y coordinate to add to this <see cref="Rectangle"/>.</param>
|
||||
public void Offset(float offsetX, float offsetY)
|
||||
{
|
||||
X += (int)offsetX;
|
||||
Y += (int)offsetY;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="amount">The x and y components to add to this <see cref="Rectangle"/>.</param>
|
||||
public void Offset(Point amount)
|
||||
{
|
||||
X += amount.X;
|
||||
Y += amount.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Rectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="amount">The x and y components to add to this <see cref="Rectangle"/>.</param>
|
||||
public void Offset(Vector2 amount)
|
||||
{
|
||||
X += (int)amount.X;
|
||||
Y += (int)amount.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="String"/> representation of this <see cref="Rectangle"/> in the format:
|
||||
/// {X:[<see cref="X"/>] Y:[<see cref="Y"/>] Width:[<see cref="Width"/>] Height:[<see cref="Height"/>]}
|
||||
/// </summary>
|
||||
/// <returns><see cref="String"/> representation of this <see cref="Rectangle"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "{X:" + X + " Y:" + Y + " Width:" + Width + " Height:" + Height + "}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle"/> that completely contains two other rectangles.
|
||||
/// </summary>
|
||||
/// <param name="value1">The first <see cref="Rectangle"/>.</param>
|
||||
/// <param name="value2">The second <see cref="Rectangle"/>.</param>
|
||||
/// <returns>The union of the two rectangles.</returns>
|
||||
public static Rectangle Union(Rectangle value1, Rectangle value2)
|
||||
{
|
||||
int x = Math.Min(value1.X, value2.X);
|
||||
int y = Math.Min(value1.Y, value2.Y);
|
||||
return new Rectangle(x, y,
|
||||
Math.Max(value1.Right, value2.Right) - x,
|
||||
Math.Max(value1.Bottom, value2.Bottom) - y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle"/> that completely contains two other rectangles.
|
||||
/// </summary>
|
||||
/// <param name="value1">The first <see cref="Rectangle"/>.</param>
|
||||
/// <param name="value2">The second <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result">The union of the two rectangles as an output parameter.</param>
|
||||
public static void Union(ref Rectangle value1, ref Rectangle value2, out Rectangle result)
|
||||
{
|
||||
result.X = Math.Min(value1.X, value2.X);
|
||||
result.Y = Math.Min(value1.Y, value2.Y);
|
||||
result.Width = Math.Max(value1.Right, value2.Right) - result.X;
|
||||
result.Height = Math.Max(value1.Bottom, value2.Bottom) - result.Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user