Beispiel #1
0
        public override bool IsPointInFigure(Point mousePoint)
        {
            List <Point> focusPoints = new MathEllipse().FindFocusPoints(first, second);
            Point        center      = focusPoints[0];
            Point        right       = focusPoints[1];
            Point        left        = focusPoints[2];
            Point        top         = focusPoints[3];
            Point        bottom      = focusPoints[4];

            if (mousePoint == center || mousePoint == right || mousePoint == left || mousePoint == top || mousePoint == bottom)
            {
                return(true);
            }
            else if (mousePoint.X <= right.X && mousePoint.X >= top.X && mousePoint.Y <= right.Y && mousePoint.Y >= top.Y) // top right quarter
            {
                return(true);
            }
            else if (mousePoint.X <= right.X && mousePoint.X >= bottom.X && mousePoint.Y >= right.Y && mousePoint.Y <= bottom.Y) //bottom right quarter
            {
                return(true);
            }
            else if (mousePoint.X <= bottom.X && mousePoint.X >= left.X && mousePoint.Y <= bottom.Y && mousePoint.Y >= left.Y) //bottom left quarter
            {
                return(true);
            }
            else if (mousePoint.X >= left.X & mousePoint.X <= top.X && mousePoint.Y <= left.Y && mousePoint.Y >= top.Y) // top left quarter
            {
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        public void HighlightSelectedFigure(AFigure aFigure)

        {
            if (aFigure != null)
            {
                List <Point> points = aFigure.DoFigureMath();
                if (points.Count > 50)
                {
                    if (points.Count == 360)     // круг
                    {
                        for (int i = 0; i < points.Count; i = i + 45)
                        {
                            if (i == 0 || i == 90 || i == 180 || i == 270 || i == 360)
                            {
                            }
                            else
                            {
                                DrawLine(points[i], points[i], 7, Color.Red);
                            }
                        }
                    }
                    else
                    {
                        Point        first       = aFigure.ReturnPoints()[0];
                        Point        second      = aFigure.ReturnPoints()[1];
                        List <Point> focusPoints = new MathEllipse().FindFocusPoints(first, second);
                        Point        right       = focusPoints[1];
                        Point        left        = focusPoints[2];
                        Point        top         = focusPoints[3];
                        Point        bottom      = focusPoints[4];
                        DrawLine(right, right, 7, Color.Red);
                        DrawLine(left, left, 7, Color.Red);
                        DrawLine(top, top, 7, Color.Red);
                        DrawLine(bottom, bottom, 7, Color.Red);
                    }
                }
                else
                {
                    for (int i = 0; i < points.Count; i++)
                    {
                        DrawLine(points[i], points[i], 7, Color.Red);
                    }
                }
            }
        }