private void View_OnCreateFigureButton_Click(object sender, EventArgs e) { if (_pointsBuffer.Count == 0) { _view.ShowError(new Exception("Список точек пуст!")); return; } var factory = AppDependencies.CreataFactory(); var points = new Point[_pointsBuffer.Count]; for (int i = 0; i < points.Length; i++) { points[i] = (Point)_pointsBuffer[i]; } try { var figure = factory.Create(points); var color = _view.GetSelectedColor(); var figureDrawer = new FigureDrawer( new FiguresDataAdapter(figure), color, System.Drawing.Color.Black, System.Drawing.Color.Black ); _figuresBuffer.Add(figureDrawer); _outFigures.Add(figureDrawer); } catch (Exception err) { _view.ShowError(err); } }
public IEnumerable <FigureDrawer> Deserialize(string fileName) { var stream = new StreamReader(fileName); var xml = new XmlSerializer(typeof(List <XmlFigureData>)); var factory = AppDependencies.CreataFactory(); var figures = new List <FigureDrawer>(); var data = xml.Deserialize(stream); foreach (var item in data as List <XmlFigureData> ) { var figure = factory.Create(item.Points); var adapter = new FiguresDataAdapter(figure); var vertexColor = Color.FromName(ValidateColorName(item.VertexColorName)); var centerColor = Color.FromName(ValidateColorName(item.CenterColorName)); var penColor = Color.FromName(ValidateColorName(item.PenColorName)); var drawer = new FigureDrawer(adapter, penColor, vertexColor, centerColor); figures.Add(drawer); } return(figures); }