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
- ClientScriptManager.cs
- FormatterConverter.cs
- SemaphoreFullException.cs
- ParallelQuery.cs
- RepeaterItemCollection.cs
- TextTreeInsertElementUndoUnit.cs
- BoundingRectTracker.cs
- AdapterDictionary.cs
- PointCollection.cs
- Root.cs
- hwndwrapper.cs
- _ListenerRequestStream.cs
- _DisconnectOverlappedAsyncResult.cs
- SurrogateChar.cs
- InfoCardCryptoHelper.cs
- ApplicationActivator.cs
- CodeTypeReferenceCollection.cs
- Selection.cs
- ReadOnlyHierarchicalDataSourceView.cs
- AuthenticationSection.cs
- NativeRightsManagementAPIsStructures.cs
- MailMessage.cs
- XmlMapping.cs
- SspiHelper.cs
- ButtonBase.cs
- RectAnimationBase.cs
- TextStore.cs
- StylusButtonCollection.cs
- XPathItem.cs
- XamlInt32CollectionSerializer.cs
- XmlStringTable.cs
- InputReport.cs
- WinEventTracker.cs
- RealizedColumnsBlock.cs
- SqlDataSourceTableQuery.cs
- AccessorTable.cs
- XmlSchemaSubstitutionGroup.cs
- XsdBuildProvider.cs
- DbTypeMap.cs
- PermissionSet.cs
- ErrorHandler.cs
- Stylus.cs
- ApplicationHost.cs
- WindowsSysHeader.cs
- FileSystemInfo.cs
- CompleteWizardStep.cs
- MachineKeySection.cs
- JavaScriptObjectDeserializer.cs
- RequiredFieldValidator.cs
- DataGridViewColumnCollection.cs
- SqlAliaser.cs
- TextModifier.cs
- SQLBoolean.cs
- XmlSchemaSequence.cs
- sqlmetadatafactory.cs
- metadatamappinghashervisitor.cs
- IntSumAggregationOperator.cs
- PropertyPathConverter.cs
- SqlEnums.cs
- CompiledRegexRunnerFactory.cs
- NegotiationTokenAuthenticatorStateCache.cs
- UdpConstants.cs
- CategoriesDocument.cs
- XPathException.cs
- GridViewDeleteEventArgs.cs
- CannotUnloadAppDomainException.cs
- SQLDateTime.cs
- SortableBindingList.cs
- EventLogEntryCollection.cs
- SizeLimitedCache.cs
- CodeMemberProperty.cs
- OptionUsage.cs
- GridView.cs
- RemotingConfiguration.cs
- PropertyEmitter.cs
- ListSourceHelper.cs
- ControlSerializer.cs
- ListViewDeletedEventArgs.cs
- FontDifferentiator.cs
- TableLayoutStyleCollection.cs
- IdnMapping.cs
- Vector.cs
- Material.cs
- QueryExecutionOption.cs
- oledbmetadatacolumnnames.cs
- SelectionItemPattern.cs
- PropertyToken.cs
- SmiConnection.cs
- XmlSchemaSimpleTypeUnion.cs
- DiffuseMaterial.cs
- SQLResource.cs
- CancelEventArgs.cs
- DataSourceGroupCollection.cs
- Form.cs
- TheQuery.cs
- ExternalFile.cs
- CommandManager.cs
- GenericTextProperties.cs
- DataGridViewElement.cs
- Rights.cs