public int MouseOver(IViewportController viewportController, int x, int y)
        {
            if (viewportController.Viewport.VisibilityMask != this.vfFlag)
                return MG_NONE;

            int mouseGripIndex = this.MouseOverGripIndex(viewportController, x, y);

            switch (mouseGripIndex)
            {
                case ResizableBox.MG_TOP_LEFT:
                case ResizableBox.MG_BOTTOM_RIGHT:
                    viewportController.Cursor = Cursors.SizeNWSE;
                    break;
                case ResizableBox.MG_TOP_RIGHT:
                case ResizableBox.MG_BOTTOM_LEFT:
                    viewportController.Cursor = Cursors.SizeNESW;
                    break;
                case ResizableBox.MG_TOP_MIDDLE:
                case ResizableBox.MG_BOTTOM_MIDDLE:
                    viewportController.Cursor = Cursors.SizeNS;
                    break;
                case ResizableBox.MG_LEFT_MIDDLE:
                case ResizableBox.MG_RIGHT_MIDDLE:
                    viewportController.Cursor = Cursors.SizeWE;
                    break;
                case ResizableBox.MG_MOVE:
                    viewportController.Cursor = Cursors.SizeAll;
                    break;
                default:
                    viewportController.Cursor = Cursors.Default;
                    break;
            }

            return mouseGripIndex;
        }
Exemple #2
0
 public new void MouseUp(IViewportController viewportController, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         Editor.SelectionBox.MouseUp(viewportController, e);
     }
 }
Exemple #3
0
        public new void MouseUp(IViewportController viewportController, MouseEventArgs e)
        {
            if (Editor.SelectionBox.SelectedObject != null)
            {
                Editor.SelectionBox.MouseUp(viewportController, e);
            }
            else
            {
                Ray ray = viewportController.CreateViewportRay(e.X, e.Y);
                ISelectableObject selectedObject = null;
                float             d = float.MaxValue;

                foreach (ISelectableObject selectable in Editor.SelectableObjects)
                {
                    Pair <bool, float> pair = selectable.RayIntersects(ray, viewportController);

                    if (pair.first && pair.second < d)
                    {
                        d = pair.second;
                        selectedObject = selectable;
                    }
                }

                Editor.SelectionBox.SelectedObject = selectedObject;
            }
        }
Exemple #4
0
 public new void MouseDown(IViewportController viewportController, MouseEventArgs e)
 {
     if (Editor.SelectionBox.SelectedObject != null)
     {
         Editor.SelectionBox.MouseDown(viewportController, e);
     }
 }
Exemple #5
0
        protected override void OnLoad(EventArgs e)
        {
            switch (viewportType)
            {
            case ViewportType.Perspective:
                this.viewportController = Editor.CreatePerspectiveViewport(this.viewportPanel);
                break;

            case ViewportType.Front:
                this.viewportController = Editor.CreateOrthographicViewport(this.viewportPanel, Vector3.UNIT_Z);
                break;

            case ViewportType.Side:
                this.viewportController = Editor.CreateOrthographicViewport(this.viewportPanel, Vector3.UNIT_X);
                break;

            case ViewportType.Top:
                this.viewportController = Editor.CreateOrthographicViewport(this.viewportPanel, Vector3.UNIT_Y);
                break;

            default:
                throw new Exception("Viewport type " + viewportType.ToString() + " not implemented");
            }

            base.OnLoad(e);
        }
Exemple #6
0
        private static IViewportController RegisterViewportController(IViewportController controller, ViewportPanel control)
        {
            control.Initialise(controller);

            // first viewport
            if (viewportControllers.Count == 0)
            {
                ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

                // lighting
                Engine.Graphics.SceneManager.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_MODULATIVE;
                Engine.Graphics.SceneManager.AmbientLight    = new ColourValue(0.85f, 0.85f, 0.85f);
                Engine.Graphics.SceneManager.ShadowColour    = new ColourValue(0.75f, 0.75f, 0.75f);

                // default light
                Light light = Engine.Graphics.SceneManager.CreateLight("defaultLight");
                light.DiffuseColour  = ColourValue.White;
                light.SpecularColour = ColourValue.White;
                light.Direction      = new Vector3(0.2f, -1.0f, 0.2f);
                light.Type           = Light.LightTypes.LT_DIRECTIONAL;

                if (OnCreateViewportController != null)
                {
                    OnCreateViewportController(controller, EventArgs.Empty);
                }
            }

            controller.SizeChanged();
            controller.CreateScene();

            viewportControllers.Add(controller);
            return(controller);
        }
