fixed calculation of position when sampleIndex is set in WindowBase#Apply method