コード例 #1
0
        void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box)
        {
            //1. mouse down
            box.MouseDown += (s, e) =>
            {
                box.BackColor      = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue);
                e.MouseCursorStyle = MouseCursorStyle.Pointer;

                //--------------------------------------------
                //move controller here
                controllerBox1.SetBounds(box.Left - 5, box.Top - 5,
                                         box.Width + 10, box.Height + 10);
                controllerBox1.Visible   = true;
                controllerBox1.TargetBox = box;

                e.SetMouseCapture(controllerBox1);
            };

            //2. mouse up
            box.MouseUp += (s, e) =>
            {
                e.MouseCursorStyle       = MouseCursorStyle.Default;
                box.BackColor            = Color.LightGray;
                controllerBox1.Visible   = false;
                controllerBox1.TargetBox = null;
            };
        }
コード例 #2
0
        void SetupBackgroundProperties(LayoutFarm.CustomWidgets.EaseBox backgroundBox)
        {
            //if click on background
            backgroundBox.MouseDown += (s, e) =>
            {
                //remove all controller box
                RemoveAllControllerBoxes();
            };

            //when start drag on bg
            //just show selection box on top most
            backgroundBox.MouseDrag += (s, e) =>
            {
                //move to mouse position
                if (!selectionBoxIsShown)
                {
                    selectionBox.LandingPoint = new Point(e.X, e.Y);
                    selectionBox.SetLocation(e.X, e.Y);
                    selectionBox.Visible = true;
                    selectionBoxIsShown  = true;

                    e.SetMouseCapture(selectionBox);
                }
                else
                {
                    Point pos = selectionBox.LandingPoint;
                    int   x   = pos.X;
                    int   y   = pos.Y;
                    int   w   = e.X - pos.X;
                    int   h   = e.Y - pos.Y;

                    if (w < 0)
                    {
                        w  = -w;
                        x -= w;
                    }
                    if (h < 0)
                    {
                        h  = -h;
                        y -= h;
                    }
                    //set width and height
                    selectionBox.SetBounds(x, y, w, h);
                    e.SetMouseCapture(selectionBox);
                }

                e.StopPropagation();
            };
            backgroundBox.MouseUp += (s, e) =>
            {
                if (selectionBoxIsShown)
                {
                    FindSelectedUserBoxes();
                    selectionBox.Visible = false;
                    selectionBox.SetSize(1, 1);
                    selectionBoxIsShown = false;
                }
                e.StopPropagation();
            };
        }
コード例 #3
0
 void SetupBackgroundProperties(LayoutFarm.CustomWidgets.EaseBox backgroundBox)
 {
     //if click on background
     backgroundBox.MouseDown += (s, e) =>
     {
         controllerBox1.TargetBox = null;//release target box
         controllerBox1.Visible   = false;
     };
 }
コード例 #4
0
 void SetupDockSpaces()
 {
     //1. controller
     this.dockspaceController = new DockSpacesController(this, SpaceConcept.NineSpace);
     //2.
     this.dockspaceController.LeftTopSpace.Content     = boxLeftTop = CreateTinyControlBox(SpaceName.LeftTop);
     this.dockspaceController.RightTopSpace.Content    = boxRightTop = CreateTinyControlBox(SpaceName.RightTop);
     this.dockspaceController.LeftBottomSpace.Content  = boxLeftBottom = CreateTinyControlBox(SpaceName.LeftBottom);
     this.dockspaceController.RightBottomSpace.Content = boxRightBottom = CreateTinyControlBox(SpaceName.RightBottom);
 }
コード例 #5
0
 void SetupBackgroundProperties(LayoutFarm.CustomWidgets.EaseBox backgroundBox)
 {
     //if click on background
     backgroundBox.MouseDown += (s, e) =>
     {
         //remove all controller box
         RemoveAllUserControllerBoxes();
     };
     //when start drag on bg
     //just show selection box on top most
     backgroundBox.MouseDrag += (s, e) =>
     {
         //move to mouse position
         if (!selectionBoxIsShown)
         {
             selectionBox.SetLocation(e.X, e.Y);
             selectionBox.Visible = true;
             selectionBoxIsShown  = true;
         }
         else
         {
             int x = e.CapturedMouseX;
             int y = e.CapturedMouseY;
             int w = e.DiffCapturedX;
             int h = e.DiffCapturedY;
             if (w < 0)
             {
                 w  = -w;
                 x -= w;
             }
             if (h < 0)
             {
                 h  = -h;
                 y -= h;
             }
             //set width and height
             selectionBox.SetLocationAndSize(x, y, w, h);
         }
     };
     backgroundBox.MouseUp += (s, e) =>
     {
         if (!selectionBoxIsShown)
         {
             FindSelectedUserBoxes();
             selectionBox.Visible = false;
             selectionBox.SetSize(1, 1);
             selectionBoxIsShown = false;
         }
     };
 }
