Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / DrawingServices.cs / 1305600 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Section.cs
- IsolationInterop.cs
- Primitive.cs
- LicFileLicenseProvider.cs
- DateTimeFormatInfoScanner.cs
- SafeRightsManagementHandle.cs
- ParserExtension.cs
- ComboBoxRenderer.cs
- PrintPageEvent.cs
- TemplateXamlParser.cs
- MetadataWorkspace.cs
- Stream.cs
- Lazy.cs
- UnsafeMethods.cs
- SqlGatherProducedAliases.cs
- Formatter.cs
- UrlMappingsSection.cs
- MetadataItemEmitter.cs
- WebDescriptionAttribute.cs
- UnauthorizedAccessException.cs
- MediaScriptCommandRoutedEventArgs.cs
- TreeWalkHelper.cs
- ApplyTemplatesAction.cs
- EntityProviderFactory.cs
- NullToBooleanConverter.cs
- MissingManifestResourceException.cs
- Error.cs
- StrokeNode.cs
- FilteredAttributeCollection.cs
- EncoderBestFitFallback.cs
- TextSpanModifier.cs
- FormViewUpdateEventArgs.cs
- NullableLongAverageAggregationOperator.cs
- ZipPackagePart.cs
- HtmlInputControl.cs
- LogStream.cs
- serverconfig.cs
- PipelineModuleStepContainer.cs
- Thread.cs
- ActivityTypeCodeDomSerializer.cs
- ResourceExpressionEditorSheet.cs
- StylusEventArgs.cs
- EntityContainerEntitySet.cs
- HttpClientChannel.cs
- Page.cs
- DocumentViewer.cs
- PropagatorResult.cs
- PopupRootAutomationPeer.cs
- DataMisalignedException.cs
- Label.cs
- dbdatarecord.cs
- BindingListCollectionView.cs
- Calendar.cs
- EventWaitHandleSecurity.cs
- ComponentConverter.cs
- Drawing.cs
- ReadOnlyCollection.cs
- TypeElementCollection.cs
- followingquery.cs
- SymbolUsageManager.cs
- ContextInformation.cs
- BufferedGraphics.cs
- ResourcePermissionBase.cs
- SapiGrammar.cs
- HostingEnvironmentWrapper.cs
- UnmanagedMarshal.cs
- CompiledRegexRunnerFactory.cs
- GroupDescription.cs
- FilterInvalidBodyAccessException.cs
- StandardCommands.cs
- BrowserCapabilitiesCompiler.cs
- XsltFunctions.cs
- MenuItemBinding.cs
- CodeAttachEventStatement.cs
- StylusPlugin.cs
- ListViewDataItem.cs
- BulletedList.cs
- AnnotationAuthorChangedEventArgs.cs
- ObjRef.cs
- RuntimeEnvironment.cs
- DateTimeOffset.cs
- CaseStatement.cs
- PropertyCollection.cs
- ListItemConverter.cs
- DataGridViewCellValidatingEventArgs.cs
- EdmToObjectNamespaceMap.cs
- SrgsElement.cs
- UnrecognizedPolicyAssertionElement.cs
- DbConvert.cs
- BinaryFormatterWriter.cs
- DragAssistanceManager.cs
- SqlDeflator.cs
- SqlProviderUtilities.cs
- ContainerUIElement3D.cs
- WeakEventManager.cs
- ProtocolViolationException.cs
- PaintValueEventArgs.cs
- WpfXamlMember.cs
- GregorianCalendar.cs
- CodePrimitiveExpression.cs