Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / Media / Animation / ControllableStoryboardAction.cs / 1 / ControllableStoryboardAction.cs
/****************************************************************************\ * * File: ControllableStoryboardAction.cs * * This object includes a named Storyboard references. When triggered, the * name is resolved and passed to a derived class method to perform the * actual action. * * Copyright (C) by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System.ComponentModel; // DefaultValueAttribute using System.Diagnostics; // Debug.Assert using System.Windows.Documents; // TableTemplate using System.Windows.Markup; // INameScope namespace System.Windows.Media.Animation { ////// A controllable storyboard action associates a trigger action with a /// Storyboard. The association from this object is a string that is the name /// of the Storyboard in a resource dictionary. /// public abstract class ControllableStoryboardAction : TriggerAction { ////// Internal constructor - nobody is supposed to ever create an instance /// of this class. Use a derived class instead. /// internal ControllableStoryboardAction() { } ////// Name to use for resolving the storyboard reference needed. This /// points to a BeginStoryboard instance, and we're controlling that one. /// [DefaultValue(null)] public string BeginStoryboardName { get { return _beginStoryboardName; } set { if (IsSealed) { throw new InvalidOperationException(SR.Get(SRID.CannotChangeAfterSealed, "ControllableStoryboardAction")); } // Null is allowed to wipe out existing name - as long as another // valid name is set before Invoke time. _beginStoryboardName = value; } } internal sealed override void Invoke( FrameworkElement fe, FrameworkContentElement fce, Style targetStyle, FrameworkTemplate frameworkTemplate, Int64 layer ) { Debug.Assert( fe != null || fce != null, "Caller of internal function failed to verify that we have a FE or FCE - we have neither." ); Debug.Assert( targetStyle != null || frameworkTemplate != null, "This function expects to be called when the associated action is inside a Style/Template. But it was not given a reference to anything." ); INameScope nameScope = null; if( targetStyle != null ) { nameScope = targetStyle; } else { Debug.Assert( frameworkTemplate != null ); nameScope = frameworkTemplate; } Invoke( fe, fce, GetStoryboard( fe, fce, nameScope ) ); } internal sealed override void Invoke( FrameworkElement fe ) { Debug.Assert( fe != null, "Invoke needs an object as starting point"); Invoke( fe, null, GetStoryboard( fe, null, null ) ); } internal virtual void Invoke( FrameworkElement containingFE, FrameworkContentElement containingFCE, Storyboard storyboard ) { } // Find a Storyboard object for this StoryboardAction to act on, using the // given BeginStoryboardName to find a BeginStoryboard instance and use // its Storyboard object reference. private Storyboard GetStoryboard( FrameworkElement fe, FrameworkContentElement fce, INameScope nameScope ) { if( BeginStoryboardName == null ) { throw new InvalidOperationException(SR.Get(SRID.Storyboard_BeginStoryboardNameRequired)); } BeginStoryboard keyedBeginStoryboard = Storyboard.ResolveBeginStoryboardName( BeginStoryboardName, nameScope, fe, fce ); Storyboard storyboard = keyedBeginStoryboard.Storyboard; if( storyboard == null ) { throw new InvalidOperationException(SR.Get(SRID.Storyboard_BeginStoryboardNoStoryboard, BeginStoryboardName)); } return storyboard; } private string _beginStoryboardName = null; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. /****************************************************************************\ * * File: ControllableStoryboardAction.cs * * This object includes a named Storyboard references. When triggered, the * name is resolved and passed to a derived class method to perform the * actual action. * * Copyright (C) by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System.ComponentModel; // DefaultValueAttribute using System.Diagnostics; // Debug.Assert using System.Windows.Documents; // TableTemplate using System.Windows.Markup; // INameScope namespace System.Windows.Media.Animation { ////// A controllable storyboard action associates a trigger action with a /// Storyboard. The association from this object is a string that is the name /// of the Storyboard in a resource dictionary. /// public abstract class ControllableStoryboardAction : TriggerAction { ////// Internal constructor - nobody is supposed to ever create an instance /// of this class. Use a derived class instead. /// internal ControllableStoryboardAction() { } ////// Name to use for resolving the storyboard reference needed. This /// points to a BeginStoryboard instance, and we're controlling that one. /// [DefaultValue(null)] public string BeginStoryboardName { get { return _beginStoryboardName; } set { if (IsSealed) { throw new InvalidOperationException(SR.Get(SRID.CannotChangeAfterSealed, "ControllableStoryboardAction")); } // Null is allowed to wipe out existing name - as long as another // valid name is set before Invoke time. _beginStoryboardName = value; } } internal sealed override void Invoke( FrameworkElement fe, FrameworkContentElement fce, Style targetStyle, FrameworkTemplate frameworkTemplate, Int64 layer ) { Debug.Assert( fe != null || fce != null, "Caller of internal function failed to verify that we have a FE or FCE - we have neither." ); Debug.Assert( targetStyle != null || frameworkTemplate != null, "This function expects to be called when the associated action is inside a Style/Template. But it was not given a reference to anything." ); INameScope nameScope = null; if( targetStyle != null ) { nameScope = targetStyle; } else { Debug.Assert( frameworkTemplate != null ); nameScope = frameworkTemplate; } Invoke( fe, fce, GetStoryboard( fe, fce, nameScope ) ); } internal sealed override void Invoke( FrameworkElement fe ) { Debug.Assert( fe != null, "Invoke needs an object as starting point"); Invoke( fe, null, GetStoryboard( fe, null, null ) ); } internal virtual void Invoke( FrameworkElement containingFE, FrameworkContentElement containingFCE, Storyboard storyboard ) { } // Find a Storyboard object for this StoryboardAction to act on, using the // given BeginStoryboardName to find a BeginStoryboard instance and use // its Storyboard object reference. private Storyboard GetStoryboard( FrameworkElement fe, FrameworkContentElement fce, INameScope nameScope ) { if( BeginStoryboardName == null ) { throw new InvalidOperationException(SR.Get(SRID.Storyboard_BeginStoryboardNameRequired)); } BeginStoryboard keyedBeginStoryboard = Storyboard.ResolveBeginStoryboardName( BeginStoryboardName, nameScope, fe, fce ); Storyboard storyboard = keyedBeginStoryboard.Storyboard; if( storyboard == null ) { throw new InvalidOperationException(SR.Get(SRID.Storyboard_BeginStoryboardNoStoryboard, BeginStoryboardName)); } return storyboard; } private string _beginStoryboardName = null; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- OdbcHandle.cs
- GroupItemAutomationPeer.cs
- BitmapFrame.cs
- DependencyObject.cs
- ScrollViewerAutomationPeer.cs
- BitmapEffectOutputConnector.cs
- DocumentReferenceCollection.cs
- Environment.cs
- XmlLangPropertyAttribute.cs
- DiscoveryExceptionDictionary.cs
- RecognizerStateChangedEventArgs.cs
- SqlPersonalizationProvider.cs
- FontUnitConverter.cs
- KeyGesture.cs
- IndexingContentUnit.cs
- QuaternionRotation3D.cs
- ConfigXmlReader.cs
- AccessorTable.cs
- SafeFileMappingHandle.cs
- DetailsViewInsertedEventArgs.cs
- ButtonBase.cs
- PropertyFilterAttribute.cs
- GradientStop.cs
- TransactionTable.cs
- ConfigurationStrings.cs
- NameHandler.cs
- PipeStream.cs
- FrameworkReadOnlyPropertyMetadata.cs
- DropShadowEffect.cs
- MaterializeFromAtom.cs
- WebPartsPersonalization.cs
- PropertyExpression.cs
- DataSourceHelper.cs
- MeshGeometry3D.cs
- AddInStore.cs
- ImageAttributes.cs
- NameValueCollection.cs
- WebZone.cs
- XmlDataSourceDesigner.cs
- BindingContext.cs
- TextUtf8RawTextWriter.cs
- SqlCacheDependencySection.cs
- PrinterSettings.cs
- DoubleMinMaxAggregationOperator.cs
- QilLoop.cs
- DbConnectionPool.cs
- WeakReadOnlyCollection.cs
- CompositeScriptReferenceEventArgs.cs
- ITextView.cs
- InstalledFontCollection.cs
- DesignTimeTemplateParser.cs
- ClipboardData.cs
- Rect.cs
- FieldBuilder.cs
- HttpRequestBase.cs
- ToolStripCollectionEditor.cs
- SqlRowUpdatingEvent.cs
- SelectionManager.cs
- Claim.cs
- XmlAttributeCache.cs
- ThrowHelper.cs
- VerticalAlignConverter.cs
- LogStore.cs
- ListenerConstants.cs
- COM2ICategorizePropertiesHandler.cs
- DataGridToolTip.cs
- TypeSystem.cs
- XmlCountingReader.cs
- XPathNodePointer.cs
- OpenFileDialog.cs
- UnsafeNativeMethods.cs
- LocalizeDesigner.cs
- DictionaryEntry.cs
- RoleService.cs
- EncodingConverter.cs
- Renderer.cs
- HostProtectionException.cs
- HMACSHA256.cs
- DLinqTableProvider.cs
- VisualStyleRenderer.cs
- XmlSchemaExporter.cs
- DynamicPropertyHolder.cs
- DynamicQueryableWrapper.cs
- BypassElement.cs
- PasswordBox.cs
- shaperfactoryquerycachekey.cs
- LinkLabelLinkClickedEvent.cs
- ICollection.cs
- XmlSchemaAppInfo.cs
- ZipFileInfoCollection.cs
- AxisAngleRotation3D.cs
- NewItemsContextMenuStrip.cs
- NoneExcludedImageIndexConverter.cs
- RuntimeIdentifierPropertyAttribute.cs
- WhitespaceReader.cs
- SoapTypeAttribute.cs
- TextRangeSerialization.cs
- GregorianCalendar.cs
- SchemaMapping.cs
- XamlToRtfWriter.cs