Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / MS / Internal / Ink / DrawingAttributesDefaultValueFactory.cs / 1 / DrawingAttributesDefaultValueFactory.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: DefaultValueFactory for DrawingAttributes // // History: // 2005/11/08 : [....] - Created // //--------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; using System.Windows.Controls; using System.Windows.Ink; namespace MS.Internal.Ink { internal class DrawingAttributesDefaultValueFactory : DefaultValueFactory { internal DrawingAttributesDefaultValueFactory() { } ////// Returns an "immutable" default value. Since we can't make the default value /// read only we'll return a new one every time. /// internal override object DefaultValue { get { return new DrawingAttributes(); } } ////// Creates a mutable default value /// internal override object CreateDefaultValue(DependencyObject owner, DependencyProperty property) { // Instantiate our default value instance. DrawingAttributes defaultValue = new DrawingAttributes(); // Add event handlers for tracking the changes on the default value instance. DrawingAttributesDefaultPromoter promoter = new DrawingAttributesDefaultPromoter((InkCanvas)owner); defaultValue.AttributeChanged += new PropertyDataChangedEventHandler(promoter.OnDrawingAttributesChanged); defaultValue.PropertyDataChanged += new PropertyDataChangedEventHandler(promoter.OnDrawingAttributesChanged); return defaultValue; } ////// A tracking class which monitors the sub-property changes on DrawingAttributes /// private class DrawingAttributesDefaultPromoter { ////// Constructor /// /// internal DrawingAttributesDefaultPromoter(InkCanvas owner) { _owner = owner; } ////// A handler for both AttributeChanged and PropertyDataChanged. /// /// /// internal void OnDrawingAttributesChanged(object sender, PropertyDataChangedEventArgs e) { DrawingAttributes value = (DrawingAttributes)sender; // The current instance will be promoted to the local value other than the default value. // Then we could just remove our handlers to stop tracking. value.AttributeChanged -= new PropertyDataChangedEventHandler(OnDrawingAttributesChanged); value.PropertyDataChanged -= new PropertyDataChangedEventHandler(OnDrawingAttributesChanged); // if (_owner.ReadLocalValue(InkCanvas.DefaultDrawingAttributesProperty) == DependencyProperty.UnsetValue) { // Promote the instance to the local value. _owner.SetValue(InkCanvas.DefaultDrawingAttributesProperty, value); } // Remove this value from the DefaultValue cache so we stop // handing it out as the default value now that it has changed. PropertyMetadata metadata = InkCanvas.DefaultDrawingAttributesProperty.GetMetadata(_owner.DependencyObjectType); metadata.ClearCachedDefaultValue(_owner, InkCanvas.DefaultDrawingAttributesProperty); } private readonly InkCanvas _owner; } } } // 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
- AbstractExpressions.cs
- UnrecognizedPolicyAssertionElement.cs
- CqlLexerHelpers.cs
- ViewgenContext.cs
- UnmanagedMemoryStream.cs
- PolyQuadraticBezierSegment.cs
- initElementDictionary.cs
- Workspace.cs
- ArcSegment.cs
- ListViewGroupItemCollection.cs
- PassportIdentity.cs
- PropertySourceInfo.cs
- SettingsPropertyWrongTypeException.cs
- HitTestDrawingContextWalker.cs
- MessageAction.cs
- CommonDialog.cs
- IntSecurity.cs
- LogWriteRestartAreaAsyncResult.cs
- FastEncoderWindow.cs
- ScrollProperties.cs
- TimelineClockCollection.cs
- Single.cs
- Light.cs
- Menu.cs
- ScriptControlManager.cs
- XmlSchemaComplexContentExtension.cs
- login.cs
- ShaperBuffers.cs
- CookieProtection.cs
- EntityDataSourceState.cs
- UIHelper.cs
- ScrollItemPattern.cs
- InvalidDataException.cs
- indexingfiltermarshaler.cs
- HealthMonitoringSectionHelper.cs
- TabletCollection.cs
- DescendantQuery.cs
- MarkupExtensionReturnTypeAttribute.cs
- StateMachineHelpers.cs
- ListBox.cs
- CqlWriter.cs
- CalendarData.cs
- Matrix3D.cs
- EllipticalNodeOperations.cs
- initElementDictionary.cs
- CodeSnippetCompileUnit.cs
- PropertyGeneratedEventArgs.cs
- TextTreeNode.cs
- ComplexTypeEmitter.cs
- EventEntry.cs
- ProfileGroupSettingsCollection.cs
- SelectedGridItemChangedEvent.cs
- WinEventQueueItem.cs
- MetafileHeader.cs
- TableDesigner.cs
- WmlFormAdapter.cs
- ConnectionPointCookie.cs
- SystemEvents.cs
- ReferencedType.cs
- PassportAuthenticationEventArgs.cs
- TransportConfigurationTypeElement.cs
- ContextDataSourceView.cs
- Hex.cs
- Region.cs
- TraceAsyncResult.cs
- ItemCheckEvent.cs
- HtmlInputCheckBox.cs
- PngBitmapDecoder.cs
- ImmComposition.cs
- CheckableControlBaseAdapter.cs
- IndentedWriter.cs
- DashStyle.cs
- GradientStopCollection.cs
- PrintDocument.cs
- Restrictions.cs
- SoapBinding.cs
- ModelPropertyCollectionImpl.cs
- Component.cs
- QualificationDataAttribute.cs
- SemanticBasicElement.cs
- RegexGroupCollection.cs
- XmlSchemaGroupRef.cs
- ReplyChannel.cs
- UInt64Storage.cs
- BitmapEffectGeneralTransform.cs
- VerticalAlignConverter.cs
- FixUpCollection.cs
- TextEndOfSegment.cs
- InvalidProgramException.cs
- ConfigViewGenerator.cs
- UnmanagedMemoryStreamWrapper.cs
- ProcessHostServerConfig.cs
- EntityStoreSchemaGenerator.cs
- _DisconnectOverlappedAsyncResult.cs
- TextPenaltyModule.cs
- CompositeCollectionView.cs
- HttpRequestWrapper.cs
- AuthenticationManager.cs
- BrowserCapabilitiesFactoryBase.cs
- UrlMappingsModule.cs