Win.CodeNavi.frmMain.frmMain_Load C# (CSharp) Method

frmMain_Load() private method

Load handler for the main form
private frmMain_Load ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void frmMain_Load(object sender, EventArgs e)
        {
            // Pretty...
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.DoubleBuffer, true);

            // So our key handler will see them
            KeyPreview = true;

            // Setup a handler for the exit
            Application.ApplicationExit += new EventHandler(this.OnApplicationExit);

            // Correct version
            Assembly assembly = Assembly.GetExecutingAssembly();
            FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
            string strVersion = fvi.FileVersion;
            this.Text = "NCC Group Code Navi - " + strVersion;

            // Load the previously search code paths and search terms
            // This saves the paths so they are persistent over runs
            if (Properties.Settings.Default.CodeFolders != null && Properties.Settings.Default.CodeFolders.Count > 0)
            {
                StringCollection strCodePathCollection = new StringCollection();
                foreach (String strPath in Properties.Settings.Default.CodeFolders)
                {
                    txtCodePath.Items.Add(strPath);
                }
            }
            if (Properties.Settings.Default.SearchStrings != null && Properties.Settings.Default.SearchStrings.Count > 0)
            {
                StringCollection strSearchStringCollection = new StringCollection();
                foreach (String strSearchString in Properties.Settings.Default.SearchStrings)
                {
                    txtSearch.Items.Add(strSearchString);
                }
            }

            if (Properties.Settings.Default.CaseSensitive == true) opCaseSearch.Checked = true;
            else opCaseSearch.Checked = false;
            if (Properties.Settings.Default.Regex == true) opRegexSearch.Checked = true;
            else opRegexSearch.Checked = false;
            if (Properties.Settings.Default.IgnoreTest == true) optIgnoreTest.Checked = true;
            else optIgnoreTest.Checked = false;
            if (Properties.Settings.Default.IgnoreComments == true) optIgnoreComments.Checked = true;
            else optIgnoreComments.Checked = false;
            if (Properties.Settings.Default.NotesWordWrap == true)
            {
                cmdWordWrap.Checked = true;
                richNotes.WordWrap = true;
            }
            else
            {
                cmdWordWrap.Checked = false;
                richNotes.WordWrap = false;
            }
            if (Properties.Settings.Default.AutoSaveNotes == true)
            {
                optAutoSaveNotes.Checked = true;
                timerSave.Start();
            }
            else
            {
                timerSave.Stop();
            }

            if (Properties.Settings.Default.ExtensionSets != null && Properties.Settings.Default.ExtensionSets.Count > 0)
            {
                foreach (String strExt in Properties.Settings.Default.ExtensionSets)
                {
                    txtExt.Items.Add(strExt);
                }
            }
            else
            {
                doExtensionReset();
            }
            if (Properties.Settings.Default.Extensions != null) {
                if (Properties.Settings.Default.Extensions.Count() == 0)
                {
                    txtExt.Text = "*.*";
                }
                else
                {
                    txtExt.Text = Properties.Settings.Default.Extensions;

                }
            }
            else txtExt.Text = "*.*";

            if (Properties.Settings.Default.CodeFolders != null && Properties.Settings.Default.CodeFolders.Count > 0)
            {
                txtCodePath.Text = txtCodePath.Items[0].ToString();
                frmBrowser frmBStart = null;

                if (Directory.Exists(txtCodePath.Text))
                {
                    frmBStart = new frmBrowser(txtCodePath.Text, "*.*", this);
                    frmBStart.MdiParent = this;

                    //initialBrowser = new Thread(new ThreadStart(frmBStart.Show));
                    //initialBrowser.Start();
                    frmBStart.Show();
                }
                else
                {
                    //frmBStart = new frmBrowser("C:\\","*.*",this);
                }
            }

            if (Properties.Settings.Default.SearchStrings != null && Properties.Settings.Default.SearchStrings.Count > 0) txtSearch.Text = txtSearch.Items[0].ToString();

            if (Properties.Settings.Default.ShowNotesPanel == true)
            {
                tabNotes.Visible = true;
                cmdshowNotesPanel.Checked = true;
            }
            else
            {
                tabNotes.Visible = false;
                cmdshowNotesPanel.Checked = false;
            }

            if (Properties.Settings.Default.NotesFont != null) richNotes.SelectionFont = Properties.Settings.Default.NotesFont;
            try
            {
                if (Properties.Settings.Default.NotesColour != null)
                {
                    richNotes.SelectionColor = Properties.Settings.Default.NotesColour;
                }

            }
            catch (Exception)
            {

            }

            try
            {
                richNotes.LoadFile(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\NCCCodeNavi.rtf");
                bNotesPending = false;
            }
            catch (Exception)
            {
                bNotesPending = false;
            }

            if(Directory.Exists(AssemblyDirectory + "\\Grepify.Profiles")){
                foreach(string strFile in Directory.GetFiles(AssemblyDirectory + "\\Grepify.Profiles")){
                    optGrepify.DropDownItems.Add(Path.GetFileNameWithoutExtension(strFile));
                }
            } else {
                optGrepify.DropDownItems.Add("Profile directory does not exist - " + AssemblyDirectory + "\\Grepify.Profiles");
            }

            if (File.Exists(AssemblyDirectory + "\\NCCCodeNavi.Exclusions\\NCCCodeNavi.exclusions"))
            {
                richExclusions.LoadFile(AssemblyDirectory + "\\NCCCodeNavi.Exclusions\\NCCCodeNavi.exclusions");
            }

            //Twitter twTemp = new Twitter();
            //twTemp.SetRT(this.richNCCNews,this.tabNCCNews);
            //workerThread = new Thread(new ThreadStart(twTemp.Get));

            VersionCheck vCheck = new VersionCheck();
            workerThreadV = new Thread(new ThreadStart(vCheck.Get));

            // Start the worker thread.
            //workerThread.Start();
            workerThreadV.Start();
        }