Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- EventHandlerList.cs
- CompensationHandlingFilter.cs
- SQLStringStorage.cs
- FlowDocumentReader.cs
- HtmlInputButton.cs
- FileDialog.cs
- MulticastNotSupportedException.cs
- WindowsBrush.cs
- ResourceDefaultValueAttribute.cs
- HasCopySemanticsAttribute.cs
- TraceInternal.cs
- DBPropSet.cs
- X509Logo.cs
- propertytag.cs
- ManagedFilter.cs
- WindowsSolidBrush.cs
- ResourceContainer.cs
- PointHitTestResult.cs
- RenderData.cs
- Command.cs
- SqlBulkCopy.cs
- GridErrorDlg.cs
- AssemblyBuilder.cs
- DataGridItemEventArgs.cs
- InternalBufferOverflowException.cs
- NativeMethods.cs
- ExceptionTranslationTable.cs
- RSAPKCS1SignatureFormatter.cs
- IDictionary.cs
- XmlSchemaExternal.cs
- SQLByteStorage.cs
- WebEventTraceProvider.cs
- MemberInfoSerializationHolder.cs
- SettingsSection.cs
- LicenseContext.cs
- HtmlElementCollection.cs
- XsdSchemaFileEditor.cs
- MetafileHeaderWmf.cs
- IpcClientManager.cs
- CollectionDataContractAttribute.cs
- ListChangedEventArgs.cs
- TaiwanCalendar.cs
- RadioButton.cs
- XsltConvert.cs
- SymDocumentType.cs
- ConsumerConnectionPoint.cs
- RadioButtonRenderer.cs
- DbProviderFactoriesConfigurationHandler.cs
- StoreContentChangedEventArgs.cs
- TextModifierScope.cs
- SqlComparer.cs
- Triplet.cs
- XPathNavigatorReader.cs
- ConstructorArgumentAttribute.cs
- SerializableAttribute.cs
- ToolStripItemTextRenderEventArgs.cs
- AdornerLayer.cs
- GridItemPattern.cs
- BooleanSwitch.cs
- _SecureChannel.cs
- SolidColorBrush.cs
- RuntimeArgumentHandle.cs
- HwndStylusInputProvider.cs
- GridViewSelectEventArgs.cs
- XmlILIndex.cs
- DefaultExpressionVisitor.cs
- CapabilitiesPattern.cs
- SqlException.cs
- NaturalLanguageHyphenator.cs
- WmpBitmapDecoder.cs
- VirtualizingStackPanel.cs
- GenericNameHandler.cs
- LateBoundBitmapDecoder.cs
- XmlWhitespace.cs
- QilPatternFactory.cs
- X509CertificateTrustedIssuerElementCollection.cs
- IxmlLineInfo.cs
- ApplicationProxyInternal.cs
- TypeReference.cs
- metadatamappinghashervisitor.hashsourcebuilder.cs
- SchemaDeclBase.cs
- AutoScrollExpandMessageFilter.cs
- AssemblyInfo.cs
- NullReferenceException.cs
- ExtendedPropertyDescriptor.cs
- SmtpReplyReaderFactory.cs
- X509LogoTypeExtension.cs
- URIFormatException.cs
- ProtocolException.cs
- HttpConfigurationContext.cs
- X509ChainPolicy.cs
- Menu.cs
- Point4DConverter.cs
- ObjectDataSourceView.cs
- AmbiguousMatchException.cs
- InternalRelationshipCollection.cs
- SmiTypedGetterSetter.cs
- WebPartMovingEventArgs.cs
- EmbeddedMailObject.cs
- EventLogPermission.cs