Energy confinement and MHD activity in shaped TCV plasmas with localized electron cyclotron heating