public IEnumerable <Path> DrawRectancles(IEnumerable <RectancleInfo> rectancles) { RectancleCreator figureCreator = new RectancleCreator(); IPathCreator pathCreator = new SolidPathCreator(); List <Path> paths = new List <Path>(); foreach (var item in rectancles) { Path path = pathCreator.GetPath(item.brush); path.Data = figureCreator.GetFigures(info.CopyWithPoints( PointConverter.ToCanvas(item.leftUp, info), PointConverter.ToCanvas(item.rightUp, info))); paths.Add(path); Path newpath = pathCreator.GetPath(figureCreator.newRectancle.brush); newpath.Data = figureCreator.GetFigures(info.CopyWithPoints( figureCreator.newRectancle.leftUp, figureCreator.newRectancle.rightUp)); paths.Add(newpath); figureCreator.newRectancle = null; } return(paths); }
private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (temp == new Point(-1, -1)) { temp = e.GetPosition(MyCanvas); } else { Point point = e.GetPosition(MyCanvas); CanvasInfo info = new CanvasInfo(MyCanvas.ActualWidth, MyCanvas.ActualHeight, GetStep()); if (temp.X <= point.X) { AddRectancle(PointConverter.ToCoor(temp, info), PointConverter.ToCoor(point, info), color); } else { AddRectancle(PointConverter.ToCoor(point, info), PointConverter.ToCoor(temp, info), color); } temp = new Point(-1, -1); Draw(GetStep()); } }