Use docking-station and screen-configuration

I’m using a Dell Latitude D830 at work with Nvidia Quadro-card. I’m using docking-station Dell D-dock.

In Nvidia-settings i set it up as TwinView and made the external display as Primary screen.
Its working good, but i miss the ability to Un-dock and reconfigure X to switch primary screen. I’ve also installed Gnome-Dock so i can safely un-dock, but the secondary screen remain secondary when i un-dock.
Is there a way to detect screen automatic in dock/undock?