The critical Z-invariant Ising model via dimers