Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / Host / DesignSurfaceCollection.cs / 1 / DesignSurfaceCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.ComponentModel.Design {
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Design;
using System.Diagnostics;
///
///
/// Provides a read-only collection of design surfaces.
///
public sealed class DesignSurfaceCollection : ICollection {
private DesignerCollection _designers;
///
/// Initializes a new instance of the DesignSurfaceCollection class
///
internal DesignSurfaceCollection(DesignerCollection designers) {
_designers = designers;
if (_designers == null) {
_designers = new DesignerCollection(null);
}
}
///
///
/// Gets number of design surfaces in the collection.
///
public int Count {
get {
return _designers.Count;
}
}
///
///
/// Gets or sets the document at the specified index.
///
public DesignSurface this[int index] {
get {
IDesignerHost host = _designers[index];
DesignSurface surface = host.GetService(typeof(DesignSurface)) as DesignSurface;
if (surface == null) {
throw new NotSupportedException();
}
return surface;
}
}
///
///
/// Creates and retrieves a new enumerator for this collection.
///
public IEnumerator GetEnumerator() {
return new DesignSurfaceEnumerator(_designers.GetEnumerator());
}
///
///
int ICollection.Count {
get {
return Count;
}
}
///
///
bool ICollection.IsSynchronized {
get {
return false;
}
}
///
///
object ICollection.SyncRoot {
get {
return null;
}
}
///
///
void ICollection.CopyTo(Array array, int index) {
foreach(DesignSurface surface in this) {
array.SetValue(surface, index++);
}
}
public void CopyTo(DesignSurface[] array, int index) {
((ICollection)this).CopyTo(array, index);
}
///
///
IEnumerator IEnumerable.GetEnumerator() {
return GetEnumerator();
}
///
/// Enumerator that performs the conversion from designer host
/// to design surface.
///
private class DesignSurfaceEnumerator : IEnumerator {
private IEnumerator _designerEnumerator;
internal DesignSurfaceEnumerator(IEnumerator designerEnumerator) {
_designerEnumerator = designerEnumerator;
}
public object Current {
get {
IDesignerHost host = (IDesignerHost)_designerEnumerator.Current;
DesignSurface surface = host.GetService(typeof(DesignSurface)) as DesignSurface;
if (surface == null) {
throw new NotSupportedException();
}
return surface;
}
}
public bool MoveNext() {
return _designerEnumerator.MoveNext();
}
public void Reset() {
_designerEnumerator.Reset();
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FusionWrap.cs
- SmtpException.cs
- ListViewTableCell.cs
- TextEditorCharacters.cs
- SpanIndex.cs
- IIS7UserPrincipal.cs
- ListViewAutomationPeer.cs
- FixedPosition.cs
- WebControlAdapter.cs
- ScriptBehaviorDescriptor.cs
- TextDecoration.cs
- StatusBarAutomationPeer.cs
- ElapsedEventArgs.cs
- ComponentRenameEvent.cs
- InternalCache.cs
- ConfigurationSettings.cs
- Qualifier.cs
- TextComposition.cs
- counter.cs
- UrlMappingsSection.cs
- MergeFilterQuery.cs
- XmlRawWriter.cs
- QuotedPrintableStream.cs
- Image.cs
- ObjectStateEntryDbDataRecord.cs
- TdsRecordBufferSetter.cs
- DispatcherHooks.cs
- LOSFormatter.cs
- _AutoWebProxyScriptEngine.cs
- BooleanFunctions.cs
- DataRecordInternal.cs
- CollectionEditor.cs
- RightsManagementEncryptedStream.cs
- QuaternionConverter.cs
- ExpressionList.cs
- XmlSerializationReader.cs
- Matrix.cs
- Latin1Encoding.cs
- MultiPageTextView.cs
- VirtualPathData.cs
- HandlerBase.cs
- rsa.cs
- SettingsSection.cs
- Point4D.cs
- CommunicationException.cs
- SchemaNotation.cs
- Rules.cs
- HtmlSelectionListAdapter.cs
- MouseActionValueSerializer.cs
- DateBoldEvent.cs
- CollectionBuilder.cs
- Automation.cs
- InputScopeAttribute.cs
- TraceHwndHost.cs
- Size.cs
- StoryFragments.cs
- TimeSpanConverter.cs
- path.cs
- EditBehavior.cs
- BatchStream.cs
- EntryPointNotFoundException.cs
- DoubleCollectionValueSerializer.cs
- ToolStripSettings.cs
- DescendantOverDescendantQuery.cs
- XmlSerializerVersionAttribute.cs
- CollectionConverter.cs
- DataFormat.cs
- TypedColumnHandler.cs
- UpdatePanelControlTrigger.cs
- CapiSafeHandles.cs
- SystemFonts.cs
- TextPatternIdentifiers.cs
- CommandManager.cs
- AsymmetricSignatureDeformatter.cs
- DbSourceCommand.cs
- ComponentResourceKeyConverter.cs
- WindowsRebar.cs
- SqlMethodAttribute.cs
- Registry.cs
- PropertyGridEditorPart.cs
- DocumentPage.cs
- DebugHandleTracker.cs
- ContextItemManager.cs
- CompositeControl.cs
- ScopelessEnumAttribute.cs
- QueryException.cs
- Token.cs
- WinFormsSpinner.cs
- CharKeyFrameCollection.cs
- ReadOnlyAttribute.cs
- BaseDataList.cs
- ResourceProviderFactory.cs
- TargetInvocationException.cs
- StrongTypingException.cs
- TypeCollectionPropertyEditor.cs
- Calendar.cs
- CannotUnloadAppDomainException.cs
- XamlSerializer.cs
- WinEventWrap.cs
- XmlMemberMapping.cs