using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using Machinations.FromFlash.machinations.model;

namespace Machinations.GUI
{
    /// <summary>
    /// visualisation of drain
    /// </summary>
    class DrainView : NodeView<Drain>
    {
        public DrainView(Drain node) : base(node)
        {
        }

        protected override void SetMainUiElementPosition(Point value)
        {
            m_uiElement.SetValue(Canvas.LeftProperty, value.X);
            m_uiElement.SetValue(Canvas.TopProperty, value.Y);
        }

        public override int Radius { get { return 30; } }

        public override void InitShape()
        {
            Polygon polygon = new Polygon();
            polygon.Points = new PointCollection(new[]
            {
                new Point(- Radius / 2, - Radius / 3),
                new Point( Radius / 2, - Radius / 3),
                new Point(0,  Radius / 2)
            });
            polygon.Fill = Brushes.Transparent;
            polygon.Stroke = new SolidColorBrush(m_model.Color);
            polygon.StrokeThickness = 2;
            m_uiElement = polygon;
        }

        public override void ColorView(Brush brush)
        {
            ((Polygon)m_uiElement).Stroke = brush;
        }
    }
}
