Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / 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 : rruiz - 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. //---------------------------------------------------------------------------- // // // 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 : rruiz - 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
- Keyboard.cs
- DelegatingTypeDescriptionProvider.cs
- ResXResourceReader.cs
- WindowVisualStateTracker.cs
- ReliabilityContractAttribute.cs
- DataSetMappper.cs
- ConnectionStringsExpressionEditor.cs
- SqlServices.cs
- ConnectionStringSettingsCollection.cs
- SerTrace.cs
- ToolboxItemImageConverter.cs
- WebBrowserProgressChangedEventHandler.cs
- ImageListDesigner.cs
- AspNetSynchronizationContext.cs
- ConfigurationElement.cs
- UInt32.cs
- TextEditorContextMenu.cs
- OleDbPropertySetGuid.cs
- NetworkCredential.cs
- LockedAssemblyCache.cs
- DesignerActionPropertyItem.cs
- DesignTable.cs
- ObjectConverter.cs
- HttpApplication.cs
- ErrorProvider.cs
- DetailsViewInsertedEventArgs.cs
- NamespaceDecl.cs
- SmiGettersStream.cs
- EntryIndex.cs
- MatrixIndependentAnimationStorage.cs
- QueryCacheKey.cs
- ChildChangedEventArgs.cs
- WindowsTitleBar.cs
- Scene3D.cs
- SqlClientPermission.cs
- PointValueSerializer.cs
- UrlAuthorizationModule.cs
- IsolationInterop.cs
- Vector3D.cs
- OpCodes.cs
- Win32MouseDevice.cs
- CompiledQuery.cs
- JournalEntry.cs
- CanonicalXml.cs
- CreatingCookieEventArgs.cs
- ToolBarPanel.cs
- ToolStripDropTargetManager.cs
- ObfuscateAssemblyAttribute.cs
- WebResourceUtil.cs
- RegexWriter.cs
- CodeConditionStatement.cs
- Rectangle.cs
- WmlPageAdapter.cs
- ChannelFactoryRefCache.cs
- HttpCacheVaryByContentEncodings.cs
- FrameworkName.cs
- SimplePropertyEntry.cs
- GraphicsPath.cs
- BamlVersionHeader.cs
- SctClaimDictionary.cs
- ServerIdentity.cs
- CallbackValidatorAttribute.cs
- HwndAppCommandInputProvider.cs
- HostDesigntimeLicenseContext.cs
- IUnknownConstantAttribute.cs
- AttachedAnnotation.cs
- ValidatingReaderNodeData.cs
- RelatedEnd.cs
- ContentPropertyAttribute.cs
- BaseUriHelper.cs
- DataGridViewComboBoxEditingControl.cs
- FillBehavior.cs
- HtmlControlPersistable.cs
- SchemaInfo.cs
- LifetimeServices.cs
- DefaultBindingPropertyAttribute.cs
- SafeHandles.cs
- RuntimeArgument.cs
- CqlWriter.cs
- DataReceivedEventArgs.cs
- ScalarRestriction.cs
- MimeTypeMapper.cs
- FieldToken.cs
- LinkTarget.cs
- StatusBar.cs
- XmlEntity.cs
- RuntimeArgument.cs
- DataSourceCache.cs
- FlowPosition.cs
- SerialPort.cs
- NavigationProperty.cs
- Memoizer.cs
- TextTreeInsertUndoUnit.cs
- NamespaceEmitter.cs
- QueuePathDialog.cs
- TreeNode.cs
- PenThreadWorker.cs
- PanelDesigner.cs
- CancelEventArgs.cs
- ProjectionNode.cs