Exemple #1
0
 public FREDrawingVisual(object c)
 {
     this.context = c.Wrap <IFrameworkRenderElementContext>();
     using (var dc = RenderOpen()) {
         context.Render(dc);
         var controls = new[] { context }.Concat(RenderTreeHelper.RenderDescendants(context));
         foreach (var ctrl in controls)
         {
             var rcbc = ctrl.Wrap <IRenderControlBaseContext>();
             if (rcbc == null)
             {
                 continue;
             }
             dc.PushTransform(rcbc.GeneralTransform);
             dc.DrawRectangle(new VisualBrush(rcbc.Control), null, new Rect(new Point(0, 0), rcbc.RenderSize));
             dc.Pop();
         }
         dc.Close();
     }
 }
Exemple #2
0
 public FREDrawingVisual(object context)
 {
     this.context = context;
     using (var dc = this.RenderOpen()) {
         DXMethods.Render(((dynamic)context).Factory, dc, context);
         var controls = new object[] { context }.Concat(RenderTreeHelper.RenderDescendants(context));
         foreach (object ctrl in controls)
         {
             if (!DXMethods.Is(ctrl, "RenderControlBaseContext", null, false))
             {
                 continue;
             }
             var dctrl = ((dynamic)ctrl);
             dc.PushTransform((dctrl).GeneralTransform);
             dc.DrawRectangle(new VisualBrush((dctrl).Control), null, new Rect(new Point(0, 0), (dctrl).RenderSize));
             dc.Pop();
         }
         dc.Close();
     }
 }
Exemple #3
0
        static VisualTreeItem FindNode(VisualTreeItem currentVisualTreeItem, object target)
        {
            // it might be faster to have a map for the lookup
            // check into this at some point
            Queue <VisualTreeItem> items = new Queue <VisualTreeItem>();

            items.Enqueue(currentVisualTreeItem);
            while (items.Count > 0)
            {
                currentVisualTreeItem = items.Dequeue();
                if (currentVisualTreeItem.Target == target)
                {
                    var chrome = currentVisualTreeItem.Target.Wrap <IChrome>();
                    if (chrome != null && target is IInputElement)
                    {
                        var root = chrome.Root;
                        if (root != null)
                        {
                            var child = RenderTreeHelper.HitTest(root, Mouse.GetPosition((IInputElement)target));
                            var node  = currentVisualTreeItem.FindNode(child);
                            if (node != null)
                            {
                                return(node);
                            }
                        }
                    }
                    return(currentVisualTreeItem);
                }

                foreach (var child in currentVisualTreeItem.Children)
                {
                    items.Enqueue(child);
                }
            }
            return(null);
        }
Exemple #4
0
 public static bool IsVisible(IFrameworkRenderElementContext context)
 {
     return(isVisible(context) && context.ElementHost != null && RenderTreeHelper.RenderAncestors(context).Select(x => x.Wrap <IFrameworkRenderElementContext>()).All(x => isVisible(x)));
 }
Exemple #5
0
 public static bool IsVisible(object context)
 {
     return(isVisible(context) && RenderTreeHelper.RenderAncestors(context).All(x => isVisible(x)));
 }