public UIHolderBox WrapWithHolderBox(int x, int y, UIBox uibox) { //create holder ui var box1 = new UIHolderBox(uibox.Width + 10, uibox.Height + 10); uibox.SetLocation(5, 5); box1.AddChild(uibox); box1.SetLocation(x, y); box1.TargetBox = uibox; SetupActiveBoxProperties(box1); userBoxes.Add(box1); return(box1); }
public UIHolderBox AddExternalControl(int x, int y, UIBox uibox) { //create holder ui var box1 = new UIHolderBox(uibox.Width + 10, uibox.Height + 10); uibox.SetLocation(5, 5); box1.AddChild(uibox); box1.SetLocation(x, y); box1.TargetBox = uibox; SetupActiveBoxProperties(box1); viewport.AddContent(box1); userBoxes.Add(box1); return(box1); }
static void MoveWithSnapToGrid(UIControllerBox controllerBox, int dx, int dy) { //sample move with snap to grid Point pos = controllerBox.Position; int newX = pos.X + dx; int newY = pos.Y + dy; int gridSize = 5; float halfGrid = (float)gridSize / 2f; int nearestX = (int)((newX + halfGrid) / gridSize) * gridSize; int nearestY = (int)((newY + halfGrid) / gridSize) * gridSize; controllerBox.SetLocation(nearestX, nearestY); UIBox targetBox = controllerBox.TargetBox; if (targetBox != null) { int xdiff = nearestX - pos.X; int ydiff = nearestY - pos.Y; targetBox.SetLocation(targetBox.Left + xdiff, targetBox.Top + ydiff); } }
//---------------------------------------------------- public void OpenHinge() { if (isOpen) { return; } this.isOpen = true; //----------------------------------- if (this.primElement == null) { return; } if (floatPart == null) { return; } switch (floatPartStyle) { default: case HingeFloatPartStyle.Popup: { //add float part to top window layer var topRenderBox = primElement.GetTopWindowRenderBox(); if (topRenderBox != null) { Point globalLocation = primElement.GetGlobalLocation(); floatPart.SetLocation(globalLocation.X, globalLocation.Y + primElement.Height); this.floatPartRenderElement = this.floatPart.GetPrimaryRenderElement(primElement.Root); topRenderBox.AddChild(floatPartRenderElement); } } break; case HingeFloatPartStyle.Embeded: { } break; } }