Exemplo n.º 1
0
        /// <summary>
        /// Performs hit testing for rectangle bounds, in client coordinates</summary>
        /// <param name="pickRect">Pick rectangle, in client coordinates</param>
        /// <returns>Items that overlap with the rectangle, in client coordinates</returns>
        public virtual IEnumerable <object> Pick(Rectangle pickRect)
        {
            Matrix3x2F invXform = Matrix3x2F.Invert(m_d2dGraphics.Transform);
            RectangleF rect     = D2dUtil.Transform(invXform, pickRect);

            return(m_renderer.Pick(m_graph, rect, m_d2dGraphics));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets a bounding rectangle for the items, in client coordinates</summary>
        /// <param name="items">Items to bound</param>
        /// <returns>Bounding rectangle for the items, in client coordinates</returns>
        public virtual Rectangle GetBounds(IEnumerable <object> items)
        {
            RectangleF bounds = m_renderer.GetBounds(items.AsIEnumerable <TNode>(), m_d2dGraphics);

            bounds = D2dUtil.Transform(m_d2dGraphics.Transform, bounds);
            return(Rectangle.Truncate(bounds));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Performs hit testing for rectangle bounds, in client coordinates</summary>
        /// <param name="pickRect">Pick rectangle, in client coordinates</param>
        /// <returns>Items that overlap with the rectangle, in client coordinates</returns>
        public override IEnumerable <object> Pick(Rectangle pickRect)
        {
#if CS_4
            Matrix3x2F           invXform         = Matrix3x2F.Invert(m_d2dGraphics.Transform);
            RectangleF           rect             = D2dUtil.Transform(invXform, pickRect);
            IEnumerable <object> pickedGraphNodes = base.Pick(pickRect);
#else
            // workaround a C#3 compiler bug( CS1911 warning)
            Matrix3x2F    invXform         = Matrix3x2F.Invert(m_d2dGraphics.Transform);
            RectangleF    rect             = D2dUtil.Transform(invXform, pickRect);
            List <object> pickedGraphNodes = new List <object>();
            foreach (TNode node in m_graph.Nodes)
            {
                RectangleF nodeBounds = m_renderer.GetBounds(node, m_d2dGraphics); // in graph space
                if (nodeBounds.IntersectsWith(rect))
                {
                    pickedGraphNodes.Add(node);
                }
            }
#endif
            foreach (var pickedGraphNode in pickedGraphNodes)
            {
                yield return(pickedGraphNode);
            }

            var pickedFloatingPins = new List <object>();
            var circuiElement      = m_graph.Cast <ICircuitElementType>();
            foreach (var pin in circuiElement.Inputs)
            {
                var        grpPIn     = pin.Cast <ICircuitGroupPin <TNode> >();
                RectangleF nodeBounds = m_renderer.GetBounds(grpPIn, true, m_d2dGraphics);
                if (nodeBounds.IntersectsWith(rect))
                {
                    pickedFloatingPins.Add(pin);
                }
            }

            foreach (var pin in circuiElement.Outputs)
            {
                var        grpPIn     = pin.Cast <ICircuitGroupPin <TNode> >();
                RectangleF nodeBounds = m_renderer.GetBounds(grpPIn, false, m_d2dGraphics);
                if (nodeBounds.IntersectsWith(rect))
                {
                    pickedFloatingPins.Add(pin);
                }
            }

            foreach (var floatingPin in pickedFloatingPins)
            {
                yield return(floatingPin);
            }
        }