Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- InvokeGenerator.cs
- TextEditorCopyPaste.cs
- StringFreezingAttribute.cs
- InternalRelationshipCollection.cs
- XMLUtil.cs
- ToolStripPanelDesigner.cs
- ListViewGroupItemCollection.cs
- ComponentManagerBroker.cs
- XComponentModel.cs
- LookupNode.cs
- Thickness.cs
- GridViewDeletedEventArgs.cs
- ExtendedPropertiesHandler.cs
- Bitmap.cs
- ConfigDefinitionUpdates.cs
- VisualBasicValue.cs
- SafeReversePInvokeHandle.cs
- SrgsRuleRef.cs
- BrowserCapabilitiesFactory.cs
- DataSourceHelper.cs
- PathSegment.cs
- ConfigurationException.cs
- Journal.cs
- PackUriHelper.cs
- ClonableStack.cs
- CompatibleIComparer.cs
- IPipelineRuntime.cs
- HtmlInputCheckBox.cs
- AccessControlEntry.cs
- ExternalException.cs
- CodeChecksumPragma.cs
- DataGridAutomationPeer.cs
- TextTreeUndoUnit.cs
- CombinedGeometry.cs
- PathFigureCollection.cs
- RoutedEvent.cs
- Visual3D.cs
- DomNameTable.cs
- MdImport.cs
- ReferencedCollectionType.cs
- DockAndAnchorLayout.cs
- FixUpCollection.cs
- WsdlImporterElementCollection.cs
- ClientTarget.cs
- UnicodeEncoding.cs
- WebPartDisplayModeCollection.cs
- WorkflowRuntimeSection.cs
- ConfigXmlElement.cs
- Rfc2898DeriveBytes.cs
- NameSpaceExtractor.cs
- QueryCreatedEventArgs.cs
- BinaryParser.cs
- ObjectParameter.cs
- ChangeProcessor.cs
- CultureSpecificCharacterBufferRange.cs
- AesManaged.cs
- OdbcConnectionString.cs
- DynamicRendererThreadManager.cs
- TouchPoint.cs
- WhitespaceRuleReader.cs
- AssemblyLoader.cs
- SpecialNameAttribute.cs
- XmlEncoding.cs
- WhiteSpaceTrimStringConverter.cs
- ScriptDescriptor.cs
- dtdvalidator.cs
- RightsManagementEncryptionTransform.cs
- EntityContainer.cs
- IPGlobalProperties.cs
- GatewayIPAddressInformationCollection.cs
- PresentationAppDomainManager.cs
- CLSCompliantAttribute.cs
- DataListItemEventArgs.cs
- DeadCharTextComposition.cs
- Rect.cs
- OutOfProcStateClientManager.cs
- SystemPens.cs
- DesignTableCollection.cs
- WebConfigurationManager.cs
- RuntimeResourceSet.cs
- mediaeventshelper.cs
- ModelItemExtensions.cs
- LocalizationComments.cs
- CapacityStreamGeometryContext.cs
- WindowsGraphics.cs
- SoapElementAttribute.cs
- XmlIncludeAttribute.cs
- PrintDialogException.cs
- StatusBarItemAutomationPeer.cs
- AstNode.cs
- PropertyKey.cs
- validationstate.cs
- ZoneButton.cs
- EndpointIdentity.cs
- Semaphore.cs
- SqlBulkCopyColumnMapping.cs
- BlurEffect.cs
- ISCIIEncoding.cs
- COMException.cs
- WebPartTransformer.cs