コード例 #6
0
        void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box)
        {
            //1. mouse down
            box.MouseDown += (s, e) =>
            {
                //box.BackColor = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue);
                e.MouseCursorStyle = MouseCursorStyle.Pointer;
                //--------------------------------------------
                //request user controller for this box

                if (this.BoxSelectionMode == DzBoardSample.BoxSelectionMode.Single)
                {
                    RemoveAllControllerBoxes();
                }

                var userControllerBox = GetFreeControllerBox();
                userControllerBox.TargetBox = box;
                //--------
                //get position relative to box
                var loca1 = box.GetGlobalLocation();

                userControllerBox.SetLocation(loca1.X - 5, loca1.Y - 5);
                userControllerBox.SetSize(box.Width + 10, box.Height + 10);

                userControllerBox.Visible = true;
                userControllerBox.Focus();

                e.SetMouseCapture(userControllerBox);

                e.StopPropagation();
                //--------------------------------------------
            };

            //2. mouse up
            box.MouseUp += (s, e) =>
            {
                e.MouseCursorStyle = MouseCursorStyle.Default;
                //box.BackColor = Color.LightGray;
                RemoveAllControllerBoxes();
                e.StopPropagation();
            };
        }
コード例 #7
0
 void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box)
 {
     //1. mouse down
     box.MouseDown += (s, e) =>
     {
         box.BackColor      = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue);
         e.MouseCursorStyle = MouseCursorStyle.Pointer;
         //--------------------------------------------
         e.SetMouseCapture(rectBoxController.ControllerBoxMain);
         rectBoxController.UpdateControllerBoxes(box);
     };
     //2. mouse up
     box.MouseUp += (s, e) =>
     {
         e.MouseCursorStyle = MouseCursorStyle.Default;
         box.BackColor      = Color.LightGray;
         //controllerBox1.Visible = false;
         //controllerBox1.TargetBox = null;
     };
 }
コード例 #8
0
 static void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box)
 {
     //1. mouse down
     box.MouseDown += (s, e) =>
     {
         box.BackColor      = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue);
         e.MouseCursorStyle = MouseCursorStyle.Pointer;
     };
     //2. mouse up
     box.MouseUp += (s, e) =>
     {
         e.MouseCursorStyle = MouseCursorStyle.Default;
         box.BackColor      = Color.LightGray;
     };
     box.MouseDrag += (s, e) =>
     {
         box.BackColor = KnownColors.FromKnownColor(KnownColor.GreenYellow);
         Point pos = box.Position;
         box.SetLocation(pos.X + e.XDiff, pos.Y + e.YDiff);
         e.MouseCursorStyle = MouseCursorStyle.Pointer;
         e.CancelBubbling   = true;
     };
 }
コード例 #9
0
        void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box)
        {
            //1. mouse down
            box.MouseDown += (s, e) =>
            {
                box.BackColor      = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue);
                e.MouseCursorStyle = MouseCursorStyle.Pointer;

                UIControllerBox userControllerBox = null;
                if (this.controllerBoxMode == ControllerBoxMode.MultipleBoxes)
                {
                    //multiple box
                    userControllerBox = GetFreeUserControllerBox();
                }
                else
                {
                    //single box
                    if (singleControllerBox != null)
                    {
                        ReleaseUserControllerBox(singleControllerBox);
                    }
                    //get new one
                    userControllerBox = singleControllerBox = GetFreeUserControllerBox();
                }
                //request user controller for this box
                userControllerBox.TargetBox = box;
                viewport.AddContent(userControllerBox);
                //location relative to global position of target box
                var globalTargetPos = box.GetGlobalLocation();

                userControllerBox.SetLocation(globalTargetPos.X - 5, globalTargetPos.Y - 5);
                userControllerBox.SetSize(box.Width + 10, box.Height + 10);
                userControllerBox.Visible = true;

                //move mouse capture to new controller box
                //for next drag
                e.SetMouseCapture(userControllerBox);
            };

            //2. mouse up
            box.MouseUp += (s, e) =>
            {
                e.MouseCursorStyle = MouseCursorStyle.Default;
                box.BackColor      = Color.LightGray;

                RemoveAllUserControllerBoxes();
            };
            box.DragOver += (s, e) =>
            {
                switch (e.UserMsgFlags)
                {
                case 1:
                {           //sample only
                    box.BackColor = Color.Green;
                } break;

                case 2:
                {
                    //sample only
                    //leaving
                    box.BackColor = Color.Blue;
                } break;

                case 3:
                {
                    //drop
                    var sender      = e.Sender as UIControllerBox;
                    var droppingBox = sender.TargetBox as UIBox;
                    if (droppingBox != null)
                    {
                        //move from original
                        var parentBox = droppingBox.ParentUI as LayoutFarm.CustomWidgets.SimpleBox;
                        if (parentBox != null)
                        {
                            var newParentGlobalLoca = box.GetGlobalLocation();
                            var droppingGlobalLoca  = droppingBox.GetGlobalLocation();

                            parentBox.RemoveChild(droppingBox);
                            box.AddChild(droppingBox);

                            //TODO: review here ,
                            //set location relative to other element
                            droppingBox.SetLocation(
                                droppingGlobalLoca.X - newParentGlobalLoca.X,
                                droppingGlobalLoca.Y - newParentGlobalLoca.Y);
                        }
                        else
                        {
                        }
                    }
                } break;
                }
            };
        }
