Exemplo n.º 1
0
        void SetupBackgroundProperties(LayoutFarm.CustomWidgets.EaseBox backgroundBox)
        {
            //if click on background
            backgroundBox.MouseDown += (s, e) =>
            {
                //remove all controller box
                RemoveAllControllerBoxes();
            };

            //when start drag on bg
            //just show selection box on top most
            backgroundBox.MouseDrag += (s, e) =>
            {
                //move to mouse position
                if (!selectionBoxIsShown)
                {
                    selectionBox.LandingPoint = new Point(e.X, e.Y);
                    selectionBox.SetLocation(e.X, e.Y);
                    selectionBox.Visible = true;
                    selectionBoxIsShown  = true;

                    e.SetMouseCapture(selectionBox);
                }
                else
                {
                    Point pos = selectionBox.LandingPoint;
                    int   x   = pos.X;
                    int   y   = pos.Y;
                    int   w   = e.X - pos.X;
                    int   h   = e.Y - pos.Y;

                    if (w < 0)
                    {
                        w  = -w;
                        x -= w;
                    }
                    if (h < 0)
                    {
                        h  = -h;
                        y -= h;
                    }
                    //set width and height
                    selectionBox.SetBounds(x, y, w, h);
                    e.SetMouseCapture(selectionBox);
                }

                e.StopPropagation();
            };
            backgroundBox.MouseUp += (s, e) =>
            {
                if (selectionBoxIsShown)
                {
                    FindSelectedUserBoxes();
                    selectionBox.Visible = false;
                    selectionBox.SetSize(1, 1);
                    selectionBoxIsShown = false;
                }
                e.StopPropagation();
            };
        }