Inheritance: LayoutFarm.CustomWidgets.EaseBox
Esempio 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);
            }
        }
Esempio 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);
         }
     }
 }
Esempio 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();
         }
     }
 }
Esempio 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);
        }
Esempio 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);
                }
            }
        }
Esempio 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);
        }
 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();
         }
     }
 }
 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);
         }
     }
 }
 public void AddSelection(UIControllerBox selectionBox)
 {
     selectionBox.MasterSelectionSet = this;
     this.selectionList.Add(selectionBox);
 }
        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);
            }
        }
        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;
            }
        }
        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);
        }
Esempio n. 13
0
 public void AddSelection(UIControllerBox selectionBox)
 {
     selectionBox.MasterSelectionSet = this;
     this.selectionList.Add(selectionBox);
 }
Esempio 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;
            }
        }
Esempio 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;
        }