Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / DrawingCollection.cs / 1305600 / DrawingCollection.cs
//---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: This file contains non-generated DrawingCollection // methods. // // History: // // 2005/03/18 : timothyc - Created it. // //--------------------------------------------------------------------------- using System.Collections; using System.Collections.Generic; using System.Windows.Media.Animation; using System.Windows.Markup; namespace System.Windows.Media { ////// Collection of Drawing objects /// public sealed partial class DrawingCollection : Animatable, IList, IList{ /// /// Appends the entire input DrawingCollection, while only firing a single set of /// public events. If an exception is thrown from the public events, the /// Append operation is rolled back. /// internal void TransactionalAppend(DrawingCollection collectionToAppend) { // Use appendCount to avoid inconsistencies & runaway loops when // this == collectionToAppend, and to ensure collectionToAppend.Count // is only evaluated once. int appendCount = collectionToAppend.Count; // First, append the collection for(int i = 0; i < appendCount; i++) { AddWithoutFiringPublicEvents(collectionToAppend.Internal_GetItem(i)); } // Fire the public Changed event after all the elements have been added. // // If an exception is thrown, then the Append operation is rolled-back without // firing additional events. try { FireChanged(); } catch (Exception) { // Compute the number of elements that existed before the append int beforeAppendCount = Count - appendCount; // Remove the appended elements in reverse order without firing Changed events. for ( int i = Count - 1; // Start at the current last index i >= beforeAppendCount; // Until the previous last index i-- // Move to the preceding index ) { RemoveAtWithoutFiringPublicEvents(i); } // Avoid firing WritePostscript events (e.g., OnChanged) after rolling-back // the current operation. // // This ensures that only a single set of events is fired for both exceptional & // typical cases, and it's likely that firing events would cause another exception. throw; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: This file contains non-generated DrawingCollection // methods. // // History: // // 2005/03/18 : timothyc - Created it. // //--------------------------------------------------------------------------- using System.Collections; using System.Collections.Generic; using System.Windows.Media.Animation; using System.Windows.Markup; namespace System.Windows.Media { ////// Collection of Drawing objects /// public sealed partial class DrawingCollection : Animatable, IList, IList{ /// /// Appends the entire input DrawingCollection, while only firing a single set of /// public events. If an exception is thrown from the public events, the /// Append operation is rolled back. /// internal void TransactionalAppend(DrawingCollection collectionToAppend) { // Use appendCount to avoid inconsistencies & runaway loops when // this == collectionToAppend, and to ensure collectionToAppend.Count // is only evaluated once. int appendCount = collectionToAppend.Count; // First, append the collection for(int i = 0; i < appendCount; i++) { AddWithoutFiringPublicEvents(collectionToAppend.Internal_GetItem(i)); } // Fire the public Changed event after all the elements have been added. // // If an exception is thrown, then the Append operation is rolled-back without // firing additional events. try { FireChanged(); } catch (Exception) { // Compute the number of elements that existed before the append int beforeAppendCount = Count - appendCount; // Remove the appended elements in reverse order without firing Changed events. for ( int i = Count - 1; // Start at the current last index i >= beforeAppendCount; // Until the previous last index i-- // Move to the preceding index ) { RemoveAtWithoutFiringPublicEvents(i); } // Avoid firing WritePostscript events (e.g., OnChanged) after rolling-back // the current operation. // // This ensures that only a single set of events is fired for both exceptional & // typical cases, and it's likely that firing events would cause another exception. throw; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ProfileSettings.cs
- PathSegment.cs
- SiteOfOriginContainer.cs
- MatcherBuilder.cs
- ObjectMemberMapping.cs
- SqlDataSourceStatusEventArgs.cs
- ProviderCommandInfoUtils.cs
- UITypeEditor.cs
- RawAppCommandInputReport.cs
- NavigationWindow.cs
- BaseCodeDomTreeGenerator.cs
- PrimitiveDataContract.cs
- ObjectViewEntityCollectionData.cs
- ObjectStateEntry.cs
- XsltConvert.cs
- ArgumentsParser.cs
- MetaModel.cs
- ArraySubsetEnumerator.cs
- ProcessRequestArgs.cs
- BlurBitmapEffect.cs
- ProfileSettings.cs
- ImageAttributes.cs
- BatchParser.cs
- ComplusTypeValidator.cs
- MetabaseSettings.cs
- InvokeProviderWrapper.cs
- XmlEncodedRawTextWriter.cs
- BinarySerializer.cs
- MetadataItemSerializer.cs
- XmlHierarchicalDataSourceView.cs
- GridViewUpdateEventArgs.cs
- MouseGestureValueSerializer.cs
- PaperSize.cs
- NamespaceDisplayAutomationPeer.cs
- DesignerActionUI.cs
- assemblycache.cs
- ShowExpandedMultiValueConverter.cs
- StylusPointPropertyUnit.cs
- WebExceptionStatus.cs
- TabControlEvent.cs
- XmlEncodedRawTextWriter.cs
- XmlDictionaryString.cs
- XmlHierarchyData.cs
- BindingCompleteEventArgs.cs
- TagMapCollection.cs
- ToolStripGrip.cs
- ToolStripItemImageRenderEventArgs.cs
- DesignerUtils.cs
- Literal.cs
- MailSettingsSection.cs
- ComboBoxItem.cs
- RawStylusActions.cs
- DataGridViewSelectedRowCollection.cs
- WebPartZoneBase.cs
- PeerApplication.cs
- DeclarationUpdate.cs
- TextBoxView.cs
- EventSetter.cs
- ComplexObject.cs
- BitmapEffectRenderDataResource.cs
- StrongNameUtility.cs
- WebConfigurationFileMap.cs
- RadioButtonRenderer.cs
- PropertyChangingEventArgs.cs
- RowToFieldTransformer.cs
- RNGCryptoServiceProvider.cs
- FileUtil.cs
- Padding.cs
- Converter.cs
- RegexGroup.cs
- SchemaImporter.cs
- AnonymousIdentificationSection.cs
- DrawingImage.cs
- ControlDesigner.cs
- DelegatingTypeDescriptionProvider.cs
- CodeRegionDirective.cs
- StopStoryboard.cs
- RelationshipFixer.cs
- GuidConverter.cs
- PtsHost.cs
- RealizedColumnsBlock.cs
- FocusTracker.cs
- Typography.cs
- LineServicesCallbacks.cs
- MediaTimeline.cs
- ScriptRef.cs
- RenderDataDrawingContext.cs
- SkipStoryboardToFill.cs
- VersionedStreamOwner.cs
- WebPartConnection.cs
- FocusManager.cs
- ErrorHandler.cs
- XmlDictionaryReaderQuotasElement.cs
- ISFClipboardData.cs
- WindowsAuthenticationEventArgs.cs
- XPathEmptyIterator.cs
- XsltInput.cs
- Command.cs
- unsafenativemethodstextservices.cs
- OdbcCommand.cs