using System;
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 gate
    /// </summary>
    public class GateView : NodeView<Gate>
    {
        public GateView(Gate node) : base(node)
        {
        }


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

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

        public override void InitShape()
        {
            Rectangle rectangle = new Rectangle();
            double side = Math.Sqrt(Radius*Radius/2);
            rectangle.Width = side;
            rectangle.Height = side;
            rectangle.Fill = Brushes.Transparent;
            rectangle.Stroke = new SolidColorBrush(m_model.Color);
            rectangle.StrokeThickness = 2;
            rectangle.RenderTransform = new RotateTransform(45);
            m_uiElement = rectangle;
        }



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