-
-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pavel Kovalenko
committed
Oct 18, 2014
1 parent
88d7797
commit bc0bd11
Showing
9 changed files
with
995 additions
and
5 deletions.
There are no files selected for viewing
733 changes: 733 additions & 0 deletions
733
src/editors/xrSdkControls/Controls/IntegerUpDown/IntegerUpDown.cs
Large diffs are not rendered by default.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
src/editors/xrSdkControls/Controls/IntegerUpDown/IntegerUpDownAcceleration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Windows.Forms; | ||
|
||
namespace XRay.SdkControls | ||
{ | ||
/// <summary> | ||
/// Comprises the information specifying how acceleration should be performed | ||
/// on a Windows up-down control when the up/down button is pressed for certain | ||
/// amount of time. | ||
/// </summary> | ||
public class IntegerUpDownAcceleration | ||
{ | ||
private Int32 seconds; // Ideally we would use UInt32 but it is not CLS-compliant. | ||
private Int32 increment; // Ideally we would use UInt32 but it is not CLS-compliant. | ||
|
||
public IntegerUpDownAcceleration(Int32 seconds, Int32 increment) | ||
{ | ||
if (seconds < 0) | ||
{ | ||
throw new ArgumentOutOfRangeException("seconds < 0"); | ||
} | ||
|
||
if (increment < 0) | ||
{ | ||
throw new ArgumentOutOfRangeException("increment < 0"); | ||
} | ||
|
||
this.seconds = seconds; | ||
this.increment = increment; | ||
} | ||
|
||
/// <summary> | ||
/// Determines the amount of time for the UpDown control to wait to set the increment | ||
/// step when holding the up/down button. | ||
/// </summary> | ||
public Int32 Seconds | ||
{ | ||
get | ||
{ | ||
return seconds; | ||
} | ||
set | ||
{ | ||
if (value < 0) | ||
{ | ||
throw new ArgumentOutOfRangeException("seconds < 0"); | ||
} | ||
seconds = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Determines the amount to increment by. | ||
/// </summary> | ||
public Int32 Increment | ||
{ | ||
get | ||
{ | ||
return increment; | ||
} | ||
set | ||
{ | ||
if (value < 0) | ||
{ | ||
throw new ArgumentOutOfRangeException("increment < 0"); | ||
} | ||
increment = value; | ||
} | ||
} | ||
} | ||
} |
180 changes: 180 additions & 0 deletions
180
src/editors/xrSdkControls/Controls/IntegerUpDown/IntegerUpDownAccelerationCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Windows.Forms; | ||
|
||
namespace XRay.SdkControls | ||
{ | ||
/// <summary> | ||
/// Represents a SORTED collection of IntegerUpDownAcceleration objects in the NumericUpDown Control. | ||
/// The elements in the collection are sorted by the IntegerUpDownAcceleration.Seconds property. | ||
/// </summary> | ||
[ListBindable(false)] | ||
public class IntegerUpDownAccelerationCollection : | ||
MarshalByRefObject, | ||
ICollection<IntegerUpDownAcceleration>, | ||
IEnumerable<IntegerUpDownAcceleration> | ||
{ | ||
private List<IntegerUpDownAcceleration> items; | ||
|
||
/// <summary> | ||
/// Class constructor. | ||
/// </summary> | ||
public IntegerUpDownAccelerationCollection() | ||
{ | ||
items = new List<IntegerUpDownAcceleration>(); | ||
} | ||
|
||
/// <summary> | ||
/// Gets (ReadOnly) the element at the specified index. In C#, this property is the indexer for | ||
/// the IList class. | ||
/// </summary> | ||
/// <param name="index"></param> | ||
/// <returns></returns> | ||
public IntegerUpDownAcceleration this[int index] | ||
{ | ||
get | ||
{ | ||
return items[index]; | ||
} | ||
} | ||
|
||
// ICollection<IntegerUpDownAcceleration> implementation. | ||
|
||
/// <summary> | ||
/// Adds an item (IntegerUpDownAcceleration object) to the ICollection. | ||
/// The item is added preserving the collection sorted. | ||
/// </summary> | ||
/// <param name="acceleration"></param> | ||
public void Add(IntegerUpDownAcceleration acceleration) | ||
{ | ||
if (acceleration == null) | ||
{ | ||
throw new ArgumentNullException("acceleration"); | ||
} | ||
|
||
// Keep the array sorted, insert in the right spot. | ||
var index = 0; | ||
|
||
while (index < items.Count) | ||
{ | ||
if (acceleration.Seconds < items[index].Seconds) | ||
{ | ||
break; | ||
} | ||
++index; | ||
} | ||
items.Insert(index, acceleration); | ||
} | ||
|
||
/// <summary> | ||
/// Removes all items from the ICollection. | ||
/// </summary> | ||
public void Clear() | ||
{ | ||
items.Clear(); | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether the IList contains a specific value. | ||
/// </summary> | ||
/// <param name="acceleration"></param> | ||
/// <returns></returns> | ||
public bool Contains(IntegerUpDownAcceleration acceleration) | ||
{ | ||
return items.Contains(acceleration); | ||
} | ||
|
||
/// <summary> | ||
/// Copies the elements of the ICollection to an Array, starting at a particular Array index. | ||
/// </summary> | ||
/// <param name="array"></param> | ||
/// <param name="index"></param> | ||
public void CopyTo(IntegerUpDownAcceleration[] array, int index) | ||
{ | ||
items.CopyTo(array, index); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the number of elements contained in the ICollection. | ||
/// </summary> | ||
public int Count | ||
{ | ||
get | ||
{ | ||
return items.Count; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets a value indicating whether the ICollection is read-only. | ||
/// This collection property returns false always. | ||
/// </summary> | ||
public bool IsReadOnly | ||
{ | ||
get | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Removes the specified item from the ICollection. | ||
/// </summary> | ||
/// <param name="acceleration"></param> | ||
/// <returns></returns> | ||
public bool Remove(IntegerUpDownAcceleration acceleration) | ||
{ | ||
return items.Remove(acceleration); | ||
} | ||
|
||
// IEnumerable<IntegerUpDownAcceleration> implementation. | ||
|
||
|
||
/// <summary> | ||
/// Returns an enumerator that can iterate through the collection. | ||
/// </summary> | ||
/// <returns></returns> | ||
IEnumerator<IntegerUpDownAcceleration> IEnumerable<IntegerUpDownAcceleration>.GetEnumerator() | ||
{ | ||
return items.GetEnumerator(); | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() | ||
{ | ||
return ((IEnumerable)items).GetEnumerator(); | ||
} | ||
|
||
// IntegerUpDownAccelerationCollection methods. | ||
|
||
/// <summary> | ||
/// Adds the elements of specified array to the collection, keeping the collection sorted. | ||
/// </summary> | ||
/// <param name="accelerations"></param> | ||
public void AddRange(params IntegerUpDownAcceleration[] accelerations) | ||
{ | ||
if (accelerations == null) | ||
{ | ||
throw new ArgumentNullException("accelerations"); | ||
} | ||
|
||
// Accept the range only if ALL elements in the array are not null. | ||
foreach (var acceleration in accelerations) | ||
{ | ||
if (acceleration == null) | ||
{ | ||
throw new ArgumentNullException("At least oe entry is null"); | ||
} | ||
} | ||
|
||
// The expected array size is typically small (5 items?), so we don't need to try to be smarter about the | ||
// way we add the elements to the collection, just call Add. | ||
foreach (var acceleration in accelerations) | ||
{ | ||
Add(acceleration); | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters