Ejemplo n.º 1
0
 protected bool IsInObject(PointD a, PointD b,
     VectorGraphObject obj, Point ptClient, float tolerance)
 {
     var len = (float)Geometry.GetSpanLength(a, b);
     VectorGraphObject smb = obj.Copy();
     float scale = len / smb.Width;
     // масштабирование
     smb.Scale(scale, scale);
     // перенос
     smb.Move2Point(a.ToPointF());
     // наклон
     smb.Rotate((float)Math.Atan2(b.Y - a.Y, b.X - a.X));
     // проверить попадание
     return smb.IsPointIn(ptClient, tolerance);
 }
Ejemplo n.º 2
0
        protected void DrawObject(RectangleD worldRect, Rectangle canvasRect, Graphics g, Pen pen,
            VectorGraphObject obj, PenStorage penDic)
        {
            PointD a = Conversion.WorldToScreen(linePoints[0], worldRect, canvasRect);
            PointD b = Conversion.WorldToScreen(linePoints[1], worldRect, canvasRect);
            var len = (float)Geometry.GetSpanLength(a, b);

            VectorGraphObject smb = obj.Copy();
            smb.PaintLines(lineColor);
            smb.PaintFills(ShapeFillColor);
            smb.Alpha = ShapeAlpha;
            float scale = len / smb.Width;
            // масштабирование
            smb.Scale(scale, scale);
            // перенос
            smb.Move2Point(a.ToPointF());
            // наклон
            smb.Rotate((float)Math.Atan2(b.Y - a.Y, b.X - a.X));
            // нарисовать
            smb.Draw(g, penDic, Selected ? PenWidth + 2 : PenWidth);
        }