Esempio n. 1
0
        /// <summary>
        /// Handles saving the user specified options.
        /// </summary>
        /// <param name="sender">System parameter</param>
        /// <param name="e">System parameter</param>

        private void btnOK_Click(object sender, System.EventArgs e)
        {
            // Store the values in the globals
            GeneralSettings.MaximumMRUPaths               = cboPathMRUCount.SelectedIndex + 1;
            GeneralSettings.HighlightForeColor            = Convertors.ConvertColorToString(ForeColorButton.SelectedColor);
            GeneralSettings.HighlightBackColor            = Convertors.ConvertColorToString(BackColorButton.SelectedColor);
            GeneralSettings.ResultsForeColor              = Convertors.ConvertColorToString(btnResultsWindowForeColor.SelectedColor);
            GeneralSettings.ResultsBackColor              = Convertors.ConvertColorToString(btnResultsWindowBackColor.SelectedColor);
            GeneralSettings.ResultsContextForeColor       = Convertors.ConvertColorToString(btnResultsContextForeColor.SelectedColor);
            GeneralSettings.ResultsFont                   = Convertors.ConvertFontToString(rtxtResultsPreview.Font);
            GeneralSettings.ShowExclusionErrorMessage     = chkShowExclusionErrorMessage.Checked;
            GeneralSettings.SaveSearchOptionsOnExit       = chkSaveSearchOptions.Checked;
            GeneralSettings.FilePanelFont                 = Convertors.ConvertFontToString(__FileFont);
            GeneralSettings.DetectFileEncoding            = chkDetectFileEncoding.Checked;
            GeneralSettings.EncodingPerformance           = (int)cboPerformance.SelectedValue;
            GeneralSettings.UseEncodingCache              = chkUseEncodingCache.Checked;
            GeneralSettings.LogDisplaySavePosition        = chkSaveMessagesPosition.Checked;
            GeneralSettings.ExclusionsDisplaySavePosition = chkSaveExclusionsPosition.Checked;
            GeneralSettings.UsebSearchAccentColor         = chkLabelColor.Checked;

            // set Server SQL information
            GeneralSettings.UseDataBase          = chkUseDataBase.Checked;
            GeneralSettings.UseIntegritySecurity = chkIntegritySecurity.Checked;
            GeneralSettings.Login    = txtLogin.Text;
            GeneralSettings.Password = txtPassword.Text;
            GeneralSettings.Server   = cboServer.Text;
            GeneralSettings.Database = cboDataBase.Text;

            // set default log display positions if save position is disabled
            if (!GeneralSettings.LogDisplaySavePosition)
            {
                // set log display window and column positions to default values
                GeneralSettingsReset.LogDisplaySetDefaultPositions();
            }

            // set default exclusions display positions if save position is disabled
            if (!GeneralSettings.ExclusionsDisplaySavePosition)
            {
                // set exclusions display window and column positions to default values
                GeneralSettingsReset.ExclusionsDisplaySetDefaultPositions();
            }

            // Only load new language on a change
            LanguageItem item = (LanguageItem)cboLanguage.SelectedItem;

            if (!GeneralSettings.Language.Equals(item.Culture))
            {
                GeneralSettings.Language = item.Culture;
                Language.Load(GeneralSettings.Language);
                __LanguageChange = true;
            }

            // set shortcuts
            if (!Registry.IsInstaller())
            {
                Shortcuts.SetDesktopShortcut(chkDesktopShortcut.Checked);
                Shortcuts.SetStartMenuShortcut(chkStartMenuShortcut.Checked);
            }

            SaveEditors();

            SaveFileEncodings();

            Core.PluginManager.Save();

            // handle right click search change
            if (__RightClickUpdate)
            {
                try
                {
                    string path         = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "bSearch.AdminProcess.exe");
                    string agPath       = string.Format("\"{0}\"", Application.ExecutablePath);
                    string explorerText = string.Format("\"{0}\"", Language.GetGenericText("SearchExplorerItem"));
                    string args         = string.Format("\"{0}\" {1} {2}", chkRightClickOption.Checked.ToString(), agPath, explorerText);

                    API.UACHelper.AttemptPrivilegeEscalation(path, args, false);
                }
                catch (Exception ex)
                {
                    // TODO
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
            }

            this.Close();
        }