Пример #1
0
        /// <summary>
        /// Добавить фигуру в GraphicsPath
        /// </summary>
        /// <param name="path">GraphicsPath</param>
        /// <param name="figure">Добавляемая фигура</param>
        private static void AddFigureToGraphicsPath(GraphicsPath path, BaseFigure figure)
        {
            var points = figure.Points.GetPoints();

            if (figure.GetType() == typeof(Line))
            {
                path.AddLine(points[0], points[1]);
            }
            else if (figure.GetType() == typeof(Circle))
            {
                var circleRect = CircleDrawer.MakeRectangle(points[0], points[1],
                                                            RoundShapeType.Circle);
                path.AddEllipse(circleRect);
            }
            else if (figure.GetType() == typeof(Ellipse))
            {
                var ellipseRect = CircleDrawer.MakeRectangle(points[0], points[1],
                                                             RoundShapeType.Ellipse);
                path.AddEllipse(ellipseRect);
            }
            else if (figure.GetType() == typeof(Polyline))
            {
                path.AddLines(points.ToArray());
            }
            else if (figure.GetType() == typeof(Polygon))
            {
                path.AddPolygon(points.ToArray());
            }
        }
Пример #2
0
 /// <summary>
 /// Рисовка маркеров фигуры
 /// </summary>
 /// <param name="figure"></param>
 /// <param name="canvas"></param>
 public static void DrawSelection(BaseFigure figure, Graphics canvas)
 {
     if (figure.GetType() == typeof(Line))
     {
         var lineDrawer = new LineDrawer();
         lineDrawer.DrawSelection(figure, canvas);
     }
     else if (figure.GetType() == typeof(Polyline))
     {
         var drawer = new PolylineDrawer();
         drawer.DrawSelection(figure, canvas);
     }
     else if (figure.GetType() == typeof(Circle))
     {
         var circleDrawer = new CircleDrawer();
         circleDrawer.DrawSelection(figure, canvas);
     }
     else if (figure.GetType() == typeof(Ellipse))
     {
         var ellipseDrawer = new EllipseDrawer();
         ellipseDrawer.DrawSelection(figure, canvas);
     }
     else if (figure.GetType() == typeof(Polygon))
     {
         var polygonDrawer = new PolygonDrawer();
         polygonDrawer.DrawSelection(figure, canvas);
     }
 }
 /// <summary>
 /// Проверка типа фигуры
 /// </summary>
 /// <param name="figure"></param>
 /// <returns></returns>
 public static bool IsFigureFillable(BaseFigure figure)
 {
     if (figure.GetType() == typeof(Circle) ||
         figure.GetType() == typeof(Ellipse) ||
         figure.GetType() == typeof(Polygon))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }