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
- RuntimeEnvironment.cs
- WindowsPen.cs
- SafeNativeMethods.cs
- ParallelTimeline.cs
- SecureEnvironment.cs
- OutputCacheSettingsSection.cs
- WeakReadOnlyCollection.cs
- MemoryResponseElement.cs
- OutputScopeManager.cs
- SqlPersonalizationProvider.cs
- CheckPair.cs
- RootBuilder.cs
- TimerElapsedEvenArgs.cs
- TemplateControl.cs
- ObjectSecurityT.cs
- ModulesEntry.cs
- HttpTransportElement.cs
- ByteRangeDownloader.cs
- InputLanguageProfileNotifySink.cs
- BitmapEffect.cs
- InfiniteIntConverter.cs
- RectConverter.cs
- WebProxyScriptElement.cs
- DiscoveryDefaults.cs
- SystemIPv6InterfaceProperties.cs
- SingleObjectCollection.cs
- DynamicUpdateCommand.cs
- ToolboxDataAttribute.cs
- Positioning.cs
- BuildProvidersCompiler.cs
- HashMembershipCondition.cs
- _OSSOCK.cs
- View.cs
- InvariantComparer.cs
- DesignerForm.cs
- DuplicateWaitObjectException.cs
- QilStrConcatenator.cs
- InputBinding.cs
- DrawingImage.cs
- RtfToXamlReader.cs
- AsyncPostBackTrigger.cs
- DataFormat.cs
- DateTimeFormatInfo.cs
- ButtonBaseAdapter.cs
- CellPartitioner.cs
- Propagator.Evaluator.cs
- SyntaxCheck.cs
- Aggregates.cs
- StrongNamePublicKeyBlob.cs
- ListSourceHelper.cs
- TextStore.cs
- ClientConfigurationHost.cs
- NamespaceCollection.cs
- ContentPresenter.cs
- ModuleBuilder.cs
- FileStream.cs
- WindowHideOrCloseTracker.cs
- TimerEventSubscription.cs
- SqlDataSource.cs
- HttpListenerRequest.cs
- CodeDomLoader.cs
- FormatConvertedBitmap.cs
- UserPersonalizationStateInfo.cs
- EllipseGeometry.cs
- RowBinding.cs
- Stacktrace.cs
- BitmapEffectInput.cs
- BamlTreeUpdater.cs
- GreenMethods.cs
- AppDomainCompilerProxy.cs
- DataBindingValueUIHandler.cs
- SemanticBasicElement.cs
- SoapHeaders.cs
- PointValueSerializer.cs
- PropagationProtocolsTracing.cs
- ChildDocumentBlock.cs
- ChangePassword.cs
- DeflateStreamAsyncResult.cs
- UnsafeMethods.cs
- StateRuntime.cs
- TextServicesContext.cs
- ToolStripComboBox.cs
- DiscoveryClientReferences.cs
- PrivacyNoticeBindingElement.cs
- PerformanceCounterManager.cs
- WebConfigurationFileMap.cs
- TdsRecordBufferSetter.cs
- StrokeDescriptor.cs
- PerformanceCounterLib.cs
- DirectoryRootQuery.cs
- CaseStatementSlot.cs
- ClientSettings.cs
- SerialPinChanges.cs
- DataProtection.cs
- EventRecordWrittenEventArgs.cs
- PerspectiveCamera.cs
- ConditionCollection.cs
- StringUtil.cs
- IndicShape.cs
- SchemaImporterExtensionElement.cs