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
- Menu.cs
- NameSpaceExtractor.cs
- GridViewRowCollection.cs
- QilPatternVisitor.cs
- ValueHandle.cs
- AvTrace.cs
- Unit.cs
- PageTrueTypeFont.cs
- EntityCommandExecutionException.cs
- VectorCollectionConverter.cs
- ExpandedWrapper.cs
- MimeWriter.cs
- GenerateHelper.cs
- ErrorWebPart.cs
- DbProviderSpecificTypePropertyAttribute.cs
- ListViewCancelEventArgs.cs
- SeverityFilter.cs
- DataGridViewColumnHeaderCell.cs
- CodeBinaryOperatorExpression.cs
- DataRelationPropertyDescriptor.cs
- MenuScrollingVisibilityConverter.cs
- XsdBuilder.cs
- ListItemParagraph.cs
- QueryOutputWriter.cs
- StringUtil.cs
- TraceProvider.cs
- RuntimeResourceSet.cs
- IsolatedStoragePermission.cs
- GenericAuthenticationEventArgs.cs
- sqlcontext.cs
- GeometryGroup.cs
- TemplatedWizardStep.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- TableProviderWrapper.cs
- ResourcePool.cs
- RowVisual.cs
- ScriptControl.cs
- DataGridRowHeader.cs
- X509ChainElement.cs
- DrawingContextWalker.cs
- PrintDialog.cs
- HttpFileCollection.cs
- CollectionChangeEventArgs.cs
- DataPager.cs
- Byte.cs
- ImageCodecInfo.cs
- Panel.cs
- DataViewSetting.cs
- PngBitmapEncoder.cs
- UnsafeNativeMethods.cs
- ScrollItemPatternIdentifiers.cs
- StylusButtonCollection.cs
- TraceContext.cs
- Light.cs
- COMException.cs
- EntityDesignerBuildProvider.cs
- InternalCache.cs
- DPCustomTypeDescriptor.cs
- GcHandle.cs
- PagerSettings.cs
- DbDataAdapter.cs
- DATA_BLOB.cs
- CompositeFontParser.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- WebHttpSecurityElement.cs
- PerspectiveCamera.cs
- TokenBasedSet.cs
- OleDbParameter.cs
- wgx_commands.cs
- AutomationPeer.cs
- NavigationEventArgs.cs
- EntityClassGenerator.cs
- PresentationUIStyleResources.cs
- activationcontext.cs
- StateRuntime.cs
- coordinatorfactory.cs
- AnimationClock.cs
- HttpClientCredentialType.cs
- DataContractSet.cs
- Property.cs
- HttpPostedFile.cs
- PropertyValueChangedEvent.cs
- MimeTypeAttribute.cs
- TextServicesPropertyRanges.cs
- NonVisualControlAttribute.cs
- ChangeBlockUndoRecord.cs
- DictionaryEntry.cs
- AutomationProperty.cs
- _ConnectionGroup.cs
- PassportIdentity.cs
- OpenTypeCommon.cs
- StringUtil.cs
- WmiEventSink.cs
- CaseInsensitiveComparer.cs
- ToolBarButtonClickEvent.cs
- XmlSignificantWhitespace.cs
- RandomNumberGenerator.cs
- ColumnWidthChangingEvent.cs
- AuthenticationServiceManager.cs
- IndexerHelper.cs