public static DisplayMode getBestDisplayMode(GraphicsDevice device)
    {
        DisplayMode[] modes = device.getDisplayModes();
        int maxWidth = 0;
        int maxHeight = 0;
        int maxBitDepth = 0;
        int maxRefreshRate = 0;
        for (int i = 0; i < modes.length; i++)
        {
            if (modes[i].getWidth() > maxWidth || modes[i].getHeight() > maxHeight || 
                    (modes[i].getWidth() == maxWidth && modes[i].getHeight() == maxHeight && 
                    (modes[i].getBitDepth() > maxBitDepth || 
                            modes[i].getRefreshRate() > maxRefreshRate)))
            {
                maxHeight = modes[i].getHeight();
                maxWidth = modes[i].getWidth();
                maxBitDepth = modes[i].getBitDepth();
                maxRefreshRate = modes[i].getRefreshRate();
            }
        }
        return new DisplayMode(maxWidth, maxHeight, maxBitDepth, maxRefreshRate);
    }