Exemple #7
0
 public new void MouseDown(IViewportController viewportController, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         this.mouseDownPosition = viewportController.MouseToGrid(e.X, e.Y);
     }
 }
Exemple #8
0
        public SheetViewport(IViewportController vc)
            : base(vc)
        {
            this.children = new List <IView>(4)
            {
                new CellsViewport(vc)
                {
                    PerformTransform = false
                },

#if DRAWING
                new DrawingViewport(vc)
                {
                    PerformTransform = false
                },
#if COMMENT
                new CommentViewport(vc)
                {
                    PerformTransform = false
                },
#endif // COMMENT
#endif // DRAWING

                new CellsForegroundView(vc)
                {
                    PerformTransform = false
                },
            };
        }
Exemple #9
0
        private int MouseOverGripIndex(IViewportController viewportController, int x, int y)
        {
            int mouseGripIndex = MG_NONE;

            // the the side grips
            if (viewportController.Viewport.VisibilityMask == vfFlag)
            {
                for (int i = 0; i < this.mouseGrips.Length; i++)
                {
                    Vector3 mouseGrip = mouseGrips[i];
                    Vector2 screenPos = viewportController.GetScreenPosition(mouseGrip);
                    int     gripSize  = 4;

                    if (x >= screenPos.x - gripSize && x <= screenPos.x + gripSize && y >= screenPos.y - gripSize && y <= screenPos.y + gripSize)
                    {
                        mouseGripIndex = i;
                    }
                }
            }

            // test for special move grip
            if (mouseGripIndex == MG_NONE)
            {
                Vector2 topLeft     = viewportController.GetScreenPosition(this.corners[this.indices[0]]);
                Vector2 bottomRight = viewportController.GetScreenPosition(this.corners[this.indices[2]]);

                if (x > topLeft.x && x < bottomRight.x && y > topLeft.y && y < bottomRight.y)
                {
                    return(MG_MOVE);
                }
            }

            return(mouseGripIndex);
        }
Exemple #10
0
        public Vector3 MouseOverAxis(IViewportController viewportController, int x, int y)
        {
            Ray ray = viewportController.CreateViewportRay(x, y);

            float          th   = 0.1f; // thickness
            float          len  = 1.1f; // length
            AxisAlignedBox xBox = CreateOffsetBox(new Vector3(0.0f, -th, -th), new Vector3(len, th, th));
            AxisAlignedBox yBox = CreateOffsetBox(new Vector3(-th, 0.0f, -th), new Vector3(th, len, th));
            AxisAlignedBox zBox = CreateOffsetBox(new Vector3(-th, -th, 0.0f), new Vector3(th, th, len));

            if (ray.Intersects(xBox).first&& !viewportController.CameraController.IsLookingDownAxis(Vector3.UNIT_X))
            {
                return(Vector3.UNIT_X);
            }

            if (ray.Intersects(yBox).first&& !viewportController.CameraController.IsLookingDownAxis(Vector3.UNIT_Y))
            {
                return(Vector3.UNIT_Y);
            }

            if (ray.Intersects(zBox).first&& !viewportController.CameraController.IsLookingDownAxis(Vector3.UNIT_Z))
            {
                return(Vector3.UNIT_Z);
            }

            return(Vector3.ZERO);
        }
Exemple #11
0
        public new void MouseDown(IViewportController viewportController, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Block hitBlock = Editor.SelectBlock(viewportController, e.X, e.Y);

                if (hitBlock != null)
                    hitBlock.MaterialName = this.treeMaterial.SelectedNode.Text;
            }
        }
