Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Media / Animation / SeekStoryboard.cs / 1305600 / SeekStoryboard.cs
/****************************************************************************\ * * File: SeekStoryboard.cs * * This object includes a Storyboard reference. When triggered, the Storyboard * seeks to the given offset. * * Copyright (C) by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System.ComponentModel; // DefaultValueAttribute using System.Diagnostics; // Debug.Assert namespace System.Windows.Media.Animation { ////// SeekStoryboard will call seek on its Storyboard reference when /// it is triggered. /// public sealed class SeekStoryboard : ControllableStoryboardAction { ////// A time offset to use for this action. If it is never explicitly /// specified, it will be zero. /// // [DefaultValue(TimeSpan.Zero)] - not usable because TimeSpan.Zero is not a constant expression. public TimeSpan Offset { get { return _offset; } set { if (IsSealed) { throw new InvalidOperationException(SR.Get(SRID.CannotChangeAfterSealed, "SeekStoryboard")); } // TimeSpan is a struct and can't be null - hence no ArgumentNullException check. _offset = value; } } ////// This method is used by TypeDescriptor to determine if this property should /// be serialized. /// // Because we can't use [DefaultValue(TimeSpan.Zero)] - TimeSpan.Zero is not a constant expression. [EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeOffset() { return !(TimeSpan.Zero.Equals(_offset)); } ////// A time offset origin from which to evaluate the Offset value. /// If it is never explicitly specified, it will be relative to the /// beginning. ("Begin") /// [DefaultValue(TimeSeekOrigin.BeginTime)] public TimeSeekOrigin Origin { get { return _origin; } set { if (IsSealed) { throw new InvalidOperationException(SR.Get(SRID.CannotChangeAfterSealed, "SeekStoryboard")); } if( value == TimeSeekOrigin.BeginTime || value == TimeSeekOrigin.Duration ) // FxCop doesn't like Enum.IsDefined, probably need some central validation mechanism. { _origin = value; } else { throw new ArgumentException(SR.Get(SRID.Storyboard_UnrecognizedTimeSeekOrigin)); } } } ////// Called when it's time to execute this storyboard action /// internal override void Invoke( FrameworkElement containingFE, FrameworkContentElement containingFCE, Storyboard storyboard ) { Debug.Assert( containingFE != null || containingFCE != null, "Caller of internal function failed to verify that we have a FE or FCE - we have neither." ); if( containingFE != null ) { storyboard.Seek(containingFE, Offset, Origin); } else { storyboard.Seek(containingFCE, Offset, Origin); } } TimeSpan _offset = TimeSpan.Zero; TimeSeekOrigin _origin = TimeSeekOrigin.BeginTime; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. /****************************************************************************\ * * File: SeekStoryboard.cs * * This object includes a Storyboard reference. When triggered, the Storyboard * seeks to the given offset. * * Copyright (C) by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System.ComponentModel; // DefaultValueAttribute using System.Diagnostics; // Debug.Assert namespace System.Windows.Media.Animation { ////// SeekStoryboard will call seek on its Storyboard reference when /// it is triggered. /// public sealed class SeekStoryboard : ControllableStoryboardAction { ////// A time offset to use for this action. If it is never explicitly /// specified, it will be zero. /// // [DefaultValue(TimeSpan.Zero)] - not usable because TimeSpan.Zero is not a constant expression. public TimeSpan Offset { get { return _offset; } set { if (IsSealed) { throw new InvalidOperationException(SR.Get(SRID.CannotChangeAfterSealed, "SeekStoryboard")); } // TimeSpan is a struct and can't be null - hence no ArgumentNullException check. _offset = value; } } ////// This method is used by TypeDescriptor to determine if this property should /// be serialized. /// // Because we can't use [DefaultValue(TimeSpan.Zero)] - TimeSpan.Zero is not a constant expression. [EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeOffset() { return !(TimeSpan.Zero.Equals(_offset)); } ////// A time offset origin from which to evaluate the Offset value. /// If it is never explicitly specified, it will be relative to the /// beginning. ("Begin") /// [DefaultValue(TimeSeekOrigin.BeginTime)] public TimeSeekOrigin Origin { get { return _origin; } set { if (IsSealed) { throw new InvalidOperationException(SR.Get(SRID.CannotChangeAfterSealed, "SeekStoryboard")); } if( value == TimeSeekOrigin.BeginTime || value == TimeSeekOrigin.Duration ) // FxCop doesn't like Enum.IsDefined, probably need some central validation mechanism. { _origin = value; } else { throw new ArgumentException(SR.Get(SRID.Storyboard_UnrecognizedTimeSeekOrigin)); } } } ////// Called when it's time to execute this storyboard action /// internal override void Invoke( FrameworkElement containingFE, FrameworkContentElement containingFCE, Storyboard storyboard ) { Debug.Assert( containingFE != null || containingFCE != null, "Caller of internal function failed to verify that we have a FE or FCE - we have neither." ); if( containingFE != null ) { storyboard.Seek(containingFE, Offset, Origin); } else { storyboard.Seek(containingFCE, Offset, Origin); } } TimeSpan _offset = TimeSpan.Zero; TimeSeekOrigin _origin = TimeSeekOrigin.BeginTime; } } // 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
- ResourcePermissionBase.cs
- CacheAxisQuery.cs
- CaseInsensitiveHashCodeProvider.cs
- ButtonFieldBase.cs
- SiteMapPath.cs
- RowToParametersTransformer.cs
- Rotation3D.cs
- TransformedBitmap.cs
- StrongName.cs
- ActivationServices.cs
- Cursors.cs
- NamespaceImport.cs
- RemotingServices.cs
- autovalidator.cs
- XmlBinaryReader.cs
- BrowserDefinition.cs
- RegisteredScript.cs
- CatchBlock.cs
- AdornedElementPlaceholder.cs
- RoleManagerModule.cs
- KerberosTicketHashIdentifierClause.cs
- TypeConverterHelper.cs
- TransformCollection.cs
- HitTestParameters3D.cs
- MenuCommand.cs
- SharedUtils.cs
- EntityDataSourceSelectedEventArgs.cs
- SoapRpcServiceAttribute.cs
- EncryptedType.cs
- TextEndOfLine.cs
- DispatcherTimer.cs
- TextSchema.cs
- EntitySqlQueryBuilder.cs
- FlowLayoutSettings.cs
- VSWCFServiceContractGenerator.cs
- TrailingSpaceComparer.cs
- ResourceDescriptionAttribute.cs
- DbBuffer.cs
- Inline.cs
- MarshalByRefObject.cs
- Application.cs
- SoapHeader.cs
- BindingExpression.cs
- FileAuthorizationModule.cs
- ReferentialConstraintRoleElement.cs
- ObjectConverter.cs
- HttpVersion.cs
- ClientSettingsSection.cs
- Event.cs
- DesignerTransaction.cs
- ImmutableObjectAttribute.cs
- ListControlConvertEventArgs.cs
- DocumentPageView.cs
- SqlClientPermission.cs
- FlowThrottle.cs
- EncodingDataItem.cs
- DesignerVerbCollection.cs
- VariableReference.cs
- BinaryQueryOperator.cs
- XmlWriterSettings.cs
- Enum.cs
- NativeObjectSecurity.cs
- ObjectTag.cs
- GridViewItemAutomationPeer.cs
- DbProviderFactories.cs
- XmlMtomWriter.cs
- EmbossBitmapEffect.cs
- TypeUtils.cs
- WebPartConnectionCollection.cs
- propertytag.cs
- DataGridViewRowConverter.cs
- ConfigXmlText.cs
- CodeArrayCreateExpression.cs
- QueryOutputWriter.cs
- TableItemProviderWrapper.cs
- AdornerHitTestResult.cs
- ToolStripItemClickedEventArgs.cs
- DefaultValueAttribute.cs
- CheckBoxRenderer.cs
- NullableDoubleSumAggregationOperator.cs
- EventLogPermissionEntry.cs
- NumberAction.cs
- DataGridViewRow.cs
- QueryableDataSourceView.cs
- SeverityFilter.cs
- SchemaImporterExtensionsSection.cs
- CryptoHandle.cs
- NavigatorInput.cs
- HandleExceptionArgs.cs
- ParseChildrenAsPropertiesAttribute.cs
- DockPattern.cs
- TextEncodedRawTextWriter.cs
- ReferentialConstraint.cs
- ApplicationActivator.cs
- DataListItemEventArgs.cs
- mactripleDES.cs
- rsa.cs
- DllNotFoundException.cs
- DockPattern.cs
- CssClassPropertyAttribute.cs