コード例 #10
0
 //-----
 void SetupDockSpaces()
 {
     //1. controller
     this.dockspaceController = new DockSpacesController(this, SpaceConcept.NineSpace);
     //2.  
     this.dockspaceController.LeftTopSpace.Content = boxLeftTop = CreateTinyControlBox(SpaceName.LeftTop);
     this.dockspaceController.RightTopSpace.Content = boxRightTop = CreateTinyControlBox(SpaceName.RightTop);
     this.dockspaceController.LeftBottomSpace.Content = boxLeftBottom = CreateTinyControlBox(SpaceName.LeftBottom);
     this.dockspaceController.RightBottomSpace.Content = boxRightBottom = CreateTinyControlBox(SpaceName.RightBottom);
 }
コード例 #11
0
        static void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box)
        {
            //1. mouse down

            bool mouseUpFromDragging = false;

            System.DateTime mouseDownTime = System.DateTime.MinValue;
            System.DateTime mouseUpTime = System.DateTime.MinValue;
            int             mdown_x = 0, mdown_y = 0;
            double          velo_x = 0;
            double          velo_y = 0;
            int             x_dir  = 0;
            int             y_dir  = 0;

            UI.UITimerTask animateTimer = new UITimerTask(tim =>
            {
                box.SetLocation(box.Left + (int)(velo_x * 10 * x_dir),
                                box.Top + (int)(velo_y * 10 * y_dir));

                velo_x -= 0.1;
                velo_y -= 0.1;

                if (velo_x <= 0)
                {
                    velo_x = 0;
                }
                if (velo_y <= 0)
                {
                    velo_y = 0;
                }
                if (velo_x == 0 && velo_y == 0)
                {
                    tim.Enabled = false;
                }
            });
            animateTimer.IntervalInMillisec = 10;
            UIPlatform.RegisterTimerTask(animateTimer);


            box.MouseDown += (s, e) =>
            {
                mdown_x = box.Left;
                mdown_y = box.Top;
                animateTimer.Enabled = false;

                mouseDownTime       = System.DateTime.Now;
                mouseUpFromDragging = false;
                //
                box.BackColor      = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue);
                e.MouseCursorStyle = MouseCursorStyle.Pointer;
            };
            //2. mouse up
            box.MouseUp += (s, e) =>
            {
                mouseUpTime        = System.DateTime.Now;
                e.MouseCursorStyle = MouseCursorStyle.Default;
                box.BackColor      = Color.LightGray;

                if (mouseUpFromDragging)
                {
                    int mup_x = box.Left;
                    int mup_y = box.Top;

                    System.TimeSpan drag_timespan = mouseUpTime - mouseDownTime;
                    double          ms            = drag_timespan.Milliseconds;

                    double displacement_x = mup_x - mdown_x;
                    double displacement_y = mup_y - mdown_y;
                    velo_x = System.Math.Abs(displacement_x / ms);
                    velo_y = System.Math.Abs(displacement_y / ms);

                    x_dir = (mup_x >= mdown_x) ? 1 : -1;
                    y_dir = (mup_y >= mdown_y) ? 1 : -1;
                    animateTimer.Enabled = true;
                }
            };
            box.MouseDrag += (s, e) =>
            {
                mouseUpFromDragging = true;
                box.BackColor       = KnownColors.FromKnownColor(KnownColor.GreenYellow);
                Point pos = box.Position;
                box.SetLocation(pos.X + e.XDiff, pos.Y + e.YDiff);
                e.MouseCursorStyle = MouseCursorStyle.Pointer;
                e.CancelBubbling   = true;
            };
        }