Exemple #12
0
 public Pair <bool, float> RayIntersects(Ray ray, IViewportController viewportController)
 {
     if (viewportController.Viewport.VisibilityMask == ViewportController.VF_PERSPECTIVE)
     {
         return(ray.Intersects(this.BoundingBox));
     }
     else
     {
         return(ray.Intersects(new Sphere(this.BoundingBox.Center, 0.2f)));
     }
 }
Exemple #13
0
        public new void MouseDown(IViewportController viewportController, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Block hitBlock = Editor.SelectBlock(viewportController, e.X, e.Y);

                if (hitBlock != null)
                {
                    hitBlock.MaterialName = this.treeMaterial.SelectedNode.Text;
                }
            }
        }
Exemple #14
0
        public new void MouseMove(IViewportController viewportController, int dx, int dy, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Vector3 mouseUpPosition = viewportController.MouseToGrid(e.X, e.Y);
                Vector3 movement = mouseUpPosition - mouseDownPosition;

                foreach (EditNode editNode in Editor.SelectedNodes)
                    editNode.Position += movement;

                this.mouseDownPosition = mouseUpPosition;
            }
        }
Exemple #15
0
        public new void MouseDown(IViewportController viewportController, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Vector3 position = viewportController.MouseToGrid(e.X, e.Y);

                if (this.lstEntityTypes.SelectedItem != null)
                {
                    string key = this.lstEntityTypes.SelectedItem.ToString();

                    Editor.CreateEditNode(key, position);
                }
            }
        }
Exemple #16
0
        public new void MouseDown(IViewportController viewportController, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Vector3 position = viewportController.MouseToGrid(e.X, e.Y);

                if (this.lstEntityTypes.SelectedItem != null)
                {
                    string key = this.lstEntityTypes.SelectedItem.ToString();

                    Editor.CreateEditNode(key, position);
                }
            }
        }
Exemple #17
0
        public bool Grab(IViewportController viewportController, int x, int y)
        {
            this.mx = x;
            this.my = y;

            this.moveAxis = MouseOverAxis(viewportController, x, y);

            if (moveAxis != Vector3.ZERO)
            {
                grabPosition = MouseTo(viewportController, x, y) - this.Position;
                return(true);
            }

            return(false);
        }
Exemple #18
0
        public void MoveTo(IViewportController viewportController, int x, int y)
        {
            if (grabPosition != Vector3.ZERO)
            {
                Vector3 p      = MouseTo(viewportController, x, y);
                Vector3 newPos = p - grabPosition;

                this.Position = Editor.SnapTo((newPos * moveAxis) + (this.Position * (1 - moveAxis)));

                if (this.node != null)
                {
                    this.node.Position = this.Position;
                }
            }
        }
Exemple #19
0
        public new void MouseMove(IViewportController viewportController, int dx, int dy, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Vector3 mouseUpPosition = viewportController.MouseToGrid(e.X, e.Y);
                Vector3 movement        = mouseUpPosition - mouseDownPosition;

                foreach (EditNode editNode in Editor.SelectedNodes)
                {
                    editNode.Position += movement;
                }

                this.mouseDownPosition = mouseUpPosition;
            }
        }
Exemple #20
0
        private Vector3 MouseTo(IViewportController viewportController, int x, int y)
        {
            // determine the active plane
            Plane activePlane = viewportController.CameraController.GetActivePlane(moveAxis, this.Position);

            // raycast onto the active plane
            RaycastResult result = viewportController.MouseToPlane(x, y, activePlane);

            if (result != null)
            {
                return(result.Position);
            }

            return(Vector3.ZERO);
        }
Exemple #21
0
        private int GetSelectedGrip(IViewportController viewportController, int x, int y)
        {
            if (this.isCreated)
            {
                foreach (ResizableBox resizableBox in this.resizableBoxes)
                {
                    int grip = resizableBox.MouseOver(viewportController, x, y);

                    if (grip != ResizableBox.MG_NONE)
                    {
                        return(grip);
                    }
                }
            }

            return(ResizableBox.MG_NONE);
        }
