Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / Media / Animation / SeekStoryboard.cs / 1 / 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
- DeflateEmulationStream.cs
- DataPagerCommandEventArgs.cs
- EnumerableCollectionView.cs
- TableItemPattern.cs
- Style.cs
- WebPartDisplayMode.cs
- GridItem.cs
- RelativeSource.cs
- AbstractSvcMapFileLoader.cs
- RootBrowserWindow.cs
- ContractCodeDomInfo.cs
- SqlIdentifier.cs
- ComNativeDescriptor.cs
- DataGridHeaderBorder.cs
- SqlMethodAttribute.cs
- mediaeventargs.cs
- AnnouncementInnerClient11.cs
- OutputCacheProfile.cs
- FtpWebResponse.cs
- OperationParameterInfoCollection.cs
- DataGridViewCell.cs
- ConfigXmlText.cs
- UnsafeNativeMethods.cs
- SyndicationFeedFormatter.cs
- SchemaComplexType.cs
- IssuedSecurityTokenParameters.cs
- SmtpMail.cs
- MediaCommands.cs
- ObjectDataSourceView.cs
- _Win32.cs
- DESCryptoServiceProvider.cs
- LongTypeConverter.cs
- ToolTipService.cs
- ToolStripItemImageRenderEventArgs.cs
- UniqueEventHelper.cs
- HandlerFactoryWrapper.cs
- Panel.cs
- ResumeStoryboard.cs
- CodeCompiler.cs
- DataGridViewColumnDesignTimeVisibleAttribute.cs
- ListenerElementsCollection.cs
- XmlTextReader.cs
- TypeUtils.cs
- LinqDataSourceEditData.cs
- StateManagedCollection.cs
- Internal.cs
- ContextMenu.cs
- RuleSettingsCollection.cs
- ViewStateException.cs
- InstanceDataCollectionCollection.cs
- JavaScriptSerializer.cs
- AvTrace.cs
- SpStreamWrapper.cs
- ConfigurationStrings.cs
- ActivationServices.cs
- Set.cs
- XmlSerializerSection.cs
- UIElement3D.cs
- SizeIndependentAnimationStorage.cs
- SystemSounds.cs
- LZCodec.cs
- ComponentEditorForm.cs
- DictionaryItemsCollection.cs
- AnnotationComponentManager.cs
- ALinqExpressionVisitor.cs
- RepeatBehaviorConverter.cs
- SoapParser.cs
- FastEncoder.cs
- StylesEditorDialog.cs
- ExternalFile.cs
- ZipIOLocalFileHeader.cs
- ImageSource.cs
- MimeMapping.cs
- ExecutedRoutedEventArgs.cs
- HandledMouseEvent.cs
- FtpRequestCacheValidator.cs
- SelectionWordBreaker.cs
- ComboBox.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- MSAANativeProvider.cs
- DefaultAsyncDataDispatcher.cs
- BinaryParser.cs
- TextPointerBase.cs
- SimpleHandlerFactory.cs
- CheckPair.cs
- UnsafeNativeMethods.cs
- MinMaxParagraphWidth.cs
- TdsParameterSetter.cs
- selecteditemcollection.cs
- RevocationPoint.cs
- SafeTokenHandle.cs
- PolyBezierSegmentFigureLogic.cs
- ServiceModelPerformanceCounters.cs
- PixelFormats.cs
- VectorKeyFrameCollection.cs
- TransformConverter.cs
- ComponentResourceManager.cs
- DesignObjectWrapper.cs
- SmtpFailedRecipientException.cs
- WebPartDescriptionCollection.cs