コード例 #1
0
ファイル: GraphDoc.cs プロジェクト: toreal/Violet
        public bool checkHitEllipse(gPoint p)
        {
            bool   tf  = false;
            double c_x = (p.point1.X - p.point0.X) / 2;
            double c_y = (p.point2.Y - p.point0.Y) / 2;

            System.Windows.Point center = new System.Windows.Point(p.point0.X + c_x, p.point0.Y + c_y);

            double simpleX      = Math.Sqrt((1 - Math.Pow((p.mouseXY.Y - center.Y), 2) / Math.Pow(c_y, 2)) * Math.Pow(c_x, 2));
            double simpleY      = Math.Sqrt((1 - Math.Pow((p.mouseXY.X - center.X), 2) / Math.Pow(c_x, 2)) * Math.Pow(c_y, 2));
            double higherPlaceX = center.X + simpleX;
            double lowerPlaceX  = center.X - simpleX;
            double higherPlaceY = center.Y + simpleY;
            double lowerPlaceY  = center.Y - simpleY;

            if (p.mouseXY.X <= higherPlaceX && p.mouseXY.X >= higherPlaceX - 3)
            {
                tf = true;
            }
            if (p.mouseXY.X >= lowerPlaceX && p.mouseXY.X <= lowerPlaceX + 3)
            {
                tf = true;
            }
            if (p.mouseXY.Y <= higherPlaceY && p.mouseXY.Y >= higherPlaceY - 3)
            {
                tf = true;
            }
            if (p.mouseXY.Y >= lowerPlaceY && p.mouseXY.Y <= lowerPlaceY + 3)
            {
                tf = true;
            }

            return(tf);
        }
コード例 #2
0
ファイル: GraphDoc.cs プロジェクト: toreal/Violet
        public int checkHitWhich(List <gPath> l, gPoint gp, int drawType)
        {
            int whichOne = -1;

            for (int i = l.Count - 1; i >= 0; i--)
            {
                if (drawType < 3 || drawType == 4)
                {
                    if (l[i].controlBtn1 != gp.point0)
                    {
                        continue;
                    }
                    if (l[i].controlBtn2 != gp.point1)
                    {
                        continue;
                    }
                    if (l[i].controlBtn3 != gp.point2)
                    {
                        continue;
                    }
                    if (l[i].controlBtn4 != gp.point3)
                    {
                        continue;
                    }
                }
                if (drawType == 3)
                {
                    if (l[i].drawtype != drawType)
                    {
                        continue;
                    }
                    if (l[i].controlBtn1 != gp.point0)
                    {
                        continue;
                    }
                    if (l[i].controlBtn4 != gp.point3)
                    {
                        continue;
                    }
                }
                whichOne = i;
            }
            return(whichOne);
        }
コード例 #3
0
ファイル: GraphDoc.cs プロジェクト: toreal/Violet
        public bool checkHitRect(gPoint p)
        {
            bool tf = false;

            if ((p.mouseXY.X <= p.point1.X + 3 && p.mouseXY.X >= p.point1.X - 3) || (p.mouseXY.X >= p.point0.X - 3 && p.mouseXY.X <= p.point0.X + 3))
            {
                if (p.mouseXY.Y <= p.point2.Y && p.mouseXY.Y >= p.point0.Y)
                {
                    tf = true;
                }
            }
            if ((p.mouseXY.Y <= p.point2.Y + 3 && p.mouseXY.Y >= p.point2.Y - 3) || (p.mouseXY.Y >= p.point0.Y - 3 && p.mouseXY.Y <= p.point0.Y + 3))
            {
                if (p.mouseXY.X <= p.point1.X && p.mouseXY.X >= p.point0.X)
                {
                    tf = true;
                }
            }
            return(tf);
        }