private void PopulateAvailableVideoModes() { _lstResolution.ClearItems(); vmList.Clear(); IOrderedEnumerable <VideoMode> modes = from v in SFML.Window.VideoMode.FullscreenModes where (v.Height > 748 && v.Width > 1024) //GOSH I HOPE NOONES USING 16 BIT COLORS. OR RUNNING AT LESS THAN 59 hz orderby v.Height * v.Width ascending select v; if (!modes.Any()) { throw new Exception("No available video modes"); } foreach (VideoMode vm in modes) { if (!vmList.ContainsKey(GetVmString(vm))) { vmList.Add(GetVmString(vm), vm); _lstResolution.AddItem(GetVmString(vm)); } } if ( vmList.Any( x => x.Value.Width == CluwneLib.Screen.Size.X && x.Value.Height == CluwneLib.Screen.Size.Y)) { KeyValuePair <string, VideoMode> curr = vmList.FirstOrDefault( x => x.Value.Width == CluwneLib.Screen.Size.X && x.Value.Height == CluwneLib.Screen.Size.Y); _lstResolution.SelectItem(curr.Key, false); } else { //No match due to different refresh rate in windowed mode. Just pick first resolution based on size only. KeyValuePair <string, VideoMode> curr = vmList.FirstOrDefault( x => x.Value.Width == CluwneLib.Screen.Size.X && x.Value.Height == CluwneLib.Screen.Size.Y); _lstResolution.SelectItem(curr.Key, false); } }
private void PopulateAvailableVideoModes(Listbox resListBox) { resListBox.ClearItems(); _videoModeList.Clear(); var modes = VideoMode.FullscreenModes .Where(v => v.Height > 748 && v.Width > 1024) .OrderBy(v => v.Height * v.Width) .ToList(); if (!modes.Any()) { throw new InvalidOperationException("No available video modes"); } foreach (var vm in modes) { if (!_videoModeList.ContainsKey(GetVmString(vm))) { _videoModeList.Add(GetVmString(vm), vm); resListBox.AddItem(GetVmString(vm)); } } if (_videoModeList.Any(x => x.Value.Width == CluwneLib.Window.Viewport.Size.X && x.Value.Height == CluwneLib.Window.Viewport.Size.Y)) { var currentMode = _videoModeList.FirstOrDefault(x => x.Value.Width == CluwneLib.Window.Viewport.Size.X && x.Value.Height == CluwneLib.Window.Viewport.Size.Y); resListBox.SelectItem(currentMode.Key); } else { //No match due to different refresh rate in windowed mode. Just pick first resolution based on size only. var currentMode = _videoModeList.FirstOrDefault( x => x.Value.Width == CluwneLib.Window.Viewport.Size.X && x.Value.Height == CluwneLib.Window.Viewport.Size.Y); resListBox.SelectItem(currentMode.Key); } }