private void CloneVisualTree(ContainerVisual parent, Visual old) { DrawingVisual visual = new DrawingVisual(); parent.Children.Add(visual); visual.Clip = VisualTreeHelper.GetClip(old); visual.Offset = VisualTreeHelper.GetOffset(old); visual.Transform = VisualTreeHelper.GetTransform(old); visual.Opacity = VisualTreeHelper.GetOpacity(old); visual.OpacityMask = VisualTreeHelper.GetOpacityMask(old); #pragma warning disable 0618 visual.BitmapEffectInput = VisualTreeHelper.GetBitmapEffectInput(old); visual.BitmapEffect = VisualTreeHelper.GetBitmapEffect(old); #pragma warning restore 0618 // snapping guidelines?? DrawingContext dc = visual.RenderOpen(); dc.DrawDrawing(old.GetDrawing()); dc.Close(); int count = VisualTreeHelper.GetChildrenCount(old); for (int i = 0; i < count; i++) { Visual child = old.InternalGetVisualChild(i); CloneVisualTree(visual, child); } }
private static DrawingGroup WalkVisual(Visual visual) { DrawingGroup vd = VisualTreeHelper.GetDrawing(visual); BitmapEffect be = VisualTreeHelper.GetBitmapEffect(visual); BitmapEffectInput bei = VisualTreeHelper.GetBitmapEffectInput(visual); Geometry cg = VisualTreeHelper.GetClip(visual); double op = VisualTreeHelper.GetOpacity(visual); Brush om = VisualTreeHelper.GetOpacityMask(visual); GuidelineSet? gs = GetGuidelines(visual); Transform? tx = GetTransform(visual); DrawingGroup?dg = null; if (be is null && cg is null && om is null && gs is null && tx is null && IsZero(op - 1)) { dg = vd ?? new DrawingGroup(); }
// Token: 0x0600350C RID: 13580 RVA: 0x000F0390 File Offset: 0x000EE590 private void CloneVisualTree(ContainerVisual parent, Visual old) { DrawingVisual drawingVisual = new DrawingVisual(); parent.Children.Add(drawingVisual); drawingVisual.Clip = VisualTreeHelper.GetClip(old); drawingVisual.Offset = VisualTreeHelper.GetOffset(old); drawingVisual.Transform = VisualTreeHelper.GetTransform(old); drawingVisual.Opacity = VisualTreeHelper.GetOpacity(old); drawingVisual.OpacityMask = VisualTreeHelper.GetOpacityMask(old); drawingVisual.BitmapEffectInput = VisualTreeHelper.GetBitmapEffectInput(old); drawingVisual.BitmapEffect = VisualTreeHelper.GetBitmapEffect(old); DrawingContext drawingContext = drawingVisual.RenderOpen(); drawingContext.DrawDrawing(old.GetDrawing()); drawingContext.Close(); int childrenCount = VisualTreeHelper.GetChildrenCount(old); for (int i = 0; i < childrenCount; i++) { Visual old2 = old.InternalGetVisualChild(i); this.CloneVisualTree(drawingVisual, old2); } }
static DrawingGroup WalkVisual(Visual visual) { var vd = VisualTreeHelper.GetDrawing(visual); var be = VisualTreeHelper.GetBitmapEffect(visual); var bei = VisualTreeHelper.GetBitmapEffectInput(visual); var cg = VisualTreeHelper.GetClip(visual); var op = VisualTreeHelper.GetOpacity(visual); var om = VisualTreeHelper.GetOpacityMask(visual); var gs = GetGuidelines(visual); var tx = GetTransform(visual); DrawingGroup dg = null; if (be == null && cg == null && om == null && gs == null && tx == null && IsZero(op - 1)) { dg = vd ?? new DrawingGroup(); } else { dg = new DrawingGroup(); if (be != null) { dg.BitmapEffect = be; } if (bei != null) { dg.BitmapEffectInput = bei; } if (cg != null) { dg.ClipGeometry = cg; } if (!IsZero(op - 1)) { dg.Opacity = op; } if (om != null) { dg.OpacityMask = om; } if (gs != null) { dg.GuidelineSet = gs; } if (tx != null) { dg.Transform = tx; } if (vd != null) { dg.Children.Add(vd); } } var c = VisualTreeHelper.GetChildrenCount(visual); for (var i = 0; i < c; ++i) { dg.Children.Add(WalkVisual(GetChild(visual, i))); } return(dg); }
private static Drawing CreateDrawing(Visual visual, bool includeTransform) { DrawingGroup drawingGroup = new DrawingGroup(); System.Windows.Media.Geometry clip = VisualTreeHelper.GetClip(visual); if (clip != null) { drawingGroup.ClipGeometry = clip; } if (includeTransform) { Transform transform = VisualTreeHelper.GetTransform(visual); Vector offset = VisualTreeHelper.GetOffset(visual); Matrix matrix = transform == null ? Matrix.Identity : transform.Value; matrix.Translate(offset.X, offset.Y); if (!matrix.IsIdentity) { drawingGroup.Transform = (Transform) new MatrixTransform(matrix); } } double opacity = VisualTreeHelper.GetOpacity(visual); if (opacity != 1.0) { drawingGroup.Opacity = opacity; } Brush opacityMask = VisualTreeHelper.GetOpacityMask(visual); if (opacityMask != null) { drawingGroup.OpacityMask = opacityMask; } BitmapEffect bitmapEffect = VisualTreeHelper.GetBitmapEffect(visual); if (bitmapEffect != null) { drawingGroup.BitmapEffect = bitmapEffect; } BitmapEffectInput bitmapEffectInput = VisualTreeHelper.GetBitmapEffectInput(visual); if (bitmapEffectInput != null && (!bitmapEffectInput.AreaToApplyEffect.IsEmpty || bitmapEffectInput.Input != BitmapEffectInput.ContextInputSource)) { drawingGroup.BitmapEffectInput = bitmapEffectInput; } Drawing drawing1; if (MakeDrawingBrushCommand.IsMediaElementInstance(visual)) { Rect bounds = VisualTreeHelper.GetDrawing(visual).Bounds; drawing1 = (Drawing) new VideoDrawing() { Rect = bounds }; } else { drawing1 = (Drawing)VisualTreeHelper.GetDrawing(visual); } if (drawing1 != null) { drawingGroup.Children.Add(drawing1); } for (int childIndex = 0; childIndex < VisualTreeHelper.GetChildrenCount((DependencyObject)visual); ++childIndex) { Visual visual1 = VisualTreeHelper.GetChild((DependencyObject)visual, childIndex) as Visual; if (visual1 != null) { Drawing drawing2 = MakeDrawingBrushCommand.CreateDrawing(visual1, true); if (drawing2 != null) { drawingGroup.Children.Add(drawing2); } } } if (drawingGroup.Children.Count == 0) { return((Drawing)null); } if (drawingGroup.Children.Count == 1 && drawingGroup.ClipGeometry == null && (drawingGroup.Transform == null || drawingGroup.Transform.Value.IsIdentity) && (drawingGroup.Opacity == 1.0 && drawingGroup.OpacityMask == null && drawingGroup.BitmapEffect == null)) { return(drawingGroup.Children[0]); } return((Drawing)drawingGroup); }