private void Shapes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: (e.NewItems[0] as INotifyPropertyChanged).PropertyChanged += Shapes_PropertyChanged; ShapesListMenu.IsEnabled = true; switch (e.NewItems[0]) { case PointShape point: CanvasPaint.Children.Add(CanvasBUS.NewShapeForCancas(point)); ShapesListMenu.IsEnabled = false; break; case EllipseShape ellipse: CanvasPaint.Children.Add(CanvasBUS.NewShapeForCancas(ellipse)); break; case PolygonShape polygon: CanvasPaint.Children.Add(CanvasBUS.NewShapeForCancas(polygon)); break; case PolylineShape polyline: CanvasPaint.Children.Add(CanvasBUS.NewShapeForCancas(polyline)); break; default: break; } break; case NotifyCollectionChangedAction.Remove: switch (e.OldItems[0]) { case PointShape point: var points = CanvasPaint.Children.OfType <Ellipse>().Where(p => p.Name == PointShape.pointName).ToList(); foreach (var item in points) { CanvasPaint.Children.Remove(item); } break; default: break; } break; case NotifyCollectionChangedAction.Replace: MessageBox.Show("Replace - 75Main - not be"); break; case NotifyCollectionChangedAction.Reset: ShapesListMenu.IsEnabled = false; action = null; CanvasPaint.Children.Clear(); Fill.IsEnabled = false; break; } }
public void NewShapeForCancasTest4() { shapeBUS = new ShapeBUS(); shapeBUS.AddPoint(new Point(0, 0)); CanvasBUS.NewShapeForCancas(shapeBUS.Shapes[0] as PointShape); }
public void NewShapeForCancasTest2() { shapeBUS = new ShapeBUS(); shapeBUS.AddPoint(new Point(0, 0)); shapeBUS.AddPoint(new Point(5, 5)); shapeBUS.CreateEllipse(); CanvasBUS.NewShapeForCancas(shapeBUS.Shapes[0] as EllipseShape); }
public void NewShapeForCancasTest1() { shapeBUS = new ShapeBUS(); shapeBUS.AddPoint(new Point(0, 0)); shapeBUS.AddPoint(new Point(5, 8)); shapeBUS.AddPoint(new Point(5, 4)); shapeBUS.AddPoint(new Point(0, 0)); shapeBUS.CreatePolygon(); CanvasBUS.NewShapeForCancas(shapeBUS.Shapes[0] as PolygonShape); }
public void NewShapeForCancasTest3() { shapeBUS = new ShapeBUS(); shapeBUS.AddPoint(new Point(0, 0)); shapeBUS.AddPoint(new Point(3, 50)); shapeBUS.CreatePolyline(); shapeBUS.AddPoint(new Point(5, 5)); shapeBUS.CreatePolyline(); CanvasBUS.NewShapeForCancas(shapeBUS.Shapes[0] as PolylineShape); }