Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / NumericUpDownAccelerationCollection.cs / 1305376 / NumericUpDownAccelerationCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms
{
using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
///
/// Represents a SORTED collection of NumericUpDownAcceleration objects in the NumericUpDown Control.
/// The elements in the collection are sorted by the NumericUpDownAcceleration.Seconds property.
///
[ListBindable(false)]
public class NumericUpDownAccelerationCollection : MarshalByRefObject, ICollection, IEnumerable
{
List items;
/// ICollection implementation.
///
/// Adds an item (NumericUpDownAcceleration object) to the ICollection.
/// The item is added preserving the collection sorted.
///
public void Add(NumericUpDownAcceleration acceleration)
{
if( acceleration == null )
{
throw new ArgumentNullException("acceleration");
}
// Keep the array sorted, insert in the right spot.
int index = 0;
while( index < this.items.Count )
{
if( acceleration.Seconds < this.items[index].Seconds )
{
break;
}
index++;
}
this.items.Insert(index, acceleration);
}
///
/// Removes all items from the ICollection.
///
public void Clear()
{
this.items.Clear();
}
///
/// Determines whether the IList contains a specific value.
///
public bool Contains(NumericUpDownAcceleration acceleration)
{
return this.items.Contains(acceleration);
}
///
/// Copies the elements of the ICollection to an Array, starting at a particular Array index.
///
public void CopyTo(NumericUpDownAcceleration[] array, int index)
{
this.items.CopyTo(array, index);
}
///
/// Gets the number of elements contained in the ICollection.
///
public int Count
{
get {return this.items.Count;}
}
///
/// Gets a value indicating whether the ICollection is read-only.
/// This collection property returns false always.
///
public bool IsReadOnly
{
get {return false;}
}
///
/// Removes the specified item from the ICollection.
///
public bool Remove(NumericUpDownAcceleration acceleration)
{
return this.items.Remove(acceleration);
}
/// IEnumerable implementation.
///
/// Returns an enumerator that can iterate through the collection.
///
IEnumerator IEnumerable.GetEnumerator()
{
return this.items.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return ((IEnumerable)items).GetEnumerator();
}
/// NumericUpDownAccelerationCollection methods.
///
/// Class constructor.
///
public NumericUpDownAccelerationCollection()
{
this.items = new List();
}
///
/// Adds the elements of specified array to the collection, keeping the collection sorted.
///
public void AddRange(params NumericUpDownAcceleration[] accelerations)
{
if (accelerations == null)
{
throw new ArgumentNullException("accelerations");
}
// Accept the range only if ALL elements in the array are not null.
foreach (NumericUpDownAcceleration acceleration in accelerations)
{
if (acceleration == null)
{
throw new ArgumentNullException(SR.GetString(SR.NumericUpDownAccelerationCollectionAtLeastOneEntryIsNull));
}
}
// 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 (NumericUpDownAcceleration acceleration in accelerations)
{
this.Add(acceleration);
}
}
///
/// Gets (ReadOnly) the element at the specified index. In C#, this property is the indexer for
/// the IList class.
///
public NumericUpDownAcceleration this[int index]
{
get { return this.items[index]; }
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms
{
using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
///
/// Represents a SORTED collection of NumericUpDownAcceleration objects in the NumericUpDown Control.
/// The elements in the collection are sorted by the NumericUpDownAcceleration.Seconds property.
///
[ListBindable(false)]
public class NumericUpDownAccelerationCollection : MarshalByRefObject, ICollection, IEnumerable
{
List items;
/// ICollection implementation.
///
/// Adds an item (NumericUpDownAcceleration object) to the ICollection.
/// The item is added preserving the collection sorted.
///
public void Add(NumericUpDownAcceleration acceleration)
{
if( acceleration == null )
{
throw new ArgumentNullException("acceleration");
}
// Keep the array sorted, insert in the right spot.
int index = 0;
while( index < this.items.Count )
{
if( acceleration.Seconds < this.items[index].Seconds )
{
break;
}
index++;
}
this.items.Insert(index, acceleration);
}
///
/// Removes all items from the ICollection.
///
public void Clear()
{
this.items.Clear();
}
///
/// Determines whether the IList contains a specific value.
///
public bool Contains(NumericUpDownAcceleration acceleration)
{
return this.items.Contains(acceleration);
}
///
/// Copies the elements of the ICollection to an Array, starting at a particular Array index.
///
public void CopyTo(NumericUpDownAcceleration[] array, int index)
{
this.items.CopyTo(array, index);
}
///
/// Gets the number of elements contained in the ICollection.
///
public int Count
{
get {return this.items.Count;}
}
///
/// Gets a value indicating whether the ICollection is read-only.
/// This collection property returns false always.
///
public bool IsReadOnly
{
get {return false;}
}
///
/// Removes the specified item from the ICollection.
///
public bool Remove(NumericUpDownAcceleration acceleration)
{
return this.items.Remove(acceleration);
}
/// IEnumerable implementation.
///
/// Returns an enumerator that can iterate through the collection.
///
IEnumerator IEnumerable.GetEnumerator()
{
return this.items.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return ((IEnumerable)items).GetEnumerator();
}
/// NumericUpDownAccelerationCollection methods.
///
/// Class constructor.
///
public NumericUpDownAccelerationCollection()
{
this.items = new List();
}
///
/// Adds the elements of specified array to the collection, keeping the collection sorted.
///
public void AddRange(params NumericUpDownAcceleration[] accelerations)
{
if (accelerations == null)
{
throw new ArgumentNullException("accelerations");
}
// Accept the range only if ALL elements in the array are not null.
foreach (NumericUpDownAcceleration acceleration in accelerations)
{
if (acceleration == null)
{
throw new ArgumentNullException(SR.GetString(SR.NumericUpDownAccelerationCollectionAtLeastOneEntryIsNull));
}
}
// 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 (NumericUpDownAcceleration acceleration in accelerations)
{
this.Add(acceleration);
}
}
///
/// Gets (ReadOnly) the element at the specified index. In C#, this property is the indexer for
/// the IList class.
///
public NumericUpDownAcceleration this[int index]
{
get { return this.items[index]; }
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PostBackTrigger.cs
- _NetworkingPerfCounters.cs
- BuildProvider.cs
- Error.cs
- MasterPageParser.cs
- Formatter.cs
- CreateInstanceBinder.cs
- InkPresenterAutomationPeer.cs
- CodeBlockBuilder.cs
- FrameworkContextData.cs
- TCPListener.cs
- StrongName.cs
- DataServiceRequest.cs
- ListItem.cs
- MultipleViewPattern.cs
- BitmapEffect.cs
- RequestQueue.cs
- UIElement3D.cs
- BitmapInitialize.cs
- ToolStripContentPanel.cs
- HtmlShimManager.cs
- TableParaClient.cs
- Drawing.cs
- WindowClosedEventArgs.cs
- DBCommand.cs
- InputLangChangeEvent.cs
- RelationshipEndMember.cs
- HtmlInputReset.cs
- ProxyWebPartConnectionCollection.cs
- UnaryNode.cs
- ProfileModule.cs
- ComboBoxItem.cs
- WebConfigurationHostFileChange.cs
- GeneratedContractType.cs
- PanelStyle.cs
- OleDbConnectionInternal.cs
- ApplyImportsAction.cs
- FileFormatException.cs
- RuntimeHandles.cs
- OptimizedTemplateContentHelper.cs
- ExpressionNormalizer.cs
- HebrewNumber.cs
- PathSegment.cs
- SimpleBitVector32.cs
- SqlDataSourceCustomCommandPanel.cs
- TextElement.cs
- AgileSafeNativeMemoryHandle.cs
- IssuedTokenClientBehaviorsElement.cs
- PassportAuthentication.cs
- InstanceNormalEvent.cs
- ServicePointManagerElement.cs
- ListViewInsertionMark.cs
- TextTreeInsertUndoUnit.cs
- RectValueSerializer.cs
- LayoutSettings.cs
- ImageIndexConverter.cs
- DefaultAutoFieldGenerator.cs
- TemplatePartAttribute.cs
- TabRenderer.cs
- ObjectSecurity.cs
- DiscardableAttribute.cs
- CacheOutputQuery.cs
- storepermission.cs
- OdbcConnectionPoolProviderInfo.cs
- ToolConsole.cs
- NetworkAddressChange.cs
- FieldAccessException.cs
- XmlHierarchicalEnumerable.cs
- XmlSchemaAnnotated.cs
- ClaimComparer.cs
- InputScopeAttribute.cs
- GraphicsContainer.cs
- TraceSource.cs
- XpsFontSerializationService.cs
- ListBoxItem.cs
- VariableDesigner.xaml.cs
- PropertyGeneratedEventArgs.cs
- SchemaDeclBase.cs
- thaishape.cs
- RadioButton.cs
- XXXInfos.cs
- UrlMapping.cs
- LabelAutomationPeer.cs
- DecimalAnimation.cs
- Ipv6Element.cs
- CompressStream.cs
- ProcessHostServerConfig.cs
- XappLauncher.cs
- WebPartPersonalization.cs
- SecurityPolicySection.cs
- TextReader.cs
- IdnMapping.cs
- AttributeCallbackBuilder.cs
- CompilerInfo.cs
- DataGridCommandEventArgs.cs
- PageCodeDomTreeGenerator.cs
- ApplicationServiceHelper.cs
- CodeTypeReference.cs
- ServiceNameElementCollection.cs
- Vector3DCollection.cs