Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / MS / Internal / Annotations / AnnotationResourceCollection.cs / 1 / AnnotationResourceCollection.cs
//---------------------------------------------------------------------------- // //// Copyright (C) 2003 by Microsoft Corporation. All rights reserved. // // // Description: Subclass of AnnotationObservableCollectionwhich has slightly different // eventing behavior for ClearItems and SetItem methods. This class // is used specifically for AnnotationResources. // // History: // 03/10/2005 : [....] - created // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; using System.Windows.Annotations; using System.Windows.Data; namespace MS.Internal.Annotations { /// /// Subclass of AnnotationObservableCollection which has slightly different /// eventing behavior for ClearItems and SetItem methods. This class /// is used specifically for AnnotationResources. /// internal sealed class AnnotationResourceCollection : AnnotationObservableCollection{ //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors /// /// Initializes a new instance of AnnotationResourceCollection that is empty and has default initial capacity. /// public AnnotationResourceCollection() : base() { } #endregion Constructors //------------------------------------------------------ // // Public Events // //----------------------------------------------------- #region Public Events ////// Event fired when an item in the collection changes (fires a PropertyChanged event). /// public event PropertyChangedEventHandler ItemChanged; #endregion Public Events //------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ #region Protected Methods ////// Override this method and provide a different set of events /// when items are cleared from the collection. Specifically, /// fire a Remove event for each item in the collection. /// protected override void ProtectedClearItems() { // We want to fire for each item in the list Listlist = new List (this); Items.Clear(); // directly clear Collection inner Items collection OnPropertyChanged(CountString); OnPropertyChanged(IndexerName); OnCollectionCleared(list); } /// /// Override this method and provide a different set of events /// when an item is set on a given index in this collection. /// Specifically, fire a both a Remove and Add event (as the /// grand-parent class ObservableCollection does). /// /// index of item to set /// item to set at that index protected override void ProtectedSetItem(int index, AnnotationResource item) { // Use the standard built in events (one for item removed and one for item added) ObservableCollectionSetItem(index, item); // Calls raw ObservableCollection method } #endregion Protected Methods //----------------------------------------------------- // // Private Methods // //------------------------------------------------------ #region Private Methods // fire an event for each item removed from the collection void OnCollectionCleared(IEnumerablelist) { foreach(object item in list) { OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, 0)); } } private void OnPropertyChanged(string propertyName) { OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); } // raise CollectionChanged event to any listeners protected override void OnItemPropertyChanged(object sender, PropertyChangedEventArgs e) { if (ItemChanged != null) { ItemChanged(sender, e); } } #endregion Private Methods } } // 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
- TextContainer.cs
- OSFeature.cs
- WmfPlaceableFileHeader.cs
- ValidationSummaryDesigner.cs
- XmlToDatasetMap.cs
- SymmetricCryptoHandle.cs
- RootBrowserWindow.cs
- AsymmetricCryptoHandle.cs
- RegisteredExpandoAttribute.cs
- Compiler.cs
- validation.cs
- TextDecoration.cs
- ContentDefinition.cs
- CookielessHelper.cs
- HashFinalRequest.cs
- HttpHandlerActionCollection.cs
- coordinator.cs
- TextSelectionHelper.cs
- ByteStorage.cs
- MethodAccessException.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- ToolStripTextBox.cs
- Compiler.cs
- ProfileGroupSettings.cs
- FilterUserControlBase.cs
- SrgsText.cs
- CodeExporter.cs
- ACL.cs
- _DisconnectOverlappedAsyncResult.cs
- ExceptionHelpers.cs
- DoubleUtil.cs
- XmlDataSource.cs
- ISAPIWorkerRequest.cs
- TransformPattern.cs
- UIHelper.cs
- FixedHighlight.cs
- SetterBaseCollection.cs
- ServiceContractGenerator.cs
- SiteOfOriginPart.cs
- DbConnectionPoolOptions.cs
- XamlSerializerUtil.cs
- SourceFileBuildProvider.cs
- ClientFormsAuthenticationCredentials.cs
- NonVisualControlAttribute.cs
- StorageMappingItemCollection.cs
- Stopwatch.cs
- FamilyTypeface.cs
- OuterProxyWrapper.cs
- StringBuilder.cs
- ColorTransformHelper.cs
- BeginStoryboard.cs
- RecordConverter.cs
- ProcessStartInfo.cs
- PluralizationServiceUtil.cs
- Helper.cs
- datacache.cs
- ContainerUtilities.cs
- ProcessManager.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- PeerInvitationResponse.cs
- TextEditorCharacters.cs
- TdsParserSessionPool.cs
- SamlAction.cs
- IDispatchConstantAttribute.cs
- File.cs
- DataGridViewCell.cs
- TextFormatterHost.cs
- PowerModeChangedEventArgs.cs
- SecureStringHasher.cs
- NativeMethods.cs
- IndexerNameAttribute.cs
- DefaultValueConverter.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- IisTraceWebEventProvider.cs
- SchemaHelper.cs
- RowCache.cs
- RightsManagementEncryptionTransform.cs
- milexports.cs
- XamlTreeBuilder.cs
- VectorAnimation.cs
- DataFormats.cs
- ServicePointManagerElement.cs
- CollectionViewGroupInternal.cs
- ComponentEditorForm.cs
- EndEvent.cs
- SessionPageStatePersister.cs
- DataControlLinkButton.cs
- PointCollection.cs
- MobileDeviceCapabilitiesSectionHandler.cs
- _ContextAwareResult.cs
- WSTrust.cs
- SymbolMethod.cs
- WorkflowTimerService.cs
- MemberRelationshipService.cs
- OleDbEnumerator.cs
- ConstrainedDataObject.cs
- ServiceObjectContainer.cs
- HtmlForm.cs
- DbCommandDefinition.cs
- WmpBitmapEncoder.cs