Code:
public static void RotateScreen(bool clockwise)
        {
        // Retrieving current settings
        // ...

        // Rotating the screen
        if (clockwise) {   // <- ?
        if (newMode.dmDisplayOrientation DMDO_DEFAULT)
            {
        newMode.dmDisplayOrientation--;
            }
        //else
        //newMode.dmDisplayOrientation = DMDO_270;

        // Swapping width and height;
        uint temp = newMode.dmPelsWidth;
        newMode.dmPelsWidth = newMode.dmPelsHeight;
        newMode.dmPelsHeight = temp;

        // Capturing the operation result
        // ...
        }