Пример #1
0
        public Shape draw_Shapes(GraphicalObject graphical_object)
        {
            string          shape = graphical_object.Shape;
            SolidColorBrush brush = Pick_color(graphical_object.Type);

            switch (shape)
            {
            case "rectangle":
                Rectangle rectangle = new Rectangle();
                rectangle.Width             = graphical_object.Width;
                rectangle.Height            = graphical_object.Height;
                rectangle.Fill              = brush;
                rectangle.VerticalAlignment = VerticalAlignment.Top;
                Canvas.SetLeft(rectangle, graphical_object.Left);
                Canvas.SetTop(rectangle, graphical_object.Top);
                return(rectangle);

            case "elipse":
                Ellipse ellipse = new Ellipse();
                ellipse.Width             = graphical_object.Width;
                ellipse.Height            = graphical_object.Height;
                ellipse.Fill              = brush;
                ellipse.VerticalAlignment = VerticalAlignment.Top;
                Canvas.SetLeft(ellipse, graphical_object.Left);
                Canvas.SetTop(ellipse, graphical_object.Top);
                return(ellipse);

            default:
                return(new Rectangle());
            }
        }
Пример #2
0
        public List <GraphicalObject> ReadFromFile(string path)
        {
            string[] lines = File.ReadAllLines(path);
            List <GraphicalObject> list = new List <GraphicalObject>();

            foreach (string line in lines)
            {
                GraphicalObject graphical_object = ConvertLineToGraphicalObject(line);
                list.Add(graphical_object);
            }
            return(list);
        }