SetSize() public method

public SetSize ( int width, int height ) : void
width int
height int
return void
示例#1
0
        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);
                }
            }
        }
        void ResizeTargetWithSnapToGrid2(SpaceName tinyBoxSpaceName, UIControllerBox controllerBox, UIMouseEventArgs e, int dx, int dy)
        {
            //sample move with snap to grid
            Point pos = controllerBox.Position;
            int newX = pos.X + dx;// e.XDiff;
            int newY = pos.Y + dy;// e.YDiff;
            //snap to gridsize =5;
            //find nearest snap x 
            int gridSize = 5;
            float halfGrid = (float)gridSize / 2f;
            int nearestX = (int)((newX + halfGrid) / gridSize) * gridSize;
            int nearestY = (int)((newY + halfGrid) / gridSize) * gridSize;
            int xdiff = nearestX - pos.X;
            int ydiff = nearestY - pos.Y;
            int diffX = 0, diffY = 0;
            var targetBox = controllerBox.TargetBox;
            if (targetBox != null)
            {
                var targetBoxLocation = targetBox.GetGlobalLocation();
                diffX = this.Left - targetBoxLocation.X;
                diffY = this.Top - targetBoxLocation.Y;
            }


            switch (tinyBoxSpaceName)
            {
                case SpaceName.LeftTop:
                    {
                        if (xdiff != 0 || ydiff != 0)
                        {
                            controllerBox.SetLocation(controllerBox.Left + xdiff, controllerBox.Top + ydiff);
                            controllerBox.SetSize(controllerBox.Width - xdiff, controllerBox.Height - ydiff);
                            if (targetBox != null)
                            {
                                //move target box too 
                                targetBox.SetBounds(targetBox.Left + diffX + 5,
                                    targetBox.Top + diffY + 5,
                                    controllerBox.Width - 10,
                                    controllerBox.Height - 10);
                            }
                        }
                    }
                    break;
                case SpaceName.RightTop:
                    {
                        if (xdiff != 0 || ydiff != 0)
                        {
                            controllerBox.SetLocation(controllerBox.Left, controllerBox.Top + ydiff);
                            controllerBox.SetSize(controllerBox.Width + xdiff, controllerBox.Height - ydiff);
                            if (targetBox != null)
                            {
                                //move target box too 
                                targetBox.SetBounds(targetBox.Left + diffX + 5,
                                   targetBox.Top + diffY + 5,
                                   controllerBox.Width - 10,
                                   controllerBox.Height - 10);
                            }
                        }
                    }
                    break;
                case SpaceName.RightBottom:
                    {
                        if (xdiff != 0 || ydiff != 0)
                        {
                            controllerBox.SetSize(controllerBox.Width + xdiff, controllerBox.Height + ydiff);
                            if (targetBox != null)
                            {
                                //move target box too 
                                targetBox.SetBounds(targetBox.Left + diffX + 5,
                                   targetBox.Top + diffY + 5,
                                   controllerBox.Width - 10,
                                   controllerBox.Height - 10);
                            }
                        }
                    }
                    break;
                case SpaceName.LeftBottom:
                    {
                        if (xdiff != 0 || ydiff != 0)
                        {
                            controllerBox.SetLocation(controllerBox.Left + xdiff, controllerBox.Top);
                            controllerBox.SetSize(controllerBox.Width - xdiff, controllerBox.Height + ydiff);
                            if (targetBox != null)
                            {
                                //move target box too 
                                targetBox.SetBounds(targetBox.Left + diffX + 5,
                                   targetBox.Top + diffY + 5,
                                   controllerBox.Width - 10,
                                   controllerBox.Height - 10);
                            }
                        }
                    }
                    break;
            }
        }
示例#3
0
        void ResizeTargetWithSnapToGrid2(SpaceName tinyBoxSpaceName, UIControllerBox controllerBox, UIMouseEventArgs e, int dx, int dy)
        {
            //sample move with snap to grid
            Point pos  = controllerBox.Position;
            int   newX = pos.X + dx; // e.XDiff;
            int   newY = pos.Y + dy; // e.YDiff;
            //snap to gridsize =5;
            //find nearest snap x
            int   gridSize = 5;
            float halfGrid = (float)gridSize / 2f;
            int   nearestX = (int)((newX + halfGrid) / gridSize) * gridSize;
            int   nearestY = (int)((newY + halfGrid) / gridSize) * gridSize;

            int xdiff = nearestX - pos.X;
            int ydiff = nearestY - pos.Y;


            int diffX = 0, diffY = 0;
            var targetBox = controllerBox.TargetBox;

            if (targetBox != null)
            {
                var targetBoxLocation = targetBox.GetGlobalLocation();
                diffX = this.Left - targetBoxLocation.X;
                diffY = this.Top - targetBoxLocation.Y;
            }


            switch (tinyBoxSpaceName)
            {
            case SpaceName.LeftTop:
            {
                if (xdiff != 0 || ydiff != 0)
                {
                    controllerBox.SetLocation(controllerBox.Left + xdiff, controllerBox.Top + ydiff);
                    controllerBox.SetSize(controllerBox.Width - xdiff, controllerBox.Height - ydiff);


                    if (targetBox != null)
                    {
                        //move target box too
                        targetBox.SetBounds(targetBox.Left + diffX + 5,
                                            targetBox.Top + diffY + 5,
                                            controllerBox.Width - 10,
                                            controllerBox.Height - 10);
                    }
                }
            } break;

            case SpaceName.RightTop:
            {
                if (xdiff != 0 || ydiff != 0)
                {
                    controllerBox.SetLocation(controllerBox.Left, controllerBox.Top + ydiff);
                    controllerBox.SetSize(controllerBox.Width + xdiff, controllerBox.Height - ydiff);


                    if (targetBox != null)
                    {
                        //move target box too
                        targetBox.SetBounds(targetBox.Left + diffX + 5,
                                            targetBox.Top + diffY + 5,
                                            controllerBox.Width - 10,
                                            controllerBox.Height - 10);
                    }
                }
            } break;

            case SpaceName.RightBottom:
            {
                if (xdiff != 0 || ydiff != 0)
                {
                    controllerBox.SetSize(controllerBox.Width + xdiff, controllerBox.Height + ydiff);

                    if (targetBox != null)
                    {
                        //move target box too
                        targetBox.SetBounds(targetBox.Left + diffX + 5,
                                            targetBox.Top + diffY + 5,
                                            controllerBox.Width - 10,
                                            controllerBox.Height - 10);
                    }
                }
            } break;

            case SpaceName.LeftBottom:
            {
                if (xdiff != 0 || ydiff != 0)
                {
                    controllerBox.SetLocation(controllerBox.Left + xdiff, controllerBox.Top);
                    controllerBox.SetSize(controllerBox.Width - xdiff, controllerBox.Height + ydiff);


                    if (targetBox != null)
                    {
                        //move target box too
                        targetBox.SetBounds(targetBox.Left + diffX + 5,
                                            targetBox.Top + diffY + 5,
                                            controllerBox.Width - 10,
                                            controllerBox.Height - 10);
                    }
                }
            } break;
            }
        }