public Settings(string pathToOptionIniGenerals, string pathToOptionIniHeureH) { InitializeComponent(); // Initialisation _pathToOptionIniGenerals = pathToOptionIniGenerals; _pathToOptionIniHeureH = pathToOptionIniHeureH; // Lire le fichier option.ini _optionIniResolutionGenerals = IniHelper.GetOptionIni(_pathToOptionIniGenerals); _optionIniResolutionHeureH = IniHelper.GetOptionIni(_pathToOptionIniHeureH); // Trouver les résolutions supportées List <Dimension> resolutionsDispo = new List <Dimension>(); DEVMODE vDevMode = new DEVMODE(); int i = 0; while (EnumDisplaySettings(null, i, ref vDevMode)) { if (vDevMode.dmPelsWidth >= 800 && vDevMode.dmPelsHeight >= 600 && resolutionsDispo.Where(d => d.Width == vDevMode.dmPelsWidth && d.Height == vDevMode.dmPelsHeight).Count() <= 0) { resolutionsDispo.Add(new Dimension { Width = vDevMode.dmPelsWidth, Height = vDevMode.dmPelsHeight }); } i++; } // Initialiser les combobox résolution i = 0; _resolutionsItems = new Dictionary <int, Dimension>(); foreach (Dimension dim in resolutionsDispo.OrderBy(d => d.Width).ThenBy(d => d.Height)) { _resolutionsItems.Add(i, dim); string description = string.Format("{0}x{1}", dim.Width, dim.Height); comboBoxGenerals.Items.Add(new ComboBoxItem { Content = description }); comboBoxHeureH.Items.Add(new ComboBoxItem { Content = description }); i++; } }
private void ActiverGregwareCustomizations() { // Initialisation bool isFullscreenGregware = (bool)Properties.Settings.Default["FullscreenModeGregware"]; bool isScrollGregware = (bool)Properties.Settings.Default["ScrollGregware"]; bool isGentool = (bool)Properties.Settings.Default[string.Format("Current{0}Gentool", _currentGameName)]; int resolutionX = 0; int resolutionY = 0; // Validité if (!isFullscreenGregware && !isScrollGregware) { return; } // Trouver la résolution actuelle if (isFullscreenGregware) { string pathToOptionIni; if (_currentGameName.Equals("Generals", StringComparison.OrdinalIgnoreCase)) { pathToOptionIni = _pathToOptionIniGenerals; } else if (_currentGameName.Equals("HeureH", StringComparison.OrdinalIgnoreCase)) { pathToOptionIni = _pathToOptionIniHeureH; } else { throw new Exception(string.Format("Unknown game name {0}", _currentGameName)); } IniHelper.OptionIni optionIniResolution = IniHelper.GetOptionIni(pathToOptionIni); resolutionX = optionIniResolution.ResolutionX; resolutionY = optionIniResolution.ResolutionY; } // Activer _fullScreenGregware = new GregwareCustomizations(isFullscreenGregware, isScrollGregware, isGentool, resolutionX, resolutionY, _uiScheduler); _fullScreenGregware.Activer(); }