Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- LateBoundBitmapDecoder.cs
- DataColumnMapping.cs
- CurrencyWrapper.cs
- BrowserCapabilitiesFactoryBase.cs
- ValueHandle.cs
- SystemIcmpV4Statistics.cs
- MetabaseSettingsIis7.cs
- DescendantQuery.cs
- StringSource.cs
- SerializationEventsCache.cs
- PathParser.cs
- ScalarOps.cs
- ReaderOutput.cs
- Border.cs
- WebRequestModuleElementCollection.cs
- XPathCompileException.cs
- SourceElementsCollection.cs
- LinkDesigner.cs
- EntityDataSource.cs
- BStrWrapper.cs
- NullableConverter.cs
- JoinTreeNode.cs
- SchemaImporterExtension.cs
- CategoriesDocumentFormatter.cs
- AudioStateChangedEventArgs.cs
- CharacterBuffer.cs
- ComponentEditorPage.cs
- AggregateNode.cs
- XsdDataContractExporter.cs
- TdsParserStaticMethods.cs
- WebServiceBindingAttribute.cs
- Thumb.cs
- GenerateHelper.cs
- GenericWebPart.cs
- CqlIdentifiers.cs
- HtmlContainerControl.cs
- GcHandle.cs
- CfgParser.cs
- XhtmlBasicLabelAdapter.cs
- LocatorPart.cs
- EraserBehavior.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- HwndSourceParameters.cs
- HtmlToClrEventProxy.cs
- PreApplicationStartMethodAttribute.cs
- SequentialOutput.cs
- ContentType.cs
- ColumnWidthChangingEvent.cs
- ComPlusServiceLoader.cs
- ScrollProviderWrapper.cs
- HttpHostedTransportConfiguration.cs
- XmlSchemaObject.cs
- CompoundFileDeflateTransform.cs
- SequentialOutput.cs
- HtmlImageAdapter.cs
- FormViewModeEventArgs.cs
- MetadataSerializer.cs
- TypeBuilderInstantiation.cs
- cookie.cs
- TreeNodeBindingCollection.cs
- SqlDataSourceCache.cs
- ResourceDefaultValueAttribute.cs
- Help.cs
- IDQuery.cs
- DetailsViewInsertedEventArgs.cs
- Matrix3DValueSerializer.cs
- FocusManager.cs
- TraceUtils.cs
- MetadataProperty.cs
- GroupBox.cs
- BinaryMethodMessage.cs
- HttpsTransportElement.cs
- WebScriptMetadataFormatter.cs
- HtmlInputText.cs
- CollectionChangeEventArgs.cs
- ExceptionAggregator.cs
- Hash.cs
- VerifyHashRequest.cs
- String.cs
- ScriptManagerProxy.cs
- PKCS1MaskGenerationMethod.cs
- DictionaryManager.cs
- SerializationInfoEnumerator.cs
- TextEndOfParagraph.cs
- contentDescriptor.cs
- SvcMapFile.cs
- HandlerWithFactory.cs
- ScrollViewer.cs
- DefaultWorkflowLoaderService.cs
- RuntimeCompatibilityAttribute.cs
- basevalidator.cs
- ToolStripDropDownItemDesigner.cs
- ServerValidateEventArgs.cs
- Positioning.cs
- Events.cs
- CatalogZone.cs
- WebMessageEncodingBindingElement.cs
- PersonalizationDictionary.cs
- NavigationWindowAutomationPeer.cs
- DataGridViewToolTip.cs