Example #1
0
        // Check if hit test rects collide with any children of the FreeFormPanel, and remove that direction in case a collision is found.
        private static void RemoveDirectionsInCollision(List <DependencyObject> childShapes, DependencyObject target, List <Rect> hitTestRects, ref AutoConnectDirections directions)
        {
            foreach (DependencyObject shape in childShapes)
            {
                if (directions == AutoConnectDirections.None)
                {
                    break;
                }

                if (object.Equals(shape, target))
                {
                    continue;
                }

                Point shapeLocation = FreeFormPanel.GetLocation(shape);
                Size  shapeSize     = FreeFormPanel.GetChildSize(shape);
                Rect  shapeRect     = new Rect(shapeLocation, shapeSize);
                for (int i = 0; i < hitTestRects.Count; i++)
                {
                    if (hitTestRects[i].IntersectsWith(shapeRect))
                    {
                        directions &= ~AutoConnectHelper.GetAutoConnectDirection(i);
                    }
                }
            }
        }
        public FreeFormPanel()
        {
            connectorEditor = null;
            this.autoConnectHelper = new AutoConnectHelper(this);
            lastYPosition = FreeFormPanel.TopStackingMargin;

            this.Unloaded += (sender, e) =>
            {
                this.RemoveConnectorEditor();
            };
        }
        public FreeFormPanel()
        {
            connectorEditor        = null;
            this.autoConnectHelper = new AutoConnectHelper(this);
            lastYPosition          = FreeFormPanel.TopStackingMargin;

            this.Unloaded += (sender, e) =>
            {
                this.RemoveConnectorEditor();
            };
        }
Example #4
0
        // Check if hit test rects are completely within the FreeFormPanel rect, and remove that direction in case it's not.
        private void RemoveDirectionsOutsideOfPanel(List <Rect> hitTestRects, ref AutoConnectDirections directions)
        {
            Rect panelRect = new Rect(0, 0, this.panel.Width, this.panel.Height);

            for (int i = 0; i < hitTestRects.Count; i++)
            {
                if (!panelRect.Contains(hitTestRects[i]))
                {
                    directions &= ~AutoConnectHelper.GetAutoConnectDirection(i);
                }
            }
        }
Example #5
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            for (int i = 0; i < 4; i++)
            {
                if ((AutoConnectHelper.GetAutoConnectDirection(i) & this.directions) != 0)
                {
                    drawingContext.DrawRectangle(this.hitTestBrush, this.hitTestPen, this.hitTestRects[i]);
                    drawingContext.DrawGeometry(
                        (AutoConnectHelper.GetAutoConnectDirection(i) == this.highlightedDirection) ? this.highlightBrush : this.renderBrush,
                        (AutoConnectHelper.GetAutoConnectDirection(i) == this.highlightedDirection) ? this.highlightPen : this.renderPen,
                        this.renderGeometries[i]);
                }
            }

            if (this.AutoConnectDirection != AutoConnectDirections.None)
            {
                drawingContext.DrawRectangle(null, this.highlightPen, this.adornedElementRect);
            }
        }