Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / 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: [....] 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
- MemoryResponseElement.cs
- OptimisticConcurrencyException.cs
- IntellisenseTextBox.cs
- ParameterCollection.cs
- TextTreeExtractElementUndoUnit.cs
- LogicalTreeHelper.cs
- ReflectEventDescriptor.cs
- WebEventTraceProvider.cs
- Point3DCollection.cs
- XPathNavigator.cs
- GregorianCalendar.cs
- COM2TypeInfoProcessor.cs
- CodeSubDirectory.cs
- UIElementAutomationPeer.cs
- RSAPKCS1SignatureDeformatter.cs
- MsmqAppDomainProtocolHandler.cs
- XPathException.cs
- UIAgentAsyncBeginRequest.cs
- StreamGeometry.cs
- BitArray.cs
- DateTimePicker.cs
- TemplateXamlParser.cs
- DesignerActionKeyboardBehavior.cs
- ConnectionsZone.cs
- MethodBody.cs
- WorkflowMarkupSerializer.cs
- BamlCollectionHolder.cs
- Monitor.cs
- ToggleProviderWrapper.cs
- MulticastDelegate.cs
- DataListItemEventArgs.cs
- RoleGroup.cs
- BitmapImage.cs
- Int16AnimationUsingKeyFrames.cs
- Encoding.cs
- ConfigXmlAttribute.cs
- GridErrorDlg.cs
- Material.cs
- XmlBuffer.cs
- FlowLayoutSettings.cs
- RemoveStoryboard.cs
- WindowsEditBoxRange.cs
- CqlLexer.cs
- SQLString.cs
- HwndMouseInputProvider.cs
- UrlParameterReader.cs
- SynchronizationLockException.cs
- ACE.cs
- NavigationExpr.cs
- DoubleConverter.cs
- SchemaNames.cs
- EdmSchemaError.cs
- Vertex.cs
- ShapeTypeface.cs
- StateFinalizationActivity.cs
- ImageFormat.cs
- VisualStyleRenderer.cs
- CodeParameterDeclarationExpression.cs
- VarRemapper.cs
- Lease.cs
- ButtonColumn.cs
- PropertyMap.cs
- SubtreeProcessor.cs
- WebServiceBindingAttribute.cs
- ComponentDispatcher.cs
- MergeExecutor.cs
- ImageAnimator.cs
- AnnotationObservableCollection.cs
- XpsManager.cs
- HandlerFactoryWrapper.cs
- TableLayoutRowStyleCollection.cs
- DataSourceCacheDurationConverter.cs
- XmlNamedNodeMap.cs
- TcpAppDomainProtocolHandler.cs
- CompositeCollection.cs
- ParserExtension.cs
- TransactionalPackage.cs
- ClientRolePrincipal.cs
- EntryPointNotFoundException.cs
- ObjectIDGenerator.cs
- Script.cs
- LineGeometry.cs
- followingsibling.cs
- Rules.cs
- CapiSafeHandles.cs
- BStrWrapper.cs
- Utils.cs
- Accessible.cs
- CollaborationHelperFunctions.cs
- OdbcErrorCollection.cs
- ToolboxBitmapAttribute.cs
- MouseBinding.cs
- PLINQETWProvider.cs
- CatalogZone.cs
- NumericExpr.cs
- NavigationPropertyEmitter.cs
- NativeCompoundFileAPIs.cs
- CodeVariableDeclarationStatement.cs
- EmptyStringExpandableObjectConverter.cs
- EventBuilder.cs