private static MyDisplayMode[] GetSupportedDisplayModes(Direct3D d3d, int adapterOrdinal) { var modeAvailable = new List <MyDisplayMode>(); var modeMap = new Dictionary <string, MyDisplayMode>(); SharpDX.Direct3D9.Format format = m_backbufferFormat; int modeCount = format == Format.Unknown ? 0 : d3d.GetAdapterModeCount(adapterOrdinal, format); for (int modeIndex = 0; modeIndex < modeCount; modeIndex++) { var mode = d3d.EnumAdapterModes(adapterOrdinal, (SharpDX.Direct3D9.Format)format, modeIndex); string key = format + ";" + mode.Width + ";" + mode.Height + ";" + mode.RefreshRate; MyDisplayMode oldMode; if (!modeMap.TryGetValue(key, out oldMode)) { var displayMode = new MyDisplayMode() { Width = mode.Width, Height = mode.Height, RefreshRate = mode.RefreshRate, AspectRatio = mode.AspectRatio }; modeMap.Add(key, displayMode); modeAvailable.Add(displayMode); } } modeAvailable.Sort(m_refreshRatePriorityComparer); return(modeAvailable.ToArray()); }