Exemplo n.º 1
0
        public void OnMouseMove(Renderer r, MouseEventArgs e)
        {
            if ((tempActive == true) && (!((myToolManager.PathTool.IsActive) && (myToolManager.PathTool.TempActive))))
            {
                Vector2 worldMouseLoc = Vector2.FromPointF(
                        r.ScreenToWorld(e.Location));

                if (r.CurrentCamera == r.CamOrtho)
                {
                    if ((e.Button == MouseButtons.Left)&&(!zoomPanOnly))
                    {
                        Vector2 topLeftPoint;
                        Vector2 worldDownPoint = Vector2.FromPointF(
                                r.ScreenToWorld(downPoint));
                        double width = Math.Abs(
                                worldDownPoint.X - worldMouseLoc.X);
                        double height = Math.Abs(
                                worldDownPoint.Y - worldMouseLoc.Y);
                        topLeftPoint = TopLeftPoint(worldDownPoint, worldMouseLoc);
                        selectionRectangle = new Rect(topLeftPoint.X,
                                topLeftPoint.Y, width, height);

                        foreach (ISelectable renderable in r.Selectables)
                        {
                            if (renderable == null) continue;
                            if ((selectionRectangle.Overlaps(renderable.GetBoundingPolygon().CalculateBoundingRectangle()))&&
                                (!renderable.IsSelected))
                            {
                                renderable.OnSelect();
                                GestureExpData(this, new GestureExpHRIEventArgs("Tool:SelectTool|box drag|select using box|" + renderable.GetName() + "|" + renderable.GetBoundingPolygon().Center.X.ToString() + "|" + renderable.GetBoundingPolygon().Center.Y.ToString() + "|(world)"));
                            }
                            else if ((!selectionRectangle.Overlaps(renderable.GetBoundingPolygon().CalculateBoundingRectangle())) &&
                                (renderable.IsSelected))
                            {
                                renderable.OnDeselect();
                                GestureExpData(this, new GestureExpHRIEventArgs("Tool:SelectTool|box drag|deselect using box|" + renderable.GetName() + "|" + renderable.GetBoundingPolygon().Center.X.ToString() + "|" + renderable.GetBoundingPolygon().Center.Y.ToString() + "|(world)"));
                            }
                        }
                    }
                    else if (e.Button == MouseButtons.Right)
                    {
                        int dx = (int)(e.X - downPoint.X);
                        int dy = (int)(-e.Y + downPoint.Y);
                        PointF newTranslation = new PointF(
                                origTrans.X - dx / r.WorldTransform.Scale,
                                origTrans.Y - dy / r.WorldTransform.Scale);
                        r.Translation = newTranslation;
                    }
                }
                else if (r.CurrentCamera == r.CamFree && e.Button == MouseButtons.Left)
                {
                    r.CamFree.Yaw((e.X - currentPoint.X) / 3);
                    r.CamFree.Pitch((e.Y - currentPoint.Y) / 2);
                }
                else if (r.CurrentCamera == r.CamChase)
                {
                    r.CamChase.Pitch((e.Y - currentPoint.Y) / 2);
                }
                currentPoint = new PointF(e.X, e.Y);
            }
        }