public MainWindow() { try { //Prevent multiple instances of the application from running. using (Mutex mutex = new Mutex(false, @"IV-Play MameUI")) { if (!mutex.WaitOne(0, false)) { MessageBox.Show("An instance of IV-Play is already running.", "Warning:"); Close(); return; } //Enabled all the winforms visual styles to give it the Windows look. Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Load the background image for the main form. SettingsManager.GetBackgroundImage(); //Display the form. While the status is retry it will just create new instances //This allows us to close the form and restart the application when refreshing //our data files. MainForm mainForm; DialogResult dialogResult = System.Windows.Forms.DialogResult.Retry; while (true) { if (dialogResult == System.Windows.Forms.DialogResult.Retry) { mainForm = new MainForm(); mainForm.BringToFront(); dialogResult = mainForm.ShowDialog(); } else { break; } } Close(); } } catch (Exception ex) { Logger.WriteToLog(ex); Close(); } }
private void SaveSettings() { //Enums Settings.Default.art_area = _cmbArtView.SelectedIndex; Settings.Default.art_type = _cmbArtType.SelectedIndex; //Checkboxes Settings.Default.GameListManufacturer = _chkManu.Checked; Settings.Default.GameListYear = _chkYear.Checked; Settings.Default.rotate_background = _chkRotateBackground.Checked; Settings.Default.large_icon = _chkItemZoom.Checked; Settings.Default.non_working_overlay = _chkArtNonWorking.Checked; Settings.Default.hide_nonworking_mechanical_games = _chkShowMechanical.Checked; Settings.Default.filter_on_input = _chkInputFilter.Checked; //Favorites Settings.Default.favorites_mode = _cmdFavMode.SelectedIndex; //Font Settings.Default.game_list_font = gameFont; Settings.Default.info_font = infoFont; //Command line Settings.Default.command_line_switches = autoCompleteTextBox1.Text; //Colors Settings.Default.info_font_color = infoColor; Settings.Default.game_list_color = _colorPickerParent.Color; Settings.Default.game_list_clone_color = _colorPickerClone.Color; Settings.Default.favorites_color = _colorPickerFav.Color; Settings.Default.art_border_color = _colorPickerBorder.Color; //BorderUpDown Settings.Default.art_border_width = Convert.ToInt32(_borderWidth.Value); //Opacity Settings.Default.art_opacity = _trackBarOpacity.Value; //Background if (_bgImageChanged) { Settings.Default.bkground_image = _backgroundImage; Settings.Default.bkground_directory = _backgroundPath; } //Logic to change background //1. Rotate initally off, turned on, but the background image wasn't changed. Change BG now if (!_initialBackgroundValue && !_bgImageChanged && _chkRotateBackground.Checked) { SettingsManager.GetBackgroundImage(); _picBG.Image = SettingsManager.BackgroundImage; _initialBackgroundValue = true; } //2. Checkback was initially off, but user pressed on and off again several times WITHOUT // changing the background image - as that takes precedence. else if ((_initialBackgroundValue && !_bgImageChanged && !_chkRotateBackground.Checked)) { _initialBackgroundValue = false; } //Art View Paths string Paths = ""; SettingsManager.ArtPaths = new List <string>(); SettingsManager.ArtPaths.Add("None"); foreach (var item in _listArtViews.Items) { SettingsManager.ArtPaths.Add(item.ToString()); Paths += item.ToString() + '|'; } Paths.TrimEnd('|'); Settings.Default.art_view_folders = Paths; SettingsManager.WriteSettingsToFile(); if (ConfigSaved != null) { ConfigSaved(null, null); } }