Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / SizeChangedEventArgs.cs / 1305600 / SizeChangedEventArgs.cs
using System; namespace System.Windows { ////// The SizeChangedEventArgs class is used by SizeChangedEventHandler. /// This handler is used for ComputedWidthChanged and ComputedHeightChanged events /// on UIElement. /// public class SizeChangedEventArgs : RoutedEventArgs { ////// Initializes a new instance of the SizeChangedEventArgs class. /// /// /// The UIElement which has its size changed by layout engine/>. /// /// /// The SizeChangeInfo that is used by. /// internal SizeChangedEventArgs(UIElement element, SizeChangedInfo info) { if (info == null) { throw new ArgumentNullException("info"); } if (element == null) { throw new ArgumentNullException("element"); } _element = element; _previousSize = info.PreviousSize; if(info.WidthChanged) _bits |= _widthChangedBit; if(info.HeightChanged) _bits |= _heightChangedBit; } /// /// Read-only access to the previous Size /// public Size PreviousSize { get { return _previousSize; } } ////// Read-only access to the new Size /// public Size NewSize { get { return _element.RenderSize; } } ////// Read-only access to the flag indicating that Width component of the size changed. /// Note that due to double math /// effects, the it may be (previousSize.Width != newSize.Width) and widthChanged = true. /// This may happen in layout when sizes of objects are fluctuating because of a precision "jitter" of /// the input parameters, but the overall scene is considered to be "the same" so no visible changes /// will be detected. Typically, the handler of SizeChangedEvent should check this bit to avoid /// invalidation of layout if the dimension didn't change. /// public bool WidthChanged { get { return ((_bits & _widthChangedBit) != 0); } } ////// Read-only access to the flag indicating that Height component of the size changed. /// Note that due to double math /// effects, the it may be (previousSize.Height != newSize.Height) and heightChanged = true. /// This may happen in layout when sizes of objects are fluctuating because of a precision "jitter" of /// the input parameters, but the overall scene is considered to be "the same" so no visible changes /// will be detected. Typically, the handler of SizeChangedEvent should check this bit to avoid /// invalidation of layout if the dimension didn't change. /// public bool HeightChanged { get { return ((_bits & _heightChangedBit) != 0); } } private Size _previousSize; private UIElement _element; private byte _bits; private static byte _widthChangedBit = 0x1; private static byte _heightChangedBit = 0x2; ////// The mechanism used to call the type-specific handler on the /// target. /// /// /// The generic handler to call in a type-specific way. /// /// /// The target to call the handler on. /// ///protected override void InvokeEventHandler(Delegate genericHandler, object genericTarget) { SizeChangedEventHandler handler = (SizeChangedEventHandler) genericHandler; handler(genericTarget, this); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; namespace System.Windows { /// /// The SizeChangedEventArgs class is used by SizeChangedEventHandler. /// This handler is used for ComputedWidthChanged and ComputedHeightChanged events /// on UIElement. /// public class SizeChangedEventArgs : RoutedEventArgs { ////// Initializes a new instance of the SizeChangedEventArgs class. /// /// /// The UIElement which has its size changed by layout engine/>. /// /// /// The SizeChangeInfo that is used by. /// internal SizeChangedEventArgs(UIElement element, SizeChangedInfo info) { if (info == null) { throw new ArgumentNullException("info"); } if (element == null) { throw new ArgumentNullException("element"); } _element = element; _previousSize = info.PreviousSize; if(info.WidthChanged) _bits |= _widthChangedBit; if(info.HeightChanged) _bits |= _heightChangedBit; } /// /// Read-only access to the previous Size /// public Size PreviousSize { get { return _previousSize; } } ////// Read-only access to the new Size /// public Size NewSize { get { return _element.RenderSize; } } ////// Read-only access to the flag indicating that Width component of the size changed. /// Note that due to double math /// effects, the it may be (previousSize.Width != newSize.Width) and widthChanged = true. /// This may happen in layout when sizes of objects are fluctuating because of a precision "jitter" of /// the input parameters, but the overall scene is considered to be "the same" so no visible changes /// will be detected. Typically, the handler of SizeChangedEvent should check this bit to avoid /// invalidation of layout if the dimension didn't change. /// public bool WidthChanged { get { return ((_bits & _widthChangedBit) != 0); } } ////// Read-only access to the flag indicating that Height component of the size changed. /// Note that due to double math /// effects, the it may be (previousSize.Height != newSize.Height) and heightChanged = true. /// This may happen in layout when sizes of objects are fluctuating because of a precision "jitter" of /// the input parameters, but the overall scene is considered to be "the same" so no visible changes /// will be detected. Typically, the handler of SizeChangedEvent should check this bit to avoid /// invalidation of layout if the dimension didn't change. /// public bool HeightChanged { get { return ((_bits & _heightChangedBit) != 0); } } private Size _previousSize; private UIElement _element; private byte _bits; private static byte _widthChangedBit = 0x1; private static byte _heightChangedBit = 0x2; ////// The mechanism used to call the type-specific handler on the /// target. /// /// /// The generic handler to call in a type-specific way. /// /// /// The target to call the handler on. /// ///protected override void InvokeEventHandler(Delegate genericHandler, object genericTarget) { SizeChangedEventHandler handler = (SizeChangedEventHandler) genericHandler; handler(genericTarget, this); } } } // 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
- ValidationPropertyAttribute.cs
- SignedPkcs7.cs
- FrameworkElement.cs
- BindingMemberInfo.cs
- KeyedCollection.cs
- CodeSnippetExpression.cs
- EmptyEnumerable.cs
- CodeIndexerExpression.cs
- FixedPageAutomationPeer.cs
- AddingNewEventArgs.cs
- ResXResourceWriter.cs
- RequestQueue.cs
- ArrangedElementCollection.cs
- QilBinary.cs
- EncryptedReference.cs
- Line.cs
- SqlBooleanMismatchVisitor.cs
- ExecutionContext.cs
- RequestCachingSection.cs
- KeyGestureValueSerializer.cs
- SelectionItemPattern.cs
- NumericExpr.cs
- DataServiceKeyAttribute.cs
- UIPermission.cs
- PasswordBoxAutomationPeer.cs
- ActivationProxy.cs
- AssemblyContextControlItem.cs
- StylusPointPropertyId.cs
- InputMethodStateTypeInfo.cs
- QueryResultOp.cs
- AssemblyResourceLoader.cs
- UICuesEvent.cs
- NegotiationTokenAuthenticatorStateCache.cs
- DataContract.cs
- ClientCultureInfo.cs
- handlecollector.cs
- ToolStripRenderEventArgs.cs
- TopClause.cs
- BindingListCollectionView.cs
- PropertyMetadata.cs
- _SslState.cs
- MenuItemBinding.cs
- ClientSettingsSection.cs
- Parameter.cs
- VoiceChangeEventArgs.cs
- StringFunctions.cs
- TableLayoutSettingsTypeConverter.cs
- SQLDecimal.cs
- BitStack.cs
- ColumnMap.cs
- DatagridviewDisplayedBandsData.cs
- ThreadExceptionEvent.cs
- WebPartConnection.cs
- QueryExpression.cs
- IndexOutOfRangeException.cs
- SessionSwitchEventArgs.cs
- Convert.cs
- CompressStream.cs
- StringPropertyBuilder.cs
- WebEncodingValidatorAttribute.cs
- PropertyContainer.cs
- EnglishPluralizationService.cs
- SqlGatherProducedAliases.cs
- DataSpaceManager.cs
- FrameDimension.cs
- ErrorRuntimeConfig.cs
- control.ime.cs
- SmiTypedGetterSetter.cs
- TagPrefixAttribute.cs
- TabControl.cs
- DataServices.cs
- ContentElementAutomationPeer.cs
- RayHitTestParameters.cs
- ColumnHeader.cs
- IUnknownConstantAttribute.cs
- BindingNavigator.cs
- TransactionFlowBindingElementImporter.cs
- WhileDesigner.cs
- ExceptQueryOperator.cs
- ImpersonateTokenRef.cs
- LinkArea.cs
- XmlSchemaObject.cs
- TransactionScopeDesigner.cs
- DbgUtil.cs
- ProcessModuleCollection.cs
- _ContextAwareResult.cs
- ControlBuilderAttribute.cs
- DataServiceContext.cs
- RoutedEventHandlerInfo.cs
- ImageClickEventArgs.cs
- UniqueIdentifierService.cs
- IisTraceListener.cs
- DocumentViewerBaseAutomationPeer.cs
- PenContext.cs
- VisualStyleElement.cs
- TrustManager.cs
- PropertySegmentSerializer.cs
- ExpressionNode.cs
- DataKey.cs
- FontEmbeddingManager.cs