Exemplo n.º 1
0
        public Shape2D(Shape gShape, ShapeProperties properties)
        {
            this.gShape = gShape;
            color       = properties.color;
            radius      = properties.size / 2;
            ShapeType   = properties.shapeType;

            X = properties.X;
            Y = properties.Y;

            trail = new Trail(this);
            trail.Draw((Canvas)gShape.Parent);
        }
Exemplo n.º 2
0
        public Shape CreateShape(ShapeProperties shapeProperties)
        {
            // Instantiate XAML shape based on type
            Shape newShape = (Shape)Activator.CreateInstance(shapeDict[shapeProperties.shapeType]);

            // Set shape to proper size
            newShape.Height = shapeProperties.size;
            newShape.Width  = shapeProperties.size;

            // Set shape color
            newShape.Fill = new SolidColorBrush(shapeProperties.color);

            // Position shape
            Canvas.SetLeft(newShape, shapeProperties.X + shapeProperties.size);
            Canvas.SetBottom(newShape, shapeProperties.Y + shapeProperties.size);

            // Add shape to the window
            simCanvas.Children.Add(newShape);

            return(newShape);
        }