bool IUiController.MouseDown(object sender, MouseEventArgs e)
        {
            double width  = Overlay.east - Overlay.west;
            double height = Overlay.north - Overlay.south;

            double      range  = Math.Max(width / 40, height / 40);
            Coordinates cursor = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y);

            if (cursor.Distance(Coordinates.FromLatLng(Overlay.north, Overlay.west)) < range)
            {
                dragCorner = DragCorners.NW;
                drag       = true;
            }
            if (cursor.Distance(Coordinates.FromLatLng(Overlay.north, (Overlay.west + Overlay.east) / 2)) < range)
            {
                dragCorner = DragCorners.N;
                drag       = true;
            }
            if (cursor.Distance(Coordinates.FromLatLng(Overlay.north, Overlay.east)) < range)
            {
                dragCorner = DragCorners.NE;
                drag       = true;
            }

            if (cursor.Distance(Coordinates.FromLatLng((Overlay.north + Overlay.south) / 2, Overlay.west)) < range)
            {
                dragCorner = DragCorners.W;
                drag       = true;
            }

            if (cursor.Distance(Coordinates.FromLatLng((Overlay.north + Overlay.south) / 2, (Overlay.west + Overlay.east) / 2)) < range)
            {
                dragCorner = DragCorners.C;
                drag       = true;
            }

            if (cursor.Distance(Coordinates.FromLatLng((Overlay.north + Overlay.south) / 2, Overlay.east)) < range)
            {
                dragCorner = DragCorners.E;
                drag       = true;
            }

            if (cursor.Distance(Coordinates.FromLatLng(Overlay.south, Overlay.west)) < range)
            {
                dragCorner = DragCorners.SW;
                drag       = true;
            }

            if (cursor.Distance(Coordinates.FromLatLng(Overlay.south, (Overlay.west + Overlay.east) / 2)) < range)
            {
                dragCorner = DragCorners.S;
                drag       = true;
            }

            if (cursor.Distance(Coordinates.FromLatLng(Overlay.south, Overlay.east)) < range)
            {
                dragCorner = DragCorners.SE;
                drag       = true;
            }

            if (drag)
            {
                mouseDown = cursor;
            }
            return(drag);
        }
        bool IUiController.MouseMove(object sender, MouseEventArgs e)
        {
            if (drag)
            {
                Coordinates cursor = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y);

                switch (dragCorner)
                {
                case DragCorners.NW:
                    Overlay.north = cursor.Lat;
                    Overlay.west  = cursor.Lng;
                    break;

                case DragCorners.N:
                    Overlay.north = cursor.Lat;
                    break;

                case DragCorners.NE:
                    Overlay.north = cursor.Lat;
                    Overlay.east  = cursor.Lng;
                    break;

                case DragCorners.W:
                    Overlay.west = cursor.Lng;
                    break;

                case DragCorners.C:
                    Overlay.north -= (mouseDown.Lat - cursor.Lat);
                    Overlay.west  -= (mouseDown.Lng - cursor.Lng);
                    Overlay.south -= (mouseDown.Lat - cursor.Lat);
                    Overlay.east  -= (mouseDown.Lng - cursor.Lng);

                    break;

                case DragCorners.E:
                    Overlay.east = cursor.Lng;
                    break;

                case DragCorners.SW:
                    Overlay.south = cursor.Lat;
                    Overlay.west  = cursor.Lng;
                    break;

                case DragCorners.S:
                    Overlay.south = cursor.Lat;
                    break;

                case DragCorners.SE:
                    Overlay.south = cursor.Lat;
                    Overlay.east  = cursor.Lng;
                    break;

                default:
                    break;
                }
                mouseDown = cursor;
                UpdateTextBoxes();
                UpdateLines();
                return(true);
            }
            else
            {
                Control wnd    = (Control)sender;
                double  width  = Overlay.east - Overlay.west;
                double  height = Overlay.north - Overlay.south;

                double      range      = Math.Max(width / 40, height / 40);
                Coordinates cursor     = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y);
                DragCorners dragCorner = DragCorners.None;
                if (cursor.Distance(Coordinates.FromLatLng(Overlay.north, Overlay.west)) < range)
                {
                    dragCorner = DragCorners.NW;
                }
                if (cursor.Distance(Coordinates.FromLatLng(Overlay.north, (Overlay.west + Overlay.east) / 2)) < range)
                {
                    dragCorner = DragCorners.N;
                }
                if (cursor.Distance(Coordinates.FromLatLng(Overlay.north, Overlay.east)) < range)
                {
                    dragCorner = DragCorners.NE;
                }

                if (cursor.Distance(Coordinates.FromLatLng((Overlay.north + Overlay.south) / 2, Overlay.west)) < range)
                {
                    dragCorner = DragCorners.W;
                }

                if (cursor.Distance(Coordinates.FromLatLng((Overlay.north + Overlay.south) / 2, (Overlay.west + Overlay.east) / 2)) < range)
                {
                    dragCorner = DragCorners.C;
                }

                if (cursor.Distance(Coordinates.FromLatLng((Overlay.north + Overlay.south) / 2, Overlay.east)) < range)
                {
                    dragCorner = DragCorners.E;
                }

                if (cursor.Distance(Coordinates.FromLatLng(Overlay.south, Overlay.west)) < range)
                {
                    dragCorner = DragCorners.SW;
                }

                if (cursor.Distance(Coordinates.FromLatLng(Overlay.south, (Overlay.west + Overlay.east) / 2)) < range)
                {
                    dragCorner = DragCorners.S;
                }

                if (cursor.Distance(Coordinates.FromLatLng(Overlay.south, Overlay.east)) < range)
                {
                    dragCorner = DragCorners.SE;
                }

                switch (dragCorner)
                {
                case DragCorners.SE:
                case DragCorners.NW:
                    wnd.Cursor = Cursors.SizeNWSE;
                    break;

                case DragCorners.N:
                case DragCorners.S:
                    wnd.Cursor = Cursors.SizeNS;
                    break;

                case DragCorners.W:
                case DragCorners.E:
                    wnd.Cursor = Cursors.SizeWE;
                    break;

                case DragCorners.C:
                    wnd.Cursor = Cursors.Hand;
                    break;

                case DragCorners.SW:
                case DragCorners.NE:
                    wnd.Cursor = Cursors.SizeNESW;
                    break;

                default:
                    wnd.Cursor = Cursors.Default;
                    break;
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        public bool MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (Earth3d.MainWindow.StudyImageset == null)
            {
                mouseDown = false;
                return(false);
            }
            Tile root = TileCache.GetTile(0, 0, 0, Earth3d.MainWindow.StudyImageset, null);

            if (root == null)
            {
                mouseDown = false;
                return(false);
            }
            if (e.Button == MouseButtons.Right && (root is SkyImageTile))
            {
                anchored = !anchored;
                popup.SetPivotMode(anchored);
                if (anchored)
                {
                    anchoredPoint1 = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y);
                    TourPlace place = new TourPlace("", anchoredPoint1.Dec, anchoredPoint1.RA, Classification.Unidentified, "UMA", ImageSetType.Sky, -1);
                    Earth3d.MainWindow.SetLabelText(place, false);
                    if (root is TangentTile)
                    {
                        TangentTile tile   = (TangentTile)root;
                        Vector3d    vector = tile.TransformPoint(12, 12);
                        vector = Coordinates.GeoTo3dDouble(anchoredPoint1.Lat, anchoredPoint1.Lng);
                        double x;
                        double y;
                        tile.UnTransformPoint(vector, out x, out y);
                    }
                    else if (root is SkyImageTile)
                    {
                        SkyImageTile tile = (SkyImageTile)root;
                        anchorPoint1 = tile.GetImagePixel(anchoredPoint1);
                    }
                }
                mouseDown = true;
                return(true);
            }
            else if (e.Button == MouseButtons.Left)
            {
                dragging = true;
                pntDown  = e.Location;
                if (anchored)
                {
                    if (root is TangentTile)
                    {
                        startRotation = Earth3d.MainWindow.StudyImageset.Rotation;
                        startCenterX  = Earth3d.MainWindow.StudyImageset.OffsetX;
                        startCenterY  = Earth3d.MainWindow.StudyImageset.OffsetY;
                        startScale    = Earth3d.MainWindow.StudyImageset.BaseTileDegrees;
                        Coordinates downPoint = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y);
                        startLength = anchoredPoint1.Distance(downPoint);
                        startAngle  = anchoredPoint1.Angle(downPoint) / RC;
                    }
                    else if (root is SkyImageTile)
                    {
                        SkyImageTile tile = (SkyImageTile)root;
                        anchoredPoint2 = Earth3d.MainWindow.GetCoordinatesForScreenPoint(e.X, e.Y);
                        anchorPoint2   = tile.GetImagePixel(anchoredPoint2);
                    }
                }
                mouseDown = true;
                return(true);
            }
            else
            {
                mouseDown = false;
                return(false);
            }
        }