示例#1
0
        private void AddSnapLines(ControlDesigner controlDesigner, ArrayList horizontalList, ArrayList verticalList, bool isTarget, bool validTarget)
        {
            IList     snapLines       = controlDesigner.SnapLines;
            Rectangle clientRectangle = controlDesigner.Control.ClientRectangle;
            Rectangle bounds          = controlDesigner.Control.Bounds;

            bounds.Location = clientRectangle.Location = this.behaviorService.ControlToAdornerWindow(controlDesigner.Control);
            int   left = bounds.Left;
            int   top  = bounds.Top;
            Point offsetToClientArea = controlDesigner.GetOffsetToClientArea();

            clientRectangle.X += offsetToClientArea.X;
            clientRectangle.Y += offsetToClientArea.Y;
            foreach (SnapLine line in snapLines)
            {
                if (isTarget)
                {
                    if ((line.Filter != null) && line.Filter.StartsWith("Padding"))
                    {
                        continue;
                    }
                    if (validTarget && !this.targetSnapLineTypes.Contains(line.SnapLineType))
                    {
                        this.targetSnapLineTypes.Add(line.SnapLineType);
                    }
                }
                else
                {
                    if (validTarget && !this.targetSnapLineTypes.Contains(line.SnapLineType))
                    {
                        continue;
                    }
                    if ((line.Filter != null) && line.Filter.StartsWith("Padding"))
                    {
                        this.snapLineToBounds.Add(line, clientRectangle);
                    }
                    else
                    {
                        this.snapLineToBounds.Add(line, bounds);
                    }
                }
                if (line.IsHorizontal)
                {
                    line.AdjustOffset(top);
                    horizontalList.Add(line);
                }
                else
                {
                    line.AdjustOffset(left);
                    verticalList.Add(line);
                }
            }
        }