public override void SetLocation(int left, int top)
{
var targetBox = this.TargetBox;
int diffX = 0, diffY = 0;
if (targetBox != null)
{
var targetBoxLocation = targetBox.GetGlobalLocation();
diffX = left - targetBoxLocation.X;
diffY = top - targetBoxLocation.Y;
}
base.SetLocation(left, top);
//move target box together
if (targetBox != null)
{
//move target box too
//get global
//targetBox.SetLocation(left + this.GridSize, top + this.GridSize);
targetBox.SetLocation(
targetBox.Left + diffX + this.GridSize,
targetBox.Top + diffY + this.GridSize);
}
}
protected override void OnKeyDown(UIKeyEventArgs e)
void FindSelectedUserBoxes() { //find users box in selected area int j = this.userBoxes.Count; var primSelectionBox = selectionBox.GetPrimaryRenderElement(rootgfx); var primGlobalPoint = primSelectionBox.GetGlobalLocation(); var selectedRectArea = new Rectangle(primGlobalPoint, primSelectionBox.Size); this.selectionSet.Clear(); List <CustomWidgets.EaseBox> selectedList = new List <CustomWidgets.EaseBox>(); for (int i = 0; i < j; ++i) { var box = userBoxes[i]; var primElement = box.GetPrimaryRenderElement(rootgfx); if (!primElement.Visible) { continue; } //get global area Point globalLocation = primElement.GetGlobalLocation(); var userElementArea = new Rectangle(globalLocation, primElement.Size); if (selectedRectArea.Contains(userElementArea)) { //selected= true; selectedList.Add(box); //------ //create user controller box for the selected box UIControllerBox userControllerBox = GetFreeControllerBox(); userControllerBox.TargetBox = box; userControllerBox.SetLocation(box.Left - 5, box.Top - 5); userControllerBox.SetSize(box.Width + 10, box.Height + 10); userControllerBox.Visible = true; userControllerBox.Focus(); selectionSet.AddSelection(userControllerBox); } } }