Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

Commit

Permalink
Moving the goalposts!
Browse files Browse the repository at this point in the history
  • Loading branch information
flibitijibibo committed Mar 26, 2014
1 parent 09c633d commit 3ecd0ad
Show file tree
Hide file tree
Showing 8 changed files with 484 additions and 426 deletions.
40 changes: 18 additions & 22 deletions MonoGame.Framework/Input/Touch/GestureSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#endregion

#region Using Statements
using Microsoft.Xna.Framework;
using System;
#endregion

Expand All @@ -29,7 +28,7 @@ public GestureType GestureType
{
get
{
return this._gestureType;
return gestureType;
}
}

Expand All @@ -40,7 +39,7 @@ public TimeSpan Timestamp
{
get
{
return this._timestamp;
return timestamp;
}
}

Expand All @@ -51,7 +50,7 @@ public Vector2 Position
{
get
{
return this._position;
return position;
}
}

Expand All @@ -62,7 +61,7 @@ public Vector2 Position2
{
get
{
return this._position2;
return position2;
}
}

Expand All @@ -73,7 +72,7 @@ public Vector2 Delta
{
get
{
return this._delta;
return delta;
}
}

Expand All @@ -84,21 +83,20 @@ public Vector2 Delta2
{
get
{
return this._delta2;
return delta2;
}
}

#endregion

#region Private Variables

// Attributes
private GestureType _gestureType;
private TimeSpan _timestamp;
private Vector2 _position;
private Vector2 _position2;
private Vector2 _delta;
private Vector2 _delta2;
private GestureType gestureType;
private TimeSpan timestamp;
private Vector2 position;
private Vector2 position2;
private Vector2 delta;
private Vector2 delta2;

#endregion

Expand All @@ -121,16 +119,14 @@ public Vector2 Delta2
Vector2 delta,
Vector2 delta2
) {
this._gestureType = gestureType;
this._timestamp = timestamp;
this._position = position;
this._position2 = position2;
this._delta = delta;
this._delta2 = delta2;
this.gestureType = gestureType;
this.timestamp = timestamp;
this.position = position;
this.position2 = position2;
this.delta = delta;
this.delta2 = delta2;
}

#endregion

}
}

3 changes: 2 additions & 1 deletion MonoGame.Framework/Input/Touch/GestureType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
*/
#endregion

#region Using Statements
using System;
#endregion

namespace Microsoft.Xna.Framework.Input.Touch
{
Expand Down Expand Up @@ -89,4 +91,3 @@ public enum GestureType
VerticalDrag = 512,
}
}

63 changes: 33 additions & 30 deletions MonoGame.Framework/Input/Touch/TouchCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
*/
#endregion

#region Using clause
#region Using Statements
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
#endregion Using clause
#endregion

namespace Microsoft.Xna.Framework.Input.Touch
{
Expand All @@ -22,12 +21,6 @@ namespace Microsoft.Xna.Framework.Input.Touch
/// </summary>
public struct TouchCollection : IList<TouchLocation>
{
private TouchLocation[] _collection;

private bool _isConnected;

private static readonly TouchLocation[] emptyCollection = new TouchLocation[0];

#region Public Properties

/// <summary>
Expand All @@ -37,7 +30,7 @@ public bool IsConnected
{
get
{
return _isConnected;
return isConnected;
}
}

Expand All @@ -64,11 +57,11 @@ public int Count
{
get
{
if (_collection == null)
if (collection == null)
{
return 0;
}
return _collection.Length;
return collection.Length;
}
}

Expand All @@ -81,11 +74,11 @@ public int Count
{
get
{
if (_collection == null)
if (collection == null)
{
throw new ArgumentOutOfRangeException("index");
}
return _collection[index];
return collection[index];
}
set
{
Expand All @@ -95,6 +88,16 @@ public int Count

#endregion

#region Private Variables

private TouchLocation[] collection;

private bool isConnected;

private static readonly TouchLocation[] emptyCollection = new TouchLocation[0];

#endregion

#region Public Constructor

/// <summary>
Expand All @@ -106,8 +109,8 @@ public int Count
/// </param>
public TouchCollection(TouchLocation[] touches)
{
_isConnected = true;
_collection = touches;
isConnected = true;
collection = touches;
}

#endregion
Expand All @@ -122,12 +125,12 @@ public TouchCollection(TouchLocation[] touches)
/// <returns></returns>
public bool FindById(int id, out TouchLocation touchLocation)
{
if (_collection == null)
if (collection == null)
{
touchLocation = default(TouchLocation);
return false;
}
foreach (TouchLocation location in _collection)
foreach (TouchLocation location in collection)
{
if (location.Id == id)
{
Expand All @@ -152,13 +155,13 @@ public bool FindById(int id, out TouchLocation touchLocation)
/// <returns></returns>
public int IndexOf(TouchLocation item)
{
if (_collection == null)
if (collection == null)
{
return -1;
}
for (int i = 0; i < _collection.Length; i += 1)
for (int i = 0; i < collection.Length; i += 1)
{
if (item == _collection[i])
if (item == collection[i])
{
return i;
}
Expand Down Expand Up @@ -211,11 +214,11 @@ public void Clear()
/// <returns>Returns true if queried item is found, false otherwise.</returns>
public bool Contains(TouchLocation item)
{
if (_collection == null)
if (collection == null)
{
return false;
}
foreach(TouchLocation location in _collection)
foreach(TouchLocation location in collection)
{
if (item == location)
{
Expand All @@ -234,9 +237,9 @@ public bool Contains(TouchLocation item)
/// <param name="arrayIndex">The starting index of the copy operation.</param>
public void CopyTo(TouchLocation[] array, int arrayIndex)
{
if (_collection != null)
if (collection != null)
{
_collection.CopyTo(array, arrayIndex);
collection.CopyTo(array, arrayIndex);
}
}

Expand All @@ -256,12 +259,12 @@ public bool Remove(TouchLocation item)
/// <returns>Enumerable list of <see cref="TouchLocation"/> objects.</returns>
public IEnumerator<TouchLocation> GetEnumerator()
{
if (_collection == null)
if (collection == null)
{
return emptyCollection.AsEnumerable().GetEnumerator();
}

return _collection.AsEnumerable().GetEnumerator();
return collection.AsEnumerable().GetEnumerator();
}


Expand All @@ -271,14 +274,14 @@ public IEnumerator<TouchLocation> GetEnumerator()
/// <returns>Enumerable list of objects.</returns>
IEnumerator IEnumerable.GetEnumerator()
{
if (_collection == null)
if (collection == null)
{
return emptyCollection.GetEnumerator();
}

return _collection.GetEnumerator();
return collection.GetEnumerator();
}

#endregion
}
}
}
Loading

0 comments on commit 3ecd0ad

Please sign in to comment.