예제 #1
0
        private void PanelDragEnter(object sender, DragEventArgs e)
        {
            var pos   = TableLayout.GetPositionFromControl((Control)sender);
            var point = new Point(pos.Column, pos.Row);

            if (e.Data.GetDataPresent(typeof(Point)))
            {
                e.Effect = DragDropEffects.Link;
            }
            ColourPanels(point);
        }
예제 #2
0
        private void PanelMouseDown(object sender, MouseEventArgs e)
        {
            var pos = TableLayout.GetPositionFromControl((Control)sender);

            _dragStart = new Point(pos.Column, pos.Row);
            ColourPanels(_dragStart);

            // This call blocks!
            ((Control)sender).DoDragDrop(_dragStart, DragDropEffects.Link);
            foreach (Control control in TableLayout.Controls)
            {
                control.BackColor = Color.Black;
            }
        }
예제 #3
0
        private void PanelDragDrop(object sender, DragEventArgs e)
        {
            var startPoint = (Point)e.Data.GetData(typeof(Point));
            var pos        = TableLayout.GetPositionFromControl((Control)sender);
            var endPoint   = new Point(pos.Column, pos.Row);

            var minx = Math.Min(startPoint.X, endPoint.X);
            var maxx = Math.Max(startPoint.X, endPoint.X);
            var miny = Math.Min(startPoint.Y, endPoint.Y);
            var maxy = Math.Max(startPoint.Y, endPoint.Y);

            var rectangle = new Rectangle(minx, miny, maxx - minx + 1, maxy - miny + 1);

            SelectedConfiguration.Configuration.Rectangles.RemoveAll(x => x.IntersectsWith(rectangle));
            SelectedConfiguration.Configuration.Rectangles.Add(rectangle);
            UpdateTableLayout();

            _dragStart = Point.Empty;
        }
예제 #4
0
 internal TableLayoutPanelCellPosition GetPositionFromControl(IArrangedElement element)
 {
     return(TableLayout.GetPositionFromControl(Owner, element));
 }