Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / WindowCollection.cs / 1305600 / WindowCollection.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // WindowCollection can be used to interate over all the windows // that have been opened in the current application. // // History: // 08/10/04: kusumav Moved out of Application.cs to its own separate file. // //--------------------------------------------------------------------------- using System.Collections; using System.Diagnostics; namespace System.Windows { #region WindowCollection class ////// WindowCollection can be used to interate over all the windows that have been /// opened in the current application. /// // public sealed class WindowCollection : ICollection { //----------------------------------------------------- // // Public Methods // //----------------------------------------------------- #region Public Methods ////// Default Constructor /// public WindowCollection() { _list = new ArrayList(1); } internal WindowCollection(int count) { Debug.Assert(count >= 0, "count must not be less than zero"); _list = new ArrayList(count); } #endregion Public Methods //------------------------------------------------------ // // Operator overload // //----------------------------------------------------- #region Operator overload ////// Overloaded [] operator to access the WindowCollection list /// public Window this[int index] { get { return _list[index] as Window; } } #endregion Operator overload //------------------------------------------------------ // // IEnumerable implementation // //------------------------------------------------------ #region IEnumerable implementation ////// GetEnumerator /// ///public IEnumerator GetEnumerator() { return _list.GetEnumerator(); } #endregion IEnumerable implementation //------------------------------------------------------- // // ICollection implementation (derives from IEnumerable) // //-------------------------------------------------------- #region ICollection implementation /// /// CopyTo /// /// /// void ICollection.CopyTo(Array array, int index) { _list.CopyTo(array, index); } ////// CopyTo /// /// /// public void CopyTo(Window[] array, int index) { _list.CopyTo(array, index); } ////// Count property /// public int Count { get { return _list.Count; } } ////// IsSynchronized /// public bool IsSynchronized { get { return _list.IsSynchronized; } } ////// SyncRoot /// public Object SyncRoot { get { return _list.SyncRoot; } } #endregion ICollection implementation //----------------------------------------------------- // // Internal Methods // //----------------------------------------------------- #region Internal Methods internal WindowCollection Clone() { WindowCollection clone; lock (_list.SyncRoot) { clone = new WindowCollection(_list.Count); for (int i = 0; i < _list.Count; i++) { clone._list.Add(_list[i]); } } return clone; } internal void Remove(Window win) { lock (_list.SyncRoot) { _list.Remove(win); } } internal void RemoveAt(int index) { lock (_list.SyncRoot) { _list.Remove(index); } } internal int Add (Window win) { lock (_list.SyncRoot) { return _list.Add(win); } } internal bool HasItem(Window win) { lock (_list.SyncRoot) { for (int i = 0; i < _list.Count; i++) { if (_list[i] == win) { return true; } } } return false; } #endregion Internal Methods //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #region Private Fields private ArrayList _list; #endregion Private Fields } #endregion WindowCollection class } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // WindowCollection can be used to interate over all the windows // that have been opened in the current application. // // History: // 08/10/04: kusumav Moved out of Application.cs to its own separate file. // //--------------------------------------------------------------------------- using System.Collections; using System.Diagnostics; namespace System.Windows { #region WindowCollection class ////// WindowCollection can be used to interate over all the windows that have been /// opened in the current application. /// // public sealed class WindowCollection : ICollection { //----------------------------------------------------- // // Public Methods // //----------------------------------------------------- #region Public Methods ////// Default Constructor /// public WindowCollection() { _list = new ArrayList(1); } internal WindowCollection(int count) { Debug.Assert(count >= 0, "count must not be less than zero"); _list = new ArrayList(count); } #endregion Public Methods //------------------------------------------------------ // // Operator overload // //----------------------------------------------------- #region Operator overload ////// Overloaded [] operator to access the WindowCollection list /// public Window this[int index] { get { return _list[index] as Window; } } #endregion Operator overload //------------------------------------------------------ // // IEnumerable implementation // //------------------------------------------------------ #region IEnumerable implementation ////// GetEnumerator /// ///public IEnumerator GetEnumerator() { return _list.GetEnumerator(); } #endregion IEnumerable implementation //------------------------------------------------------- // // ICollection implementation (derives from IEnumerable) // //-------------------------------------------------------- #region ICollection implementation /// /// CopyTo /// /// /// void ICollection.CopyTo(Array array, int index) { _list.CopyTo(array, index); } ////// CopyTo /// /// /// public void CopyTo(Window[] array, int index) { _list.CopyTo(array, index); } ////// Count property /// public int Count { get { return _list.Count; } } ////// IsSynchronized /// public bool IsSynchronized { get { return _list.IsSynchronized; } } ////// SyncRoot /// public Object SyncRoot { get { return _list.SyncRoot; } } #endregion ICollection implementation //----------------------------------------------------- // // Internal Methods // //----------------------------------------------------- #region Internal Methods internal WindowCollection Clone() { WindowCollection clone; lock (_list.SyncRoot) { clone = new WindowCollection(_list.Count); for (int i = 0; i < _list.Count; i++) { clone._list.Add(_list[i]); } } return clone; } internal void Remove(Window win) { lock (_list.SyncRoot) { _list.Remove(win); } } internal void RemoveAt(int index) { lock (_list.SyncRoot) { _list.Remove(index); } } internal int Add (Window win) { lock (_list.SyncRoot) { return _list.Add(win); } } internal bool HasItem(Window win) { lock (_list.SyncRoot) { for (int i = 0; i < _list.Count; i++) { if (_list[i] == win) { return true; } } } return false; } #endregion Internal Methods //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #region Private Fields private ArrayList _list; #endregion Private Fields } #endregion WindowCollection class } // 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
- ConfigXmlSignificantWhitespace.cs
- RegistryExceptionHelper.cs
- RefreshPropertiesAttribute.cs
- ResizeGrip.cs
- PasswordRecoveryAutoFormat.cs
- OwnerDrawPropertyBag.cs
- XmlBinaryReader.cs
- HexParser.cs
- MenuItem.cs
- GacUtil.cs
- AutoGeneratedField.cs
- ExpandSegmentCollection.cs
- DataExpression.cs
- TokenBasedSet.cs
- Identity.cs
- AnimationClockResource.cs
- QuaternionAnimationBase.cs
- DataGridComboBoxColumn.cs
- DocumentViewer.cs
- SoapDocumentMethodAttribute.cs
- DataSourceHelper.cs
- BamlTreeUpdater.cs
- BindToObject.cs
- LineProperties.cs
- XPathEmptyIterator.cs
- PrintPreviewDialog.cs
- XPathDocument.cs
- ExtensionQuery.cs
- PageRanges.cs
- DesignBindingValueUIHandler.cs
- RelatedView.cs
- StaticContext.cs
- ManipulationVelocities.cs
- MobileListItemCollection.cs
- SqlTriggerAttribute.cs
- MarkupCompiler.cs
- ProfilePropertySettingsCollection.cs
- ConnectionPointCookie.cs
- SelfIssuedAuthAsymmetricKey.cs
- DiscreteKeyFrames.cs
- RMEnrollmentPage2.cs
- ZoneIdentityPermission.cs
- WeakEventManager.cs
- CommentEmitter.cs
- COM2PropertyDescriptor.cs
- OleDbCommand.cs
- UnsafeNativeMethods.cs
- NameTable.cs
- XpsFixedDocumentReaderWriter.cs
- Rethrow.cs
- XamlPathDataSerializer.cs
- DecimalMinMaxAggregationOperator.cs
- ProtocolException.cs
- InputBindingCollection.cs
- EntityDataSourceChangingEventArgs.cs
- CollectionChangeEventArgs.cs
- DeviceContext.cs
- ValidationException.cs
- KnowledgeBase.cs
- MemoryFailPoint.cs
- ImageClickEventArgs.cs
- ReadOnlyDataSource.cs
- LayoutEditorPart.cs
- OracleInfoMessageEventArgs.cs
- GC.cs
- XmlSerializerAssemblyAttribute.cs
- WebPartMenuStyle.cs
- AppSecurityManager.cs
- MouseDevice.cs
- X509Chain.cs
- _CommandStream.cs
- CatalogPartCollection.cs
- SourceItem.cs
- TemplateParser.cs
- Button.cs
- ReplacementText.cs
- PieceNameHelper.cs
- CompareInfo.cs
- __Filters.cs
- TypeConstant.cs
- PseudoWebRequest.cs
- SessionEndingEventArgs.cs
- Geometry3D.cs
- SiteMapNodeItem.cs
- SimpleParser.cs
- ClientScriptManagerWrapper.cs
- RenderOptions.cs
- PartialCachingControl.cs
- WebPartEventArgs.cs
- LabelLiteral.cs
- StreamGeometryContext.cs
- ContentValidator.cs
- DecoderBestFitFallback.cs
- ClonableStack.cs
- NonSerializedAttribute.cs
- TransactionScope.cs
- LogReservationCollection.cs
- NullReferenceException.cs
- DataPagerFieldCollection.cs
- _SecureChannel.cs