Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / System / Windows / Media / DrawingServices.cs / 1 / DrawingServices.cs
//---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: Implements services for Drawings including walking, bounding, // and hit-testing. // // History: // // 2004/11/19 : timothyc - Created it. // //--------------------------------------------------------------------------- using System.Diagnostics; using System.Windows.Media.Animation; namespace System.Windows.Media { ////// Implements services for Drawings including walking, bounding, and /// hit-testing. /// internal static class DrawingServices { ////// Determines whether or not a point exists in a Drawing /// /// Drawing to hit-test /// Point to hit-test for ////// 'true' if the point exists within the drawing, 'false' otherwise /// internal static bool HitTestPoint(Drawing drawing, Point point) { if (drawing != null) { HitTestDrawingContextWalker ctx = new HitTestWithPointDrawingContextWalker(point); drawing.WalkCurrentValue(ctx); return ctx.IsHit; } else { return false; } } ////// Hit-tests a Drawing against a PathGeometry /// /// The drawing to hit test against /// The geometry (in local coordinate space) to hit test. ////// IntersectionDetail that describes the hit result /// internal static IntersectionDetail HitTestGeometry(Drawing drawing, PathGeometry geometry) { if (drawing != null) { HitTestDrawingContextWalker ctx = new HitTestWithGeometryDrawingContextWalker(geometry); drawing.WalkCurrentValue(ctx); return ctx.IntersectionDetail; } else { return IntersectionDetail.Empty; } } ////// Converts a RenderData content representation into a DrawingGroup /// content representation. /// /// The RenderData to convert ////// A new DrawingGroup representation that is functionally equivalent to the /// passed-in RenderData. /// internal static DrawingGroup DrawingGroupFromRenderData(RenderData renderData) { // // Create & open a new DrawingGroup // DrawingGroup drawingGroup = new DrawingGroup(); DrawingContext dc = drawingGroup.Open(); // // Create a DrawingGroup from the RenderData by walking // the RenderData & having it forward it's base value's // and animations to DrawingGroup // // // The Drawing tree we're about to produce should not be an inheritance context, // since that would place all mutable Freezables in the render data into shared // state, which would in turn case them to lose their inheritance context entirely. // This is controlled by setting "CanBeInheritanceContext" to false on the // DrawingContext which will then be applied to all new objects it creates. // DrawingDrawingContext ddc = dc as DrawingDrawingContext; if (ddc != null) { ddc.CanBeInheritanceContext = false; } DrawingContextDrawingContextWalker walker = new DrawingContextDrawingContextWalker(dc); renderData.BaseValueDrawingContextWalk(walker); // // Close the DrawingContext & return the new DrawingGroup // dc.Close(); return drawingGroup; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: Implements services for Drawings including walking, bounding, // and hit-testing. // // History: // // 2004/11/19 : timothyc - Created it. // //--------------------------------------------------------------------------- using System.Diagnostics; using System.Windows.Media.Animation; namespace System.Windows.Media { ////// Implements services for Drawings including walking, bounding, and /// hit-testing. /// internal static class DrawingServices { ////// Determines whether or not a point exists in a Drawing /// /// Drawing to hit-test /// Point to hit-test for ////// 'true' if the point exists within the drawing, 'false' otherwise /// internal static bool HitTestPoint(Drawing drawing, Point point) { if (drawing != null) { HitTestDrawingContextWalker ctx = new HitTestWithPointDrawingContextWalker(point); drawing.WalkCurrentValue(ctx); return ctx.IsHit; } else { return false; } } ////// Hit-tests a Drawing against a PathGeometry /// /// The drawing to hit test against /// The geometry (in local coordinate space) to hit test. ////// IntersectionDetail that describes the hit result /// internal static IntersectionDetail HitTestGeometry(Drawing drawing, PathGeometry geometry) { if (drawing != null) { HitTestDrawingContextWalker ctx = new HitTestWithGeometryDrawingContextWalker(geometry); drawing.WalkCurrentValue(ctx); return ctx.IntersectionDetail; } else { return IntersectionDetail.Empty; } } ////// Converts a RenderData content representation into a DrawingGroup /// content representation. /// /// The RenderData to convert ////// A new DrawingGroup representation that is functionally equivalent to the /// passed-in RenderData. /// internal static DrawingGroup DrawingGroupFromRenderData(RenderData renderData) { // // Create & open a new DrawingGroup // DrawingGroup drawingGroup = new DrawingGroup(); DrawingContext dc = drawingGroup.Open(); // // Create a DrawingGroup from the RenderData by walking // the RenderData & having it forward it's base value's // and animations to DrawingGroup // // // The Drawing tree we're about to produce should not be an inheritance context, // since that would place all mutable Freezables in the render data into shared // state, which would in turn case them to lose their inheritance context entirely. // This is controlled by setting "CanBeInheritanceContext" to false on the // DrawingContext which will then be applied to all new objects it creates. // DrawingDrawingContext ddc = dc as DrawingDrawingContext; if (ddc != null) { ddc.CanBeInheritanceContext = false; } DrawingContextDrawingContextWalker walker = new DrawingContextDrawingContextWalker(dc); renderData.BaseValueDrawingContextWalk(walker); // // Close the DrawingContext & return the new DrawingGroup // dc.Close(); return drawingGroup; } } } // 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
- SimpleBitVector32.cs
- AlternateView.cs
- CustomErrorCollection.cs
- FontDifferentiator.cs
- RemoteWebConfigurationHostStream.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- XmlTypeMapping.cs
- SpellerStatusTable.cs
- WithParamAction.cs
- TableRowCollection.cs
- PrivilegedConfigurationManager.cs
- ParameterCollection.cs
- InvalidOperationException.cs
- SliderAutomationPeer.cs
- FileDialogCustomPlacesCollection.cs
- baseaxisquery.cs
- isolationinterop.cs
- ControlBuilder.cs
- SqlBuilder.cs
- XmlSchemaException.cs
- GroupAggregateExpr.cs
- SchemaTypeEmitter.cs
- XmlSchemaObject.cs
- SessionSwitchEventArgs.cs
- ImageListUtils.cs
- sqlnorm.cs
- MulticastOption.cs
- IdentityReference.cs
- RowsCopiedEventArgs.cs
- RenderContext.cs
- DataGridTablesFactory.cs
- RangeValuePattern.cs
- BookmarkScopeHandle.cs
- GenericXmlSecurityTokenAuthenticator.cs
- SystemDropShadowChrome.cs
- ProgressBar.cs
- listitem.cs
- ExcludePathInfo.cs
- ThousandthOfEmRealDoubles.cs
- CellTreeNodeVisitors.cs
- DocumentPaginator.cs
- DBDataPermission.cs
- NestPullup.cs
- AnimationStorage.cs
- FacetValueContainer.cs
- DecodeHelper.cs
- And.cs
- TransactionFlowOption.cs
- KnownTypes.cs
- CopyCodeAction.cs
- WebServiceParameterData.cs
- Vector3DCollection.cs
- OutputCacheProfileCollection.cs
- UnionCqlBlock.cs
- TextEditorContextMenu.cs
- AccessKeyManager.cs
- cookiecontainer.cs
- HighContrastHelper.cs
- CollectionViewProxy.cs
- DirectoryRedirect.cs
- TreeNode.cs
- PasswordTextContainer.cs
- CodeDomComponentSerializationService.cs
- EventDescriptor.cs
- RequestSecurityToken.cs
- nulltextnavigator.cs
- XmlProcessingInstruction.cs
- MatrixCamera.cs
- AuthenticationSection.cs
- AttributeCollection.cs
- PrimitiveXmlSerializers.cs
- EdmEntityTypeAttribute.cs
- ConnectionProviderAttribute.cs
- Cursor.cs
- EntityDesignerUtils.cs
- XmlTypeMapping.cs
- DataControlImageButton.cs
- CodeMemberMethod.cs
- UserControl.cs
- CodeAccessSecurityEngine.cs
- ResourceReferenceExpressionConverter.cs
- SmiGettersStream.cs
- MeasureData.cs
- ToolStripSplitStackLayout.cs
- HtmlForm.cs
- DocumentViewerConstants.cs
- BindingOperations.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- Renderer.cs
- CharAnimationUsingKeyFrames.cs
- JumpTask.cs
- indexingfiltermarshaler.cs
- FileLoadException.cs
- IChannel.cs
- MILUtilities.cs
- QilExpression.cs
- Column.cs
- AsyncInvokeOperation.cs
- CacheEntry.cs
- SqlFacetAttribute.cs