The general Two-Higgs Doublet Model in a gauge-invariant form