Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / WindowCollection.cs / 1 / 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
- PrimitiveType.cs
- DesignerActionGlyph.cs
- ToolStripControlHost.cs
- WebPartActionVerb.cs
- ConfigurationException.cs
- ReadOnlyCollection.cs
- AppDomainAttributes.cs
- OuterProxyWrapper.cs
- MenuItemStyle.cs
- ExtenderControl.cs
- TextTrailingCharacterEllipsis.cs
- XmlFormatExtensionPrefixAttribute.cs
- ImageKeyConverter.cs
- PkcsMisc.cs
- SizeAnimationClockResource.cs
- CatalogZone.cs
- ResourcesBuildProvider.cs
- DataGridViewCellMouseEventArgs.cs
- Emitter.cs
- ConsumerConnectionPoint.cs
- _Semaphore.cs
- DoubleCollectionValueSerializer.cs
- StorageBasedPackageProperties.cs
- HTMLTextWriter.cs
- PasswordBox.cs
- AsyncOperation.cs
- HtmlForm.cs
- MergePropertyDescriptor.cs
- DispatcherProcessingDisabled.cs
- TextLineResult.cs
- TableRow.cs
- _KerberosClient.cs
- ColorKeyFrameCollection.cs
- FixedDSBuilder.cs
- clipboard.cs
- TypeLoadException.cs
- AssociativeAggregationOperator.cs
- LassoSelectionBehavior.cs
- SqlTypesSchemaImporter.cs
- CompilerGeneratedAttribute.cs
- RegexGroup.cs
- DictionaryGlobals.cs
- XmlSchemaSimpleTypeList.cs
- __Error.cs
- DataServiceQuery.cs
- _HTTPDateParse.cs
- ErrorsHelper.cs
- DataServiceKeyAttribute.cs
- ManagementOperationWatcher.cs
- LockRenewalTask.cs
- XmlKeywords.cs
- GenericXmlSecurityToken.cs
- XmlUrlResolver.cs
- QuaternionAnimationBase.cs
- RangeBaseAutomationPeer.cs
- WebBrowserProgressChangedEventHandler.cs
- MetricEntry.cs
- MediaTimeline.cs
- WebServiceTypeData.cs
- Listen.cs
- DataGridColumnEventArgs.cs
- ImageSourceValueSerializer.cs
- BamlRecordHelper.cs
- QilScopedVisitor.cs
- WorkflowPersistenceService.cs
- FixedSOMPageElement.cs
- Types.cs
- Int32.cs
- GenericTextProperties.cs
- XhtmlBasicTextBoxAdapter.cs
- XsltLoader.cs
- SpeechRecognitionEngine.cs
- XmlC14NWriter.cs
- TypeKeyValue.cs
- VirtualDirectoryMappingCollection.cs
- IHttpResponseInternal.cs
- SkipStoryboardToFill.cs
- XmlParserContext.cs
- Queue.cs
- Size.cs
- RadioButton.cs
- EventHandlers.cs
- ExpressionsCollectionEditor.cs
- DefaultBindingPropertyAttribute.cs
- ForEachDesigner.xaml.cs
- FileDataSourceCache.cs
- Models.cs
- FastPropertyAccessor.cs
- LabelEditEvent.cs
- BlockUIContainer.cs
- FontStyleConverter.cs
- DecimalKeyFrameCollection.cs
- DataGridViewHeaderCell.cs
- NativeMethods.cs
- PixelFormats.cs
- ISO2022Encoding.cs
- ComponentResourceKeyConverter.cs
- ApplicationId.cs
- RadioButtonList.cs
- BulletedListEventArgs.cs