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(); }; }
void SetupSelectionBoxProperties(UISelectionBox selectionBox) { selectionBox.MouseUp += (s, e) => { if (selectionBoxIsShown) { FindSelectedUserBoxes(); selectionBox.Visible = false; selectionBox.SetSize(1, 1); selectionBoxIsShown = false; } e.StopPropagation(); }; selectionBox.MouseDrag += (s, e) => { if (selectionBoxIsShown) { Point pos = selectionBox.LandingPoint; int x = pos.X; int y = pos.Y; //temp fix here //TODO: get global position of selected box int w = (selectionBox.Left + e.X) - pos.X; int h = (selectionBox.Top + 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.StopPropagation(); }; }