LayoutFarm.Demo_DragSelectionBox.SetupBackgroundProperties C# (CSharp) Method

SetupBackgroundProperties() private method

private SetupBackgroundProperties ( LayoutFarm backgroundBox ) : void
backgroundBox LayoutFarm
return void
        void SetupBackgroundProperties(LayoutFarm.CustomWidgets.EaseBox backgroundBox)
        {
            //if click on background
            backgroundBox.MouseDown += (s, e) =>
            {
                //remove all controller box
                RemoveAllUserControllerBoxes();
            };
            //when start drag on bg
            //just show selection box on top most
            backgroundBox.MouseDrag += (s, e) =>
            {
                //move to mouse position 
                if (!selectionBoxIsShown)
                {
                    selectionBox.SetLocation(e.X, e.Y);
                    selectionBox.Visible = true;
                    selectionBoxIsShown = true;
                }
                else
                {
                    int x = e.CapturedMouseX;
                    int y = e.CapturedMouseY;
                    int w = e.DiffCapturedX;
                    int h = e.DiffCapturedY;
                    if (w < 0)
                    {
                        w = -w;
                        x -= w;
                    }
                    if (h < 0)
                    {
                        h = -h;
                        y -= h;
                    }
                    //set width and height
                    selectionBox.SetBounds(x, y, w, h);
                }
            };
            backgroundBox.MouseUp += (s, e) =>
            {
                if (!selectionBoxIsShown)
                {
                    FindSelectedUserBoxes();
                    selectionBox.Visible = false;
                    selectionBox.SetSize(1, 1);
                    selectionBoxIsShown = false;
                }
            };
        }