Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Media / Animation / ControllableStoryboardAction.cs / 1305600 / 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
- XmlWrappingReader.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- ClientUrlResolverWrapper.cs
- DockProviderWrapper.cs
- BrowserInteropHelper.cs
- LineUtil.cs
- PromptBuilder.cs
- Decorator.cs
- QueryRewriter.cs
- HttpHandlerAction.cs
- cookiecollection.cs
- ThreadExceptionDialog.cs
- ServiceRoute.cs
- Aggregates.cs
- QueryReaderSettings.cs
- BulletedListEventArgs.cs
- CaseInsensitiveComparer.cs
- StringUtil.cs
- ReadOnlyHierarchicalDataSourceView.cs
- MediaTimeline.cs
- EntitySqlQueryCacheKey.cs
- RefreshPropertiesAttribute.cs
- SerialPinChanges.cs
- CodeDirectionExpression.cs
- SchemaSetCompiler.cs
- HierarchicalDataBoundControlAdapter.cs
- XmlNodeList.cs
- DisplayNameAttribute.cs
- GradientStop.cs
- CoreSwitches.cs
- RectangleF.cs
- PkcsUtils.cs
- XLinq.cs
- InstanceKey.cs
- ASCIIEncoding.cs
- SoapEnumAttribute.cs
- SmtpMail.cs
- BaseConfigurationRecord.cs
- FlowDocumentReader.cs
- ZipArchive.cs
- ProgramPublisher.cs
- OutputWindow.cs
- WsdlWriter.cs
- ChannelSinkStacks.cs
- ImageSource.cs
- ProtectedProviderSettings.cs
- XmlBoundElement.cs
- Util.cs
- MappingSource.cs
- Quaternion.cs
- CodeExpressionRuleDeclaration.cs
- CollectionTypeElement.cs
- ElementHostPropertyMap.cs
- SpeakCompletedEventArgs.cs
- ColorKeyFrameCollection.cs
- TextAnchor.cs
- NativeMethods.cs
- RadioButtonStandardAdapter.cs
- DesignTimeParseData.cs
- AccessViolationException.cs
- TypeRefElement.cs
- InvalidDataException.cs
- UniqueIdentifierService.cs
- CheckBox.cs
- DataGridPageChangedEventArgs.cs
- DataPagerFieldCollection.cs
- DocumentPageHost.cs
- FileEnumerator.cs
- GorillaCodec.cs
- Menu.cs
- StaticExtension.cs
- StrongNameSignatureInformation.cs
- SplitterEvent.cs
- DBDataPermission.cs
- DataGridViewColumnConverter.cs
- ObjectQueryExecutionPlan.cs
- BooleanConverter.cs
- WindowsEditBoxRange.cs
- serverconfig.cs
- GlobalizationAssembly.cs
- TransactionManager.cs
- CookieHandler.cs
- CalendarAutomationPeer.cs
- SerialErrors.cs
- AffineTransform3D.cs
- _SecureChannel.cs
- WebServiceData.cs
- EmptyReadOnlyDictionaryInternal.cs
- AssemblyNameProxy.cs
- UserControl.cs
- BulletedList.cs
- InstanceKeyNotReadyException.cs
- InstanceDataCollectionCollection.cs
- ProvidersHelper.cs
- PrintingPermission.cs
- PersonalizableTypeEntry.cs
- XmlElementCollection.cs
- WebPartsPersonalization.cs
- IgnoreFlushAndCloseStream.cs
- LongAverageAggregationOperator.cs