public SquareShapeView (Context context, ShapeViewModel shapeViewModel) : base (context) { _shapeViewModel = shapeViewModel; _shapeViewModel.PropertyChanged += ShapeViewModel_PropertyChanged; Initialize (); }
public async Task AddNewShape (int maxHeight, int maxWidth) { var shape = await _shapeFactory.GeneralShapeRandom (maxHeight,maxWidth); ShapeBase shapeInfo; if (shape is CircleShape) shapeInfo = await _webService.GetShapeInforAsync (shape); else shapeInfo = shape; RelativeLayout.LayoutParams layoutParams= new RelativeLayout.LayoutParams (shapeInfo.Radius * 2, shapeInfo.Radius * 2); layoutParams.LeftMargin = shapeInfo.Center_X - shapeInfo.Radius; layoutParams.TopMargin = shapeInfo.Center_Y - shapeInfo.Radius; ShapeViewModel viewModel = new ShapeViewModel (shapeInfo); if (shapeInfo is CircleShape) { var circleView = new CirclesShapeView (_context, viewModel); _mainLayout.AddView (circleView,layoutParams); } if (shapeInfo is SquareShape) { var squareView = new SquareShapeView (_context, viewModel); _mainLayout.AddView (squareView, layoutParams); } }