static public UIElement StarControlFactory(double scale) { // Draw star shape Array starShapes = Enum.GetValues(typeof(StarShape)); StarShape randomShape = (StarShape)starShapes.GetValue(_random.Next(0, starShapes.Length)); UIElement starControl; //ISSUE: Is this type good? switch (randomShape) { case StarShape.Rectangle: starControl = new Rectangle() { Fill = new SolidColorBrush(RandomColor()) }; break; case StarShape.Ellipse: starControl = new Ellipse() { Fill = new SolidColorBrush(RandomColor()) }; break; case StarShape.Star: starControl = new Star() { Fill = new SolidColorBrush(RandomColor()) }; break; default: starControl = new Star() { Fill = new SolidColorBrush(RandomColor()) }; break; } return(starControl); }
private void starToolStripMenuItem_Click_1(object sender, EventArgs e) { ShapeToDraw = new StarShape(); shapeButton.Image = starButton.Image; }