Exemple #22
0
        public bool MouseMove(IViewportController viewportController, System.Windows.Forms.MouseEventArgs e)
        {
            if (this.isCreated)
            {
                // update the visual feedback if we are not doing anything else
                if (this.selectedGrip == ResizableBox.MG_NONE)
                {
                    GetSelectedGrip(viewportController, e.X, e.Y);
                }

                if (e.Button == MouseButtons.Left)
                {
                    Vector3 mousePos = viewportController.MouseToGrid(e.X, e.Y);

                    switch (this.selectedGrip)
                    {
                    case ResizableBox.MG_NONE:          // creating a new box
                        this.max = mousePos;
                        break;

                    case ResizableBox.MG_MOVE:          // moving a box
                        Vector3 movement = mousePos - this.mouseDownPos;
                        this.min         += movement;
                        this.max         += movement;
                        this.mouseDownPos = mousePos;
                        break;

                    default:
                        this.Resize(mousePos, viewportController.Viewport.VisibilityMask);
                        break;
                    }

                    this.Update();
                }
            }
            else
            {
                if (e.Button == MouseButtons.Left && this.selectedGrip == ResizableBox.MG_NONE)
                {
                    this.Create();
                }
            }

            return(this.selectedGrip != ResizableBox.MG_NONE);
        }
Exemple #23
0
        public bool MouseUp(IViewportController viewportController, MouseEventArgs e)
        {
            bool returnValue = this.selectedGrip != ResizableBox.MG_NONE;

            if (e.Button == MouseButtons.Left)
            {
                if (this.selectedGrip == ResizableBox.MG_NONE)
                {
                    // finish creating a new box
                    this.max = viewportController.MouseToGrid(e.X, e.Y);
                }

                if (min == max)
                {
                    this.Destroy();
                }

                if (min.x == max.x)
                {
                    min.x = max.x + 1;
                }

                if (min.y == max.y)
                {
                    min.y = max.y + 1;
                }

                if (min.z == max.z)
                {
                    min.z = max.z + 1;
                }

                // make sure min an max are around the right way
                Vector3 temp = Editor.MinOf(min, max);
                this.max = Editor.MaxOf(min, max);
                this.min = temp;

                this.Update();
                this.selectedGrip = ResizableBox.MG_NONE;
            }

            return(returnValue);
        }
Exemple #24
0
        public static Block SelectBlock(IViewportController viewportController, int x, int y)
        {
            Ray   ray      = viewportController.CreateViewportRay(x, y);
            Block hitBlock = null;
            float d        = float.MaxValue;

            foreach (Block block in Editor.Blocks)
            {
                Pair <bool, float> pair = ray.Intersects(block.BoundingBox);

                if (pair.first && pair.second < d)
                {
                    d        = pair.second;
                    hitBlock = block;
                }
            }

            return(hitBlock);
        }
Exemple #25
0
        public int MouseOver(IViewportController viewportController, int x, int y)
        {
            if (viewportController.Viewport.VisibilityMask != this.vfFlag)
            {
                return(MG_NONE);
            }

            int mouseGripIndex = this.MouseOverGripIndex(viewportController, x, y);

            switch (mouseGripIndex)
            {
            case ResizableBox.MG_TOP_LEFT:
            case ResizableBox.MG_BOTTOM_RIGHT:
                viewportController.Cursor = Cursors.SizeNWSE;
                break;

            case ResizableBox.MG_TOP_RIGHT:
            case ResizableBox.MG_BOTTOM_LEFT:
                viewportController.Cursor = Cursors.SizeNESW;
                break;

            case ResizableBox.MG_TOP_MIDDLE:
            case ResizableBox.MG_BOTTOM_MIDDLE:
                viewportController.Cursor = Cursors.SizeNS;
                break;

            case ResizableBox.MG_LEFT_MIDDLE:
            case ResizableBox.MG_RIGHT_MIDDLE:
                viewportController.Cursor = Cursors.SizeWE;
                break;

            case ResizableBox.MG_MOVE:
                viewportController.Cursor = Cursors.SizeAll;
                break;

            default:
                viewportController.Cursor = Cursors.Default;
                break;
            }

            return(mouseGripIndex);
        }
        protected override void OnLoad(EventArgs e)
        {
            switch (viewportType)
            {
                case ViewportType.Perspective:
                    this.viewportController = Editor.CreatePerspectiveViewport(this.viewportPanel);
                    break;
                case ViewportType.Front:
                    this.viewportController = Editor.CreateOrthographicViewport(this.viewportPanel, Vector3.UNIT_Z);
                    break;
                case ViewportType.Side:
                    this.viewportController = Editor.CreateOrthographicViewport(this.viewportPanel, Vector3.UNIT_X);
                    break;
                case ViewportType.Top:
                    this.viewportController = Editor.CreateOrthographicViewport(this.viewportPanel, Vector3.UNIT_Y);
                    break;
                default:
                    throw new Exception("Viewport type " + viewportType.ToString() + " not implemented");
            }

            base.OnLoad(e);
        }
Exemple #27
0
        public bool MouseDown(IViewportController viewportController, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.mouseDownPos = viewportController.MouseToGrid(e.X, e.Y);
                this.selectedGrip = this.GetSelectedGrip(viewportController, e.X, e.Y);

                // create a new box
                if (this.selectedGrip == ResizableBox.MG_NONE)
                {
                    this.selectedObject = null;
                    this.min            = mouseDownPos;
                    this.max            = mouseDownPos;

                    if (this.isCreated)
                    {
                        this.Destroy();
                    }
                }
            }

            return(this.selectedGrip != ResizableBox.MG_NONE);
        }
Exemple #28
0
        private static IViewportController RegisterViewportController(IViewportController controller, ViewportPanel control)
        {
            control.Initialise(controller);

            // first viewport
            if (viewportControllers.Count == 0)
            {
                ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

                // lighting
                Engine.Graphics.SceneManager.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_MODULATIVE;
                Engine.Graphics.SceneManager.AmbientLight = new ColourValue(0.85f, 0.85f, 0.85f);
                Engine.Graphics.SceneManager.ShadowColour = new ColourValue(0.75f, 0.75f, 0.75f);

                // default light
                Light light = Engine.Graphics.SceneManager.CreateLight("defaultLight");
                light.DiffuseColour = ColourValue.White;
                light.SpecularColour = ColourValue.White;
                light.Direction = new Vector3(0.2f, -1.0f, 0.2f);
                light.Type = Light.LightTypes.LT_DIRECTIONAL;

                if (OnCreateViewportController != null)
                    OnCreateViewportController(controller, EventArgs.Empty);
            }

            controller.SizeChanged();
            controller.CreateScene();

            viewportControllers.Add(controller);
            return controller;
        }
Exemple #29
0
        public bool Grab(IViewportController viewportController, int x, int y)
        {
            this.mx = x;
            this.my = y;

            this.moveAxis = MouseOverAxis(viewportController, x, y);

            if (moveAxis != Vector3.ZERO)
            {
                grabPosition = MouseTo(viewportController, x, y) - this.Position;
                return true;
            }

            return false;
        }
Exemple #30
0
 public new void MouseMove(IViewportController viewportController, int dx, int dy, MouseEventArgs e)
 {
 }
Exemple #31
0
        public Vector3 MouseOverAxis(IViewportController viewportController, int x, int y)
        {
            Ray ray = viewportController.CreateViewportRay(x, y);

            float th = 0.1f;        // thickness
            float len = 1.1f;       // length
            AxisAlignedBox xBox = CreateOffsetBox(new Vector3(0.0f, -th, -th), new Vector3(len, th, th));
            AxisAlignedBox yBox = CreateOffsetBox(new Vector3(-th, 0.0f, -th), new Vector3(th, len, th));
            AxisAlignedBox zBox = CreateOffsetBox(new Vector3(-th, -th, 0.0f), new Vector3(th, th, len));

            if (ray.Intersects(xBox).first && !viewportController.CameraController.IsLookingDownAxis(Vector3.UNIT_X))
                return Vector3.UNIT_X;

            if (ray.Intersects(yBox).first && !viewportController.CameraController.IsLookingDownAxis(Vector3.UNIT_Y))
                return Vector3.UNIT_Y;

            if (ray.Intersects(zBox).first && !viewportController.CameraController.IsLookingDownAxis(Vector3.UNIT_Z))
                return Vector3.UNIT_Z;

            return Vector3.ZERO;
        }
 public View(IViewportController vc)
     : this()
 {
     this.viewportController = vc;
 }
Exemple #33
0
        public void MoveTo(IViewportController viewportController, int x, int y)
        {
            if (grabPosition != Vector3.ZERO)
            {
                Vector3 p = MouseTo(viewportController, x, y);
                Vector3 newPos = p - grabPosition;

                this.Position = Editor.SnapTo((newPos * moveAxis) + (this.Position * (1 - moveAxis)));

                if (this.node != null)
                    this.node.Position = this.Position;
            }
        }
Exemple #34
0
        private Vector3 MouseTo(IViewportController viewportController, int x, int y)
        {
            // determine the active plane
            Plane activePlane = viewportController.CameraController.GetActivePlane(moveAxis, this.Position);

            // raycast onto the active plane
            RaycastResult result = viewportController.MouseToPlane(x, y, activePlane);

            if (result != null)
                return result.Position;

            return Vector3.ZERO;
        }
 public void Initialise(IViewportController controller)
 {
     this.controller = controller;
     this.controller.Initialise(this.Name, this.Handle);
     this.controller.CursorChanged += new CursorEventHandler(controller_CursorChanged);
 }
Exemple #36
0
 public new void MouseUp(IViewportController viewportController, MouseEventArgs e)
 {
 }
Exemple #37
0
        public static Block SelectBlock(IViewportController viewportController, int x, int y)
        {
            Ray ray = viewportController.CreateViewportRay(x, y);
            Block hitBlock = null;
            float d = float.MaxValue;

            foreach (Block block in Editor.Blocks)
            {
                Pair<bool, float> pair = ray.Intersects(block.BoundingBox);

                if (pair.first && pair.second < d)
                {
                    d = pair.second;
                    hitBlock = block;
                }
            }

            return hitBlock;
        }
Exemple #38
0
 public new void MouseMove(IViewportController viewportController, int dx, int dy, MouseEventArgs e)
 {
     Editor.SelectionBox.MouseMove(viewportController, e);
 }
Exemple #39
0
 public new void MouseUp(IViewportController viewportController, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
         Editor.SelectionBox.MouseUp(viewportController, e);
 }
        public bool MouseDown(IViewportController viewportController, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.mouseDownPos = viewportController.MouseToGrid(e.X, e.Y);
                this.selectedGrip = this.GetSelectedGrip(viewportController, e.X, e.Y);

                // create a new box
                if (this.selectedGrip == ResizableBox.MG_NONE)
                {
                    this.selectedObject = null;
                    this.min = mouseDownPos;
                    this.max = mouseDownPos;

                    if (this.isCreated)
                        this.Destroy();
                }
            }

            return this.selectedGrip != ResizableBox.MG_NONE;
        }
        private int GetSelectedGrip(IViewportController viewportController, int x, int y)
        {
            if (this.isCreated)
            {
                foreach (ResizableBox resizableBox in this.resizableBoxes)
                {
                    int grip = resizableBox.MouseOver(viewportController, x, y);

                    if (grip != ResizableBox.MG_NONE)
                        return grip;
                }
            }

            return ResizableBox.MG_NONE;
        }
Exemple #42
0
 public new void MouseDown(IViewportController viewportController, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
         this.mouseDownPosition = viewportController.MouseToGrid(e.X, e.Y);
 }
        private int MouseOverGripIndex(IViewportController viewportController, int x, int y)
        {
            int mouseGripIndex = MG_NONE;

            // the the side grips
            if (viewportController.Viewport.VisibilityMask == vfFlag)
            {
                for (int i = 0; i < this.mouseGrips.Length; i++)
                {
                    Vector3 mouseGrip = mouseGrips[i];
                    Vector2 screenPos = viewportController.GetScreenPosition(mouseGrip);
                    int gripSize = 4;

                    if (x >= screenPos.x - gripSize && x <= screenPos.x + gripSize && y >= screenPos.y - gripSize && y <= screenPos.y + gripSize)
                        mouseGripIndex = i;
                }
            }

            // test for special move grip
            if (mouseGripIndex == MG_NONE)
            {
                Vector2 topLeft = viewportController.GetScreenPosition(this.corners[this.indices[0]]);
                Vector2 bottomRight = viewportController.GetScreenPosition(this.corners[this.indices[2]]);

                if (x > topLeft.x && x < bottomRight.x && y > topLeft.y && y < bottomRight.y)
                    return MG_MOVE;
            }

            return mouseGripIndex;
        }
Exemple #44
0
 public new void MouseMove(IViewportController viewportController, int dx, int dy, MouseEventArgs e)
 {
 }
Exemple #45
0
 public new void MouseUp(IViewportController viewportController, MouseEventArgs e)
 {
 }
Exemple #46
0
 public HeaderView(IViewportController vc)
     : base(vc)
 {
 }
Exemple #47
0
 public Viewport(IViewportController vc)
     : base(vc)
 {
     this.sheet = vc.Worksheet;
 }
Exemple #48
0
 public RowHeaderView(IViewportController vc)
     : base(vc)
 {
     this.ScrollableDirections = ScrollDirection.Vertical;
 }
Exemple #49
0
 public ColumnHeaderView(IViewportController vc)
     : base(vc)
 {
     this.ScrollableDirections = ScrollDirection.Horizontal;
 }
        public bool MouseMove(IViewportController viewportController, System.Windows.Forms.MouseEventArgs e)
        {
            if (this.isCreated)
            {
                // update the visual feedback if we are not doing anything else
                if (this.selectedGrip == ResizableBox.MG_NONE)
                    GetSelectedGrip(viewportController, e.X, e.Y);

                if (e.Button == MouseButtons.Left)
                {
                    Vector3 mousePos = viewportController.MouseToGrid(e.X, e.Y);

                    switch (this.selectedGrip)
                    {
                        case ResizableBox.MG_NONE:      // creating a new box
                            this.max = mousePos;
                            break;
                        case ResizableBox.MG_MOVE:      // moving a box
                            Vector3 movement = mousePos - this.mouseDownPos;
                            this.min += movement;
                            this.max += movement;
                            this.mouseDownPos = mousePos;
                            break;
                        default:
                            this.Resize(mousePos, viewportController.Viewport.VisibilityMask);
                            break;
                    }

                    this.Update();
                }
            }
            else
            {
                if (e.Button == MouseButtons.Left && this.selectedGrip == ResizableBox.MG_NONE)
                    this.Create();
            }

            return this.selectedGrip != ResizableBox.MG_NONE;
        }
Exemple #51
0
 public XRuler(IViewportController vc) : base(vc)
 {
 }
        public bool MouseUp(IViewportController viewportController, MouseEventArgs e)
        {
            bool returnValue = this.selectedGrip != ResizableBox.MG_NONE;

            if (e.Button == MouseButtons.Left)
            {
                if(this.selectedGrip == ResizableBox.MG_NONE)
                {
                    // finish creating a new box
                    this.max = viewportController.MouseToGrid(e.X, e.Y);
                }

                if (min == max)
                    this.Destroy();

                if (min.x == max.x)
                    min.x = max.x + 1;

                if (min.y == max.y)
                    min.y = max.y + 1;

                if (min.z == max.z)
                    min.z = max.z + 1;

                // make sure min an max are around the right way
                Vector3 temp = Editor.MinOf(min, max);
                this.max = Editor.MaxOf(min, max);
                this.min = temp;

                this.Update();
                this.selectedGrip = ResizableBox.MG_NONE;
            }

            return returnValue;
        }