using System.Windows.Shapes;

namespace GraphDrawer
{
    public class Edge
    {
        public Line Line { get; }
        public ArrowLine ArrowLine { get; }
        public Vertex StartVertex { get; }
        public Vertex FinishVertex { get; }
        public int? Weight { get; set; }
        
        public Edge(Line line, Vertex v1, Vertex v2)
        {
            Line = line;
            StartVertex = v1;
            FinishVertex = v2;
        }

        public Edge(ArrowLine line, Vertex v1, Vertex v2)
        {
            ArrowLine = line;
            StartVertex = v1;
            FinishVertex = v2;
        }

        public Edge(Line line, Vertex v1, Vertex v2, int weight)
        {
            Line = line;
            StartVertex = v1;
            FinishVertex = v2;
            Weight = weight;
        }

        public bool IsFocused
        {
            get
            {
                if (ArrowLine == null)
                    return true;
                return false;
            }
        }

        public static double GetCenterByX(Edge edge)
        {
            var x = (edge.FinishVertex.X + edge.StartVertex.X) / 2;
            return x;
        }

        public static double GetCenterByY(Edge edge)
        {
            var y = (edge.FinishVertex.Y + edge.StartVertex.Y) / 2;
            return y;
        }
    }
}