// Copyright (c) 2007 Omer Rauchwerger (a.k.a rauchy) (omer@rauchy.net) // All rights reserved. // // This file is part of Regionerate. // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, // or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Text.RegularExpressions; using System.Windows.Forms; using Rauchy.Regionerate.Presentation.Components.Properties; namespace Rauchy.Regionerate.Presentation.Components { public partial class SettingsForm : Form { #region Constructors (1)  public SettingsForm() { InitializeComponent(); LoadSettings(); } #endregion Constructors  #region Methods (15)  // Public Methods (1)  // [rgn] Public Methods (1) public void SetAutoCollapseEnabled( bool value ) { autoCollapseRegions.Enabled = value; } // Private Methods (14)  // [rgn] Private Methods (14) private void browse_Click( object sender, EventArgs e ) { OpenFileDialog openFileDialog = new OpenFileDialog { Title = "Select your custom Code Layout file", Filter = "Regionerate Code Layout File (*.xml)|*.xml" }; if ( openFileDialog.ShowDialog() == DialogResult.OK ) { customCodeLayoutPath.Text = openFileDialog.FileName; } } private void cancel_Click( object sender, EventArgs e ) { Close(); } private void contact_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e ) { Process.Start( Urls.Contact ); } private void donate_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e ) { Process.Start( Urls.Donations ); } private void edit_Click( object sender, EventArgs e ) { try { SaveSettings(); // Use DialogResult.Ignore to indicate the caller to edit the custom code layout file. // Yeah, its ugly, but subscribing and publishing an event for this seems too much ATM. DialogResult = DialogResult.Ignore; Close(); //Process.Start( customCodeLayoutPath.Text ); //if ( // MessageBox.Show( "Would you like to Regionerate to reload the custom Code Layout?", "Regionerate", // MessageBoxButtons.YesNo ) == // DialogResult.Yes ) //{ // Refresh(); //} } catch ( FileNotFoundException fnfExecption ) { MessageBox.Show( fnfExecption.Message, "Regionerate", MessageBoxButtons.OK, MessageBoxIcon.Error ); } } private void forums_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e ) { Process.Start( Urls.Forums ); } private void LoadSettings() { alwaysShowCodeLayoutBrowser.Checked = Settings.Default.AlwaysShowCodeLayoutBrowser; autoCollapseRegions.Checked = Settings.Default.AutoCollapseRegions; useDefaultCodeLayout.Checked = Settings.Default.UseDefaultCodeLayout; useCustomCodeLayout.Checked = !Settings.Default.UseDefaultCodeLayout; customCodeLayoutPath.Text = Settings.Default.CustomCodeLayoutPath; holyWarPreventionSwitch.Selection = Settings.Default.HolyWarPreventionMode; // Parse the keyboard shortcut value to retrieve the button and key. Regex expression = new Regex( @"(?