Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / System / Windows / Media / GlyphRunDrawing.cs / 1 / GlyphRunDrawing.cs
//---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: GlyphRunDrawing represents a drawing operation that renders // a GlyphRun. // // History: // // 2004/11/17 : timothyc - Created it. // //--------------------------------------------------------------------------- using System.Diagnostics; namespace System.Windows.Media { ////// GlyphRunDrawing represents a drawing operation that renders a GlyphRun. /// public sealed partial class GlyphRunDrawing : Drawing { #region Constructors ////// Default GlyphRunDrawing constructor. /// Constructs an object with all properties set to their default values /// public GlyphRunDrawing() { } ////// Two-argument GlyphRunDrawing constructor. /// Constructs an object with the GlyphRun and ForegroundBrush properties /// set to the value of their respective arguments. /// public GlyphRunDrawing(Brush foregroundBrush, GlyphRun glyphRun) { GlyphRun = glyphRun; ForegroundBrush = foregroundBrush; } #endregion #region Internal methods ////// Called when an object needs to Update it's realizations. /// Currently, GlyphRun is the only MIL object that needs realization /// updates. /// internal override void UpdateRealizations(RealizationContext realizationContext) { if (RequiresRealizationUpdates) { GlyphRun glyphRun = GlyphRun; Brush foregroundBrush = ForegroundBrush; Debug.Assert(glyphRun != null, "Because the RequriesRealizationUpdates flag is only set if GlyphRun != null."); Debug.Assert(foregroundBrush!= null, "Because the RequiresRealizationUpdates flag is only set if ForegroundBrush != null."); Rect bounds = glyphRun.ComputeInkBoundingBox(); if (!bounds.IsEmpty) { Point baselineOrigin = glyphRun.BaselineOrigin; bounds.X += baselineOrigin.X; bounds.Y += baselineOrigin.Y; foregroundBrush.UpdateRealizations(bounds, realizationContext); } } } ////// Calls methods on the DrawingContext that are equivalent to the /// Drawing with the Drawing's current value. /// internal override void WalkCurrentValue(DrawingContextWalker ctx) { // We avoid unneccessary ShouldStopWalking checks based on assumptions // about when ShouldStopWalking is set. Guard that assumption with an // assertion. See DrawingGroup.WalkCurrentValue comment for more details. Debug.Assert(!ctx.ShouldStopWalking); ctx.DrawGlyphRun( ForegroundBrush, GlyphRun ); } ////// PrecomputeCore for GlyphRuns. /// internal override void PrecomputeCore() { // Reset the flag. RequiresRealizationUpdates = false; // Check if we need to push realization updates into the foreground brush. if (GlyphRun != null) { Brush foregroundBrush = ForegroundBrush; if (foregroundBrush != null) { foregroundBrush.Precompute(); // We require realization no matter what because this is a glyph run // drawing. RequiresRealizationUpdates = true; } } } #endregion Internal methods } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: GlyphRunDrawing represents a drawing operation that renders // a GlyphRun. // // History: // // 2004/11/17 : timothyc - Created it. // //--------------------------------------------------------------------------- using System.Diagnostics; namespace System.Windows.Media { ////// GlyphRunDrawing represents a drawing operation that renders a GlyphRun. /// public sealed partial class GlyphRunDrawing : Drawing { #region Constructors ////// Default GlyphRunDrawing constructor. /// Constructs an object with all properties set to their default values /// public GlyphRunDrawing() { } ////// Two-argument GlyphRunDrawing constructor. /// Constructs an object with the GlyphRun and ForegroundBrush properties /// set to the value of their respective arguments. /// public GlyphRunDrawing(Brush foregroundBrush, GlyphRun glyphRun) { GlyphRun = glyphRun; ForegroundBrush = foregroundBrush; } #endregion #region Internal methods ////// Called when an object needs to Update it's realizations. /// Currently, GlyphRun is the only MIL object that needs realization /// updates. /// internal override void UpdateRealizations(RealizationContext realizationContext) { if (RequiresRealizationUpdates) { GlyphRun glyphRun = GlyphRun; Brush foregroundBrush = ForegroundBrush; Debug.Assert(glyphRun != null, "Because the RequriesRealizationUpdates flag is only set if GlyphRun != null."); Debug.Assert(foregroundBrush!= null, "Because the RequiresRealizationUpdates flag is only set if ForegroundBrush != null."); Rect bounds = glyphRun.ComputeInkBoundingBox(); if (!bounds.IsEmpty) { Point baselineOrigin = glyphRun.BaselineOrigin; bounds.X += baselineOrigin.X; bounds.Y += baselineOrigin.Y; foregroundBrush.UpdateRealizations(bounds, realizationContext); } } } ////// Calls methods on the DrawingContext that are equivalent to the /// Drawing with the Drawing's current value. /// internal override void WalkCurrentValue(DrawingContextWalker ctx) { // We avoid unneccessary ShouldStopWalking checks based on assumptions // about when ShouldStopWalking is set. Guard that assumption with an // assertion. See DrawingGroup.WalkCurrentValue comment for more details. Debug.Assert(!ctx.ShouldStopWalking); ctx.DrawGlyphRun( ForegroundBrush, GlyphRun ); } ////// PrecomputeCore for GlyphRuns. /// internal override void PrecomputeCore() { // Reset the flag. RequiresRealizationUpdates = false; // Check if we need to push realization updates into the foreground brush. if (GlyphRun != null) { Brush foregroundBrush = ForegroundBrush; if (foregroundBrush != null) { foregroundBrush.Precompute(); // We require realization no matter what because this is a glyph run // drawing. RequiresRealizationUpdates = true; } } } #endregion Internal methods } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StreamUpdate.cs
- ServiceDocument.cs
- SqlInternalConnectionSmi.cs
- CfgSemanticTag.cs
- TraceSection.cs
- TCEAdapterGenerator.cs
- ObjectListFieldsPage.cs
- PasswordBox.cs
- LinkClickEvent.cs
- RSAOAEPKeyExchangeDeformatter.cs
- JulianCalendar.cs
- CultureTableRecord.cs
- DataGridViewRowPostPaintEventArgs.cs
- ArraySegment.cs
- ValidationVisibilityAttribute.cs
- TemplatedAdorner.cs
- ConcurrentQueue.cs
- JavaScriptObjectDeserializer.cs
- SettingsPropertyValueCollection.cs
- BaseValidator.cs
- FacetChecker.cs
- MaskedTextProvider.cs
- Point4DConverter.cs
- COM2IVsPerPropertyBrowsingHandler.cs
- ProcessHostServerConfig.cs
- DocumentSequenceHighlightLayer.cs
- ServiceParser.cs
- DataServiceRequest.cs
- CookieProtection.cs
- StringPropertyBuilder.cs
- ParameterCollection.cs
- EventPrivateKey.cs
- TagNameToTypeMapper.cs
- ObjectAssociationEndMapping.cs
- EntityReference.cs
- FormViewPageEventArgs.cs
- DocumentPageHost.cs
- DataBindingExpressionBuilder.cs
- ItemDragEvent.cs
- XamlTypeMapper.cs
- TextTreeInsertElementUndoUnit.cs
- ChannelServices.cs
- DownloadProgressEventArgs.cs
- ContextMenu.cs
- SqlIdentifier.cs
- FixedPageProcessor.cs
- PipeSecurity.cs
- WebServiceMethodData.cs
- AssemblyBuilderData.cs
- WebEncodingValidator.cs
- Empty.cs
- AspCompat.cs
- HwndMouseInputProvider.cs
- EncryptedHeaderXml.cs
- SafeNativeMemoryHandle.cs
- MonthChangedEventArgs.cs
- Grant.cs
- RegexParser.cs
- CategoryGridEntry.cs
- DBConnectionString.cs
- IncrementalCompileAnalyzer.cs
- ItemsPresenter.cs
- ContextMenu.cs
- DynamicILGenerator.cs
- ReadOnlyDictionary.cs
- ExpressionNode.cs
- Win32PrintDialog.cs
- EntityProviderServices.cs
- Rotation3DAnimation.cs
- Convert.cs
- TypeHelpers.cs
- RenderDataDrawingContext.cs
- BufferedReceiveElement.cs
- SamlSubjectStatement.cs
- FontConverter.cs
- FrameworkContextData.cs
- AssemblyGen.cs
- CreateUserWizard.cs
- NumericExpr.cs
- _TransmitFileOverlappedAsyncResult.cs
- Command.cs
- RectAnimationClockResource.cs
- DesignerActionPanel.cs
- IntSecurity.cs
- SessionSwitchEventArgs.cs
- BinaryHeap.cs
- PointCollectionConverter.cs
- MulticastIPAddressInformationCollection.cs
- NamedPipeConnectionPoolSettingsElement.cs
- InvalidComObjectException.cs
- KeySpline.cs
- WsdlInspector.cs
- DetailsViewRow.cs
- PolicyManager.cs
- ProcessMessagesAsyncResult.cs
- XmlIlGenerator.cs
- XPathNodePointer.cs
- BaseContextMenu.cs
- InterleavedZipPartStream.cs
- ImageCreator.cs