Exemplo n.º 1
0
        void InitEdgeControlBoxes()
        {
            _midLeftSide = new UIControllerBox(20, 20)
            {
                MoveDirection = MoveDirection.XAxis, BackColor = Color.Blue, Visible = false
            };
            SetupEdge_Controller(_midLeftSide);
            _midLeftSide.MouseDrag += (s1, e1) =>
            {
                //move other boxes ...
                AbstractRectUI target1 = _boxLeftTop.TargetBox;
                //update target
                if (target1 != null)
                {
                    //change left side x and width
                    int xdiff = _midLeftSide.Right - target1.Left;
                    target1.SetLocationAndSize(
                        target1.Left + xdiff,
                        target1.Top,
                        target1.Width - xdiff,
                        target1.Height);
                    //update other controller
                    UpdateControllerBoxes(target1);
                }
            };
            _groundBox.Add(_midLeftSide);
            //------------
            _midRightSide = new UIControllerBox(20, 20)
            {
                MoveDirection = MoveDirection.XAxis, BackColor = Color.Blue, Visible = false
            };
            SetupEdge_Controller(_midRightSide);
            _midRightSide.MouseDrag += (s1, e1) =>
            {
                AbstractRectUI target1 = _boxLeftTop.TargetBox;
                //change left side x and width
                int xdiff = _midRightSide.Left - target1.Right;
                target1.SetLocationAndSize(
                    target1.Left,
                    target1.Top,
                    target1.Width + xdiff,
                    target1.Height);

                //update other controller
                UpdateControllerBoxes(target1);
            };
            _groundBox.Add(_midRightSide);
            //------------

            _midTop = new UIControllerBox(20, 20)
            {
                MoveDirection = MoveDirection.YAxis, BackColor = Color.Blue, Visible = false
            };
            SetupEdge_Controller(_midTop);
            _midTop.MouseDrag += (s1, e1) =>
            {
                AbstractRectUI target1 = _boxLeftTop.TargetBox;
                int            ydiff   = target1.Top - _midTop.Bottom;
                target1.SetLocationAndSize(
                    target1.Left,
                    target1.Top - ydiff,
                    target1.Width,
                    target1.Height + ydiff);
                //update other controller
                UpdateControllerBoxes(target1);
            };
            _groundBox.Add(_midTop);

            //------------
            _midBottom = new UIControllerBox(20, 20)
            {
                MoveDirection = MoveDirection.YAxis, BackColor = Color.Blue, Visible = false
            };
            SetupEdge_Controller(_midBottom);
            _midBottom.MouseDrag += (s1, e1) =>
            {
                AbstractRectUI target1 = _boxLeftTop.TargetBox;
                int            ydiff   = _midBottom.Top - target1.Bottom;

                target1.SetLocationAndSize(
                    target1.Left,
                    target1.Top,
                    target1.Width,
                    target1.Height + ydiff);
                //update other controller
                UpdateControllerBoxes(target1);
            };
            _groundBox.Add(_midBottom);
            //------------
        }
Exemplo n.º 2
0
        void InitCornerControlBoxes()
        {
            _boxLeftTop = new UIControllerBox(20, 20)
            {
                BackColor = Color.Yellow, Visible = false
            };
            SetupCorner_Controller(_boxLeftTop);
            _boxLeftTop.MouseDrag += (s1, e1) =>
            {
                //move other boxes ...
                AbstractRectUI target1 = _boxLeftTop.TargetBox;
                //update target
                if (target1 != null)
                {
                    target1.SetLocationAndSize(
                        _boxLeftTop.Right,
                        _boxLeftTop.Bottom,
                        _boxRightTop.Left - _boxLeftTop.Right,
                        _boxRightBottom.Top - _boxLeftTop.Bottom);
                    //update other controller
                    UpdateControllerBoxes(target1);
                }
            };
            _groundBox.Add(_boxLeftTop);
            //------------
            _boxLeftBottom = new UIControllerBox(20, 20)
            {
                BackColor = Color.Yellow, Visible = false
            };
            SetupCorner_Controller(_boxLeftBottom);
            _boxLeftBottom.MouseDrag += (s1, e1) =>
            {
                AbstractRectUI target1 = _boxLeftBottom.TargetBox;
                //update target
                if (target1 != null)
                {
                    target1.SetLocationAndSize(_boxLeftBottom.Right,
                                               _boxLeftTop.Bottom,
                                               _boxRightTop.Left - _boxLeftBottom.Right,
                                               _boxLeftBottom.Top - _boxLeftTop.Bottom);
                    //update other controller
                    UpdateControllerBoxes(target1);
                }
            };
            _groundBox.Add(_boxLeftBottom);
            //------------

            _boxRightTop = new UIControllerBox(20, 20)
            {
                BackColor = Color.Yellow, Visible = false
            };
            SetupCorner_Controller(_boxRightTop);
            _boxRightTop.MouseDrag += (s1, e1) =>
            {
                AbstractRectUI target1 = _boxRightTop.TargetBox;
                //update target
                if (target1 != null)
                {
                    target1.SetLocationAndSize(
                        _boxLeftTop.Right,
                        _boxRightTop.Bottom,
                        _boxRightTop.Left - _boxLeftTop.Right,
                        _boxRightBottom.Top - _boxRightTop.Bottom);
                    //update other controllers
                    UpdateControllerBoxes(target1);
                }
            };
            _groundBox.Add(_boxRightTop);

            //------------
            _boxRightBottom = new UIControllerBox(20, 20)
            {
                BackColor = Color.Yellow, Visible = false
            };
            SetupCorner_Controller(_boxRightBottom);
            _boxRightBottom.MouseDrag += (s1, e1) =>
            {
                OnUpdateShape();
                //rotate all other control points
                //AbstractRectUI target1 = _boxRightBottom.TargetBox;



                ////update target
                //if (target1 != null)
                //{
                //    target1.SetLocationAndSize(_boxLeftTop.Right,
                //                      _boxLeftTop.Bottom,
                //                      _boxRightBottom.Left - _boxLeftTop.Right,
                //                      _boxRightBottom.Top - _boxLeftTop.Bottom);
                //    //update other controllers
                //    UpdateControllerBoxes(target1);
                //}
            };
            _groundBox.Add(_boxRightBottom);
            //------------
        }