Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / Media / DrawingCollection.cs / 1 / 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
- GridViewSortEventArgs.cs
- XmlSecureResolver.cs
- MatrixValueSerializer.cs
- Point3DCollection.cs
- OperationValidationEventArgs.cs
- ContextDataSourceContextData.cs
- Lasso.cs
- Misc.cs
- StandardTransformFactory.cs
- SafeArchiveContext.cs
- BinaryUtilClasses.cs
- PolyQuadraticBezierSegment.cs
- WeakReadOnlyCollection.cs
- HtmlPhoneCallAdapter.cs
- DataGridColumnCollection.cs
- StringToken.cs
- DateTime.cs
- SchemaImporterExtensionsSection.cs
- ViewManager.cs
- DropShadowBitmapEffect.cs
- QueryHandler.cs
- Attributes.cs
- CodeSnippetStatement.cs
- ReadOnlyTernaryTree.cs
- Properties.cs
- FileLogRecordStream.cs
- SkipStoryboardToFill.cs
- StatusStrip.cs
- RawContentTypeMapper.cs
- CryptoProvider.cs
- ShapeTypeface.cs
- Pts.cs
- Operator.cs
- QilPatternFactory.cs
- Validator.cs
- DesignerRegionCollection.cs
- ComplusTypeValidator.cs
- EntityDataSourceWizardForm.cs
- ProgressChangedEventArgs.cs
- Sql8ExpressionRewriter.cs
- InfiniteTimeSpanConverter.cs
- MaterialGroup.cs
- PermissionRequestEvidence.cs
- SoapTypeAttribute.cs
- SerializationTrace.cs
- TypedTableBaseExtensions.cs
- CatalogPartCollection.cs
- DataGridViewCellLinkedList.cs
- RelationshipConverter.cs
- MediaPlayer.cs
- _HeaderInfoTable.cs
- Stack.cs
- PagedDataSource.cs
- RequestQueue.cs
- MsmqProcessProtocolHandler.cs
- DataGridViewRowCollection.cs
- OSEnvironmentHelper.cs
- DebugTraceHelper.cs
- AnimationStorage.cs
- ResumeStoryboard.cs
- CompositeScriptReferenceEventArgs.cs
- LeaseManager.cs
- FixedPosition.cs
- AttachedAnnotationChangedEventArgs.cs
- compensatingcollection.cs
- BreadCrumbTextConverter.cs
- SeekStoryboard.cs
- DirectoryNotFoundException.cs
- XmlLoader.cs
- HwndHostAutomationPeer.cs
- ServiceReference.cs
- PaginationProgressEventArgs.cs
- WebPartsPersonalization.cs
- SoapReflector.cs
- DataSourceProvider.cs
- Dictionary.cs
- ComponentResourceKey.cs
- ExternalCalls.cs
- SqlBuffer.cs
- PageMediaType.cs
- ClientUrlResolverWrapper.cs
- RemoteArgument.cs
- MulticastNotSupportedException.cs
- AnnotationMap.cs
- CatalogPartCollection.cs
- Axis.cs
- ProviderSettings.cs
- WebEventTraceProvider.cs
- PixelFormats.cs
- GeometryGroup.cs
- GenericWebPart.cs
- CloseCollectionAsyncResult.cs
- ImageSource.cs
- FrugalList.cs
- MethodToken.cs
- SoapAttributeOverrides.cs
- TogglePattern.cs
- DataGridItemCollection.cs
- CodeExporter.cs
- ProviderUtil.cs