public static PathDirection ConnectionDirection(this PathDirection input, PathDirection other)
        {
            var dir = PathDirection.None;

            input.GetFlags().ForEach(direction =>
            {
                switch (direction)
                {
                case PathDirection.None:
                    dir = PathDirection.None;
                    break;

                case PathDirection.Bottom:
                    if (other.HasFlag(PathDirection.Top))
                    {
                        dir = PathDirection.Bottom;
                    }
                    break;

                case PathDirection.Left:
                    if (other.HasFlag(PathDirection.Right))
                    {
                        dir = PathDirection.Left;
                    }
                    break;

                case PathDirection.Right:
                    if (other.HasFlag(PathDirection.Left))
                    {
                        dir = PathDirection.Right;
                    }
                    break;

                case PathDirection.Top:
                    if (other.HasFlag(PathDirection.Bottom))
                    {
                        dir = PathDirection.Top;
                    }
                    break;

                default:
                    dir = PathDirection.None;
                    break;
                }
            });
            return(dir);
        }
 public static IEnumerable <PathDirection> GetFlags(this PathDirection input)
 {
     return(Enum.GetValues(input.GetType()).Cast <PathDirection>().Where(value => input.HasFlag(value)));
 }