Exemplo n.º 1
0
        private void HitTesting(Point p)
        {
            var element = (srcPin.Parent as ControlAdorner).AdornedElement;

            VisualTreeHelper.HitTest(designCanvas, null, new HitTestResultCallback(HitTestResultCB1), new PointHitTestParameters(p));
            DependencyObject selectedObj = result == null ? null : result.VisualHit;

            while (selectedObj != null && selectedObj != designCanvas)
            {
                if (selectedObj is LinkableControl && selectedObj != element)
                {
                    HitLinkableControl = selectedObj as LinkableControl;

                    AdornerLayer           layer = AdornerLayer.GetAdornerLayer(HitLinkableControl);
                    PointHitTestParameters param = new PointHitTestParameters(designCanvas.TranslatePoint(p, layer));
                    VisualTreeHelper.HitTest(layer, null, new HitTestResultCallback(HitTestResultCB1), param);
                    selectedObj = result == null ? null : result.VisualHit;
                    while (selectedObj != null && selectedObj != designCanvas)
                    {
                        if (selectedObj is LinkPin)
                        {
                            HitPin = (LinkPin)selectedObj;
                            return;
                        }
                        selectedObj = VisualTreeHelper.GetParent(selectedObj);
                    }
                    return;
                }
                selectedObj = VisualTreeHelper.GetParent(selectedObj);
            }
            HitLinkableControl = null;
            HitPin             = null;
        }
Exemplo n.º 2
0
 public PinAdorner(Panel designer, LinkPin sourcePin) : base(designer)
 {
     this.designCanvas   = designer;
     this.srcPin         = sourcePin;
     drawingPen          = new Pen(Brushes.LightSlateGray, 1);
     drawingPen.LineJoin = PenLineJoin.Round;
     this.Cursor         = Cursors.Cross;
 }
Exemplo n.º 3
0
 public ControlAdorner(LinkableControl AdorneredItem)
     : base(AdorneredItem)
 {
     _children = new List <LinkPin>(4);
     foreach (var pos in AdorneredItem.GetLinkPositions())
     {
         LinkPin pin = new LinkPin(pos.Orient, pos.Position);
         this._children.Add(pin);
         this.AddLogicalChild(pin);
         this.AddVisualChild(pin);
     }
 }