public MainForm()
        {
            if (!Properties.Settings.Default.UpgradeCompleted)
            {
                Properties.Settings.Default.Upgrade();
                if (!Properties.Settings.Default.UpgradeCompleted)
                {
                    //this is an initial install - detect language if possible
                    if (Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName.Equals(UILANGUAGE_FR, StringComparison.InvariantCultureIgnoreCase))
                        Properties.Settings.Default.UILanguage = UILANGUAGE_FR;
                    else if (Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName.Equals(UILANGUAGE_ES, StringComparison.InvariantCultureIgnoreCase))
                        Properties.Settings.Default.UILanguage = UILANGUAGE_ES;
                    else
                        Properties.Settings.Default.UILanguage = UILANGUAGE_EN;
                }
                Properties.Settings.Default.UpgradeCompleted = true;
                Properties.Settings.Default.Save();
            }

            //set the UI language BEFORE initializeComponent...
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Properties.Settings.Default.UILanguage);
            System.Globalization.CultureInfo test1 = Thread.CurrentThread.CurrentUICulture;
            _generalResourceManager = new FrameworkClassReplacements.SingleAssemblyResourceManager("GeneralLanguageContent", System.Reflection.Assembly.GetExecutingAssembly(), typeof(Program));

            InitializeComponent();

            _tokenizer = new PoorMansTSqlFormatterLib.Tokenizers.TSqlStandardTokenizer();
            _parser = new PoorMansTSqlFormatterLib.Parsers.TSqlStandardParser();

            //Now that controls exist, update UI from settings.
            if (Properties.Settings.Default.UILanguage.Equals(UILANGUAGE_EN)) englishToolStripMenuItem.Checked = true;
            if (Properties.Settings.Default.UILanguage.Equals(UILANGUAGE_FR)) frenchToolStripMenuItem.Checked = true;
            if (Properties.Settings.Default.UILanguage.Equals(UILANGUAGE_ES)) spanishToolStripMenuItem.Checked = true;

            displayTokenListToolStripMenuItem.Checked = Properties.Settings.Default.DisplayTokenList;
            displayParsedSqlToolStripMenuItem.Checked = Properties.Settings.Default.DisplayParsedSqlXml;
            displayFormattingOptionsAreaToolStripMenuItem.Checked = Properties.Settings.Default.DisplayFormattingOptions;

            radio_Formatting_Standard.Checked = Properties.Settings.Default.Formatter.Equals(FORMATTER_STANDARD, StringComparison.InvariantCultureIgnoreCase);
            txt_Indent.Text = Properties.Settings.Default.Indent;
            txt_IndentWidth.Text = Properties.Settings.Default.IndentWidth.ToString();
            txt_MaxWidth.Text =  Properties.Settings.Default.MaxWidth.ToString();
            chk_ExpandCommaLists.Checked = Properties.Settings.Default.ExpandCommaLists;
            chk_TrailingCommas.Checked = Properties.Settings.Default.TrailingCommas;
            chk_SpaceAfterComma.Checked = Properties.Settings.Default.SpaceAfterComma;
            chk_ExpandBooleanExpressions.Checked = Properties.Settings.Default.ExpandBooleanExpressions;
            chk_ExpandCaseStatements.Checked = Properties.Settings.Default.ExpandCaseStatements;
            chk_ExpandBetweenConditions.Checked = Properties.Settings.Default.ExpandBetweenConditions;
            chk_BreakJoinOnSections.Checked = Properties.Settings.Default.BreakJoinOnSections;
            chk_UppercaseKeywords.Checked = Properties.Settings.Default.UppercaseKeywords;
            chk_Coloring.Checked = Properties.Settings.Default.StandardColoring;
            chk_EnableKeywordStandardization.Checked = Properties.Settings.Default.EnableKeywordStandardization;

            radio_Formatting_Identity.Checked = Properties.Settings.Default.Formatter.Equals(FORMATTER_IDENTITY, StringComparison.InvariantCultureIgnoreCase);
            chk_IdentityColoring.Checked = Properties.Settings.Default.IdentityColoring;

            _settingsLoaded = true;

            SetFormatter();
            UpdateDisplayLayout();
        }
        public MainForm()
        {
            if (!Properties.Settings.Default.UpgradeCompleted)
            {
                Properties.Settings.Default.Upgrade();
                if (!Properties.Settings.Default.UpgradeCompleted)
                {
                    //this is an initial install - detect language if possible
                    if (Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName.Equals(UILANGUAGE_FR, StringComparison.InvariantCultureIgnoreCase))
                    {
                        Properties.Settings.Default.UILanguage = UILANGUAGE_FR;
                    }
                    else if (Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName.Equals(UILANGUAGE_ES, StringComparison.InvariantCultureIgnoreCase))
                    {
                        Properties.Settings.Default.UILanguage = UILANGUAGE_ES;
                    }
                    else
                    {
                        Properties.Settings.Default.UILanguage = UILANGUAGE_EN;
                    }
                }
                Properties.Settings.Default.UpgradeCompleted = true;
                Properties.Settings.Default.Save();
            }

            //set the UI language BEFORE initializeComponent...
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Properties.Settings.Default.UILanguage);
            System.Globalization.CultureInfo test1 = Thread.CurrentThread.CurrentUICulture;
            _generalResourceManager = new FrameworkClassReplacements.SingleAssemblyResourceManager("GeneralLanguageContent", System.Reflection.Assembly.GetExecutingAssembly(), typeof(Program));

            InitializeComponent();

            _tokenizer = new PoorMansTSqlFormatterLib.Tokenizers.TSqlStandardTokenizer();
            _parser    = new PoorMansTSqlFormatterLib.Parsers.TSqlStandardParser();

            //Now that controls exist, update UI from settings.
            if (Properties.Settings.Default.UILanguage.Equals(UILANGUAGE_EN))
            {
                englishToolStripMenuItem.Checked = true;
            }
            if (Properties.Settings.Default.UILanguage.Equals(UILANGUAGE_FR))
            {
                frenchToolStripMenuItem.Checked = true;
            }
            if (Properties.Settings.Default.UILanguage.Equals(UILANGUAGE_ES))
            {
                spanishToolStripMenuItem.Checked = true;
            }

            displayTokenListToolStripMenuItem.Checked             = Properties.Settings.Default.DisplayTokenList;
            displayParsedSqlToolStripMenuItem.Checked             = Properties.Settings.Default.DisplayParsedSqlXml;
            displayFormattingOptionsAreaToolStripMenuItem.Checked = Properties.Settings.Default.DisplayFormattingOptions;

            radio_Formatting_Standard.Checked = Properties.Settings.Default.Formatter.Equals(FORMATTER_STANDARD, StringComparison.InvariantCultureIgnoreCase);
            txt_Indent.Text                          = Properties.Settings.Default.Indent;
            txt_IndentWidth.Text                     = Properties.Settings.Default.IndentWidth.ToString();
            txt_MaxWidth.Text                        = Properties.Settings.Default.MaxWidth.ToString();
            txt_StatementBreaks.Text                 = Properties.Settings.Default.NewStatementLineBreaks.ToString();
            txt_ClauseBreaks.Text                    = Properties.Settings.Default.NewClauseLineBreaks.ToString();
            chk_ExpandCommaLists.Checked             = Properties.Settings.Default.ExpandCommaLists;
            chk_TrailingCommas.Checked               = Properties.Settings.Default.TrailingCommas;
            chk_SpaceAfterComma.Checked              = Properties.Settings.Default.SpaceAfterComma;
            chk_ExpandBooleanExpressions.Checked     = Properties.Settings.Default.ExpandBooleanExpressions;
            chk_ExpandCaseStatements.Checked         = Properties.Settings.Default.ExpandCaseStatements;
            chk_ExpandBetweenConditions.Checked      = Properties.Settings.Default.ExpandBetweenConditions;
            chk_ExpandInLists.Checked                = Properties.Settings.Default.ExpandInLists;
            chk_BreakJoinOnSections.Checked          = Properties.Settings.Default.BreakJoinOnSections;
            chk_UppercaseKeywords.Checked            = Properties.Settings.Default.UppercaseKeywords;
            chk_Coloring.Checked                     = Properties.Settings.Default.StandardColoring;
            chk_EnableKeywordStandardization.Checked = Properties.Settings.Default.EnableKeywordStandardization;

            radio_Formatting_Identity.Checked = Properties.Settings.Default.Formatter.Equals(FORMATTER_IDENTITY, StringComparison.InvariantCultureIgnoreCase);
            chk_IdentityColoring.Checked      = Properties.Settings.Default.IdentityColoring;

            radio_Formatting_Obfuscate.Checked = Properties.Settings.Default.Formatter.Equals(FORMATTER_OBFUSCATE, StringComparison.InvariantCultureIgnoreCase);
            chk_RandomizeKeywordCase.Checked   = Properties.Settings.Default.RandomizeKeywordCase;
            chk_RandomizeColor.Checked         = Properties.Settings.Default.RandomizeColor;
            chk_RandomizeLineLength.Checked    = Properties.Settings.Default.RandomizeLineLength;
            chk_PreserveComments.Checked       = Properties.Settings.Default.PreserveComments;
            chk_KeywordSubstitution.Checked    = Properties.Settings.Default.KeywordSubstitution;

            _settingsLoaded = true;

            SetFormatter();
            UpdateDisplayLayout();
        }