Inheritance: LayoutFarm.CustomWidgets.EaseBox
Ejemplo n.º 1
0
        static void ResizeTargetWithSnapToGridWhenDragRelease(UIControllerBox controllerBox, UIMouseEventArgs e)
        {
            ////sample move with snap to grid
            //Point pos = controllerBox.Position;
            //int newX = pos.X + e.XDiff;
            //int newY = pos.Y + 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;

            //if (xdiff == 0)
            //{
            //    return;
            //}


            //controllerBox.SetSize(controllerBox.Width + xdiff, controllerBox.Height);

            var targetBox = controllerBox.TargetBox;

            if (targetBox != null)
            {
                int diffX = 0, diffY = 0;

                var targetBoxLocation = targetBox.GetGlobalLocation();
                diffX = controllerBox.Left - targetBoxLocation.X;
                diffY = controllerBox.Top - targetBoxLocation.Y;



                //move target box too
                var newRect = new Rectangle(targetBox.Left + diffX + 5,
                                            targetBox.Top + diffY + 5,
                                            controllerBox.Width - 10,
                                            controllerBox.Height - 10);

                controllerBox.DesignBoardModule.HistoryRecordDzElementNewBounds(
                    controllerBox.TargetBox,
                    controllerBox.beginRect,
                    newRect);

                controllerBox.beginRect = newRect;

                targetBox.SetBounds(newRect.Left,
                                    newRect.Top,
                                    newRect.Width,
                                    newRect.Height);
            }
        }
Ejemplo n.º 2
0
 public void NotifyMoveFrom(UIControllerBox src, int offsetX, int offsetY)
 {
     for (int i = selectionList.Count - 1; i >= 0; --i)
     {
         var controlBox = selectionList[i];
         if (controlBox != src)
         {
             controlBox.SetLocation(
                 controlBox.Left + offsetX,
                 controlBox.Top + offsetY);
         }
     }
 }
Ejemplo n.º 3
0
 public void NotifyRemoveUIElement(UIControllerBox src)
 {
     for (int i = selectionList.Count - 1; i >= 0; --i)
     {
         var controlBox = selectionList[i];
         if (controlBox != src)
         {
             //send to controller box to remove
             var dzModule = controlBox.DesignBoardModule;
             var target   = controlBox.TargetBox;
             controlBox.RelaseTargetAndRemoveSelf();
         }
     }
 }
Ejemplo n.º 4
0
        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;
            //snap to gridsize =5;
            //find nearest snap x

            int   gridSize = controllerBox.GridSize;
            float halfGrid = (float)gridSize / 2f;
            int   nearestX = (int)((newX + halfGrid) / gridSize) * gridSize;
            int   nearestY = (int)((newY + halfGrid) / gridSize) * gridSize;

            controllerBox.MoveTo(nearestX, nearestY);
        }
Ejemplo n.º 5
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);
                }
            }
        }
Ejemplo n.º 6
0
        UIControllerBox GetFreeControllerBox()
        {
            //Console.WriteLine("<< ctrl " + userControllerPool.Count);
            UIControllerBox controlBox = null;

            if (userControllerPool.Count > 0)
            {
                controlBox = userControllerPool.Dequeue();
                //-------------------------------------------
                viewport.AddContent(controlBox);
                //register to working controller box
                workingControllerBoxes.Add(controlBox);
            }
            else
            {
                //create new one
                //controller box 1 (red corners)
                controlBox = new UIControllerBox(40, 40);
                controlBox.DesignBoardModule = this;

                //var gridBox = new LayoutFarm.CustomWidgets.GridBox(30, 30);
                //gridBox.SetLocation(5, 5);
                //gridBox.BuildGrid(3, 3, CellSizeStyle.UniformCell);
                //controlBox.ContentBox = gridBox;

                Color c = KnownColors.FromKnownColor(KnownColor.Yellow);
                controlBox.BackColor = new Color(100, c.R, c.G, c.B);
                controlBox.SetLocation(200, 200);
                //controllerBox1.dbugTag = 3;
                controlBox.Visible = false;
                viewport.AddContent(controlBox);
                //-------------------------------------------
                //register to working controller box
                workingControllerBoxes.Add(controlBox);
            }
            return(controlBox);
        }
Ejemplo n.º 7
0
 public void NotifyRemoveUIElement(UIControllerBox src)
 {
     for (int i = selectionList.Count - 1; i >= 0; --i)
     {
         var controlBox = selectionList[i];
         if (controlBox != src)
         {
             //send to controller box to remove  
             var dzModule = controlBox.DesignBoardModule;
             var target = controlBox.TargetBox;
             controlBox.RelaseTargetAndRemoveSelf();
         }
     }
 }
Ejemplo n.º 8
0
 public void NotifyMoveFrom(UIControllerBox src, int offsetX, int offsetY)
 {
     for (int i = selectionList.Count - 1; i >= 0; --i)
     {
         var controlBox = selectionList[i];
         if (controlBox != src)
         {
             controlBox.SetLocation(
                  controlBox.Left + offsetX,
                  controlBox.Top + offsetY);
         }
     }
 }
Ejemplo n.º 9
0
 public void AddSelection(UIControllerBox selectionBox)
 {
     selectionBox.MasterSelectionSet = this;
     this.selectionList.Add(selectionBox);
 }
Ejemplo n.º 10
0
        static void ResizeTargetWithSnapToGridWhenDragRelease(UIControllerBox controllerBox, UIMouseEventArgs e)
        {
            ////sample move with snap to grid
            //Point pos = controllerBox.Position;
            //int newX = pos.X + e.XDiff;
            //int newY = pos.Y + 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;

            //if (xdiff == 0)
            //{
            //    return;
            //}


            //controllerBox.SetSize(controllerBox.Width + xdiff, controllerBox.Height);

            var targetBox = controllerBox.TargetBox;
            if (targetBox != null)
            {
                int diffX = 0, diffY = 0;
                var targetBoxLocation = targetBox.GetGlobalLocation();
                diffX = controllerBox.Left - targetBoxLocation.X;
                diffY = controllerBox.Top - targetBoxLocation.Y;
                //move target box too 
                var newRect = new Rectangle(targetBox.Left + diffX + 5,
                    targetBox.Top + diffY + 5,
                    controllerBox.Width - 10,
                    controllerBox.Height - 10);
                controllerBox.DesignBoardModule.HistoryRecordDzElementNewBounds(
                    controllerBox.TargetBox,
                    controllerBox.beginRect,
                    newRect);
                controllerBox.beginRect = newRect;
                targetBox.SetBounds(newRect.Left,
                    newRect.Top,
                    newRect.Width,
                    newRect.Height);
            }
        }
Ejemplo n.º 11
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;
            }
        }
Ejemplo n.º 12
0
        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;
            //snap to gridsize =5;
            //find nearest snap x 

            int gridSize = controllerBox.GridSize;
            float halfGrid = (float)gridSize / 2f;
            int nearestX = (int)((newX + halfGrid) / gridSize) * gridSize;
            int nearestY = (int)((newY + halfGrid) / gridSize) * gridSize;
            controllerBox.MoveTo(nearestX, nearestY);
        }
Ejemplo n.º 13
0
 public void AddSelection(UIControllerBox selectionBox)
 {
     selectionBox.MasterSelectionSet = this;
     this.selectionList.Add(selectionBox);
 }
Ejemplo n.º 14
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;
            }
        }
Ejemplo n.º 15
0
        UIControllerBox GetFreeControllerBox()
        {
            //Console.WriteLine("<< ctrl " + userControllerPool.Count);
            UIControllerBox controlBox = null;
            if (userControllerPool.Count > 0)
            {
                controlBox = userControllerPool.Dequeue();
                //-------------------------------------------
                viewport.AddContent(controlBox);
                //register to working controller box
                workingControllerBoxes.Add(controlBox);
            }
            else
            {
                //create new one 
                //controller box 1 (red corners)
                controlBox = new UIControllerBox(40, 40);
                controlBox.DesignBoardModule = this;
                //var gridBox = new LayoutFarm.CustomWidgets.GridBox(30, 30);
                //gridBox.SetLocation(5, 5);
                //gridBox.BuildGrid(3, 3, CellSizeStyle.UniformCell);
                //controlBox.ContentBox = gridBox;

                Color c = KnownColors.FromKnownColor(KnownColor.Yellow);
                controlBox.BackColor = new Color(100, c.R, c.G, c.B);
                controlBox.SetLocation(200, 200);
                //controllerBox1.dbugTag = 3;
                controlBox.Visible = false;
                viewport.AddContent(controlBox);
                //-------------------------------------------
                //register to working controller box
                workingControllerBoxes.Add(controlBox);
            }
            return controlBox;
        }