Example #1
0
        internal void InitializeForm()
        {
            Form1 form = (Form1)Owner;


            //Init
            InitializeComponent();
            SetLanguage();
            ControlUtil.SetContextMenuStrip(this, new[] { proxyHostTextBox, domainTextBox, passwordTextBox, usernameTextBox, customBrowserTextBox, specificFolderTextBox, backupExtensionTextBox, backupCustomFolderTextBox,
                                                          searchHistoryNumericUpDown, hideLinesNumericUpDown, proxyPortNumericUpDown, recentFilesNumberNumericUpDown, noteModeSizeXNumericUpDown, (Control)noteModeSizeYNumericUpDown });
            optionsTreeView.ExpandAll();


            //Data
            OptionManager.SetListExtensions(this);
            String autoFormatFiles = ConfigUtil.GetStringParameter("AutoFormatFiles");

            TextFont     = ConfigUtil.GetFontParameter("FontInUse");
            previousFont = TextFont;
            String[] argbFontColor = ConfigUtil.GetStringParameter("FontInUseColorARGB").Split(new[] { ';' });
            TextFontColor     = Color.FromArgb(Convert.ToInt32(argbFontColor[0]), Convert.ToInt32(argbFontColor[1]), Convert.ToInt32(argbFontColor[2]), Convert.ToInt32(argbFontColor[3]));
            previousFontColor = TextFontColor;
            String[] argbBackgroundColor = ConfigUtil.GetStringParameter("BackgroundColorARGB").Split(new[] { ';' });
            TextBackgroundColor     = Color.FromArgb(Convert.ToInt32(argbBackgroundColor[0]), Convert.ToInt32(argbBackgroundColor[1]), Convert.ToInt32(argbBackgroundColor[2]), Convert.ToInt32(argbBackgroundColor[3]));
            previousBackgroundColor = TextBackgroundColor;

            previousHighlightURL = ConfigUtil.GetBoolParameter("HighlightURL");
            previousLanguage     = ConfigUtil.GetStringParameter("Language"); //languageComboBox.SelectedItem.ToString();
            List <PasswordObject> passwordList = PasswordUtil.GetStringParameters(new[] { "ProxyUsername", "ProxyPassword", "ProxyDomain" });

            OptionManager.CheckProxyStatusEnabled(this);
            int periodicVersionCheck = ConfigUtil.GetIntParameter("PeriodicVersionCheck");

            previousSendTo            = ShellManager.ExistsSendToLink();
            previousOpenWith          = ShellManager.ExistsOpenWithLink();
            previousJumpListActivated = ConfigUtil.GetBoolParameter("ActiveJumpList");


            //Tab - File
            switch (ConfigUtil.GetIntParameter("SettingFolder"))
            {
            case 0:
                lastUsedFolderRadioButton.Checked = false;
                specificFolderRadioButton.Checked = true;
                break;

            case 1:
                lastUsedFolderRadioButton.Checked = true;
                specificFolderRadioButton.Checked = false;
                break;
            }

            specificFolderTextBox.Text           = ConfigUtil.GetStringParameter("SpecificFolder");
            folderOpenedFileCheckBox.Checked     = ConfigUtil.GetBoolParameter("OverrideFolderWithActiveFile");
            recentFilesNumberNumericUpDown.Value = ConfigUtil.GetIntParameter("MaxNumRecentFile");


            //Tab - Encoding
            useExistingCheckBox.Checked   = ConfigUtil.GetBoolParameter("DefaultEncoding");
            defaultComboBox.SelectedIndex = ConfigUtil.GetIntParameter("Encoding");


            //Tab - Opening
            htmlCheckBox.Checked = autoFormatFiles.Contains(".html");
            xmlCheckBox.Checked  = autoFormatFiles.Contains(".xml");
            hostsConfiguratorCheckBox.Checked = ConfigUtil.GetBoolParameter("AutoOpenHostsConfigurator");
            hostsConfiguratorTabColorComboBox.SelectedIndex = ColorUtil.GetIndexFromTabColor(ConfigUtil.GetColorParameter("ColorHostsConfigurator"));
            nullCharCheckBox.Checked = ConfigUtil.GetBoolParameter("IgnoreNullChar");


            //Tab - Saving
            createBackupCheckBox.Checked = ConfigUtil.GetBoolParameter("BackupEnabled");
            backupExtensionTextBox.Text  = ConfigUtil.GetStringParameter("BackupExtension");

            switch (ConfigUtil.GetIntParameter("BackupExtensionPosition"))
            {
            case 0:
                backupAddExtensionRadioButton.Checked     = true;
                backupReplaceExtensionRadioButton.Checked = false;
                break;

            case 1:
                backupAddExtensionRadioButton.Checked     = false;
                backupReplaceExtensionRadioButton.Checked = true;
                break;
            }

            backupIncrementalCheckBox.Checked = ConfigUtil.GetBoolParameter("BackupIncremental");

            switch (ConfigUtil.GetIntParameter("BackupLocation"))
            {
            case 0:
                backupEditedFileRadioButton.Checked   = true;
                backupCustomFolderRadioButton.Checked = false;
                break;

            case 1:
                backupEditedFileRadioButton.Checked   = false;
                backupCustomFolderRadioButton.Checked = true;
                break;
            }

            backupCustomFolderTextBox.Text = ConfigUtil.GetStringParameter("BackupLocationCustom");


            //Tab - Session
            automaticSessionSaveCheckBox.Checked = ConfigUtil.GetBoolParameter("AutomaticSessionSave");


            //Tab - Search
            showSearchPanelCheckBox.Checked   = !ConfigUtil.GetBoolParameter("SearchReplacePanelDisabled");
            caseSensitiveCheckBox.Checked     = ConfigUtil.GetBoolParameter("SearchCaseSensitive");
            loopAtEOFCheckBox.Checked         = ConfigUtil.GetBoolParameter("SearchLoopAtEOF");
            searchHistoryNumericUpDown.Value  = ConfigUtil.GetIntParameter("MaxNumSearchHistory");
            highlightsResultsCheckBox.Checked = ConfigUtil.GetBoolParameter("SearchHighlightsResults");

            switch (ConfigUtil.GetIntParameter("SearchReturn"))
            {
            case 0:
                searchReturnRadioButton1.Checked = true;
                searchReturnRadioButton2.Checked = false;
                break;

            case 1:
                searchReturnRadioButton1.Checked = false;
                searchReturnRadioButton2.Checked = true;
                break;
            }


            //Tab - Text
            wordWrapCheckBox.Checked                  = !ConfigUtil.GetBoolParameter("WordWrapDisabled");
            fontLabel1.Text                           = StringUtil.CheckStringLengthEnd(ConfigUtil.GetStringParameter("FontInUse"), maxCharsFont);
            fontColorTextBox.BackColor                = TextFontColor;
            backgroundColorTextBox.BackColor          = TextBackgroundColor;
            urlsCheckBox.Checked                      = previousHighlightURL;
            useSpacesInsteadTabsCheckBox.Checked      = ConfigUtil.GetBoolParameter("SpacesInsteadTabs");
            keepInitialSpacesOnReturnCheckBox.Checked = ConfigUtil.GetBoolParameter("KeepInitialSpacesOnReturn");
            keepBulletListOnReturnCheckBox.Checked    = ConfigUtil.GetBoolParameter("KeepBulletListOnReturn");


            //Tab - Language
            languageComboBox.EditValue                  = previousLanguage;
            sourceImageComboBoxEdit.EditValue           = LanguageUtil.GetLongCultureForGoogleTranslator(ConfigUtil.GetStringParameter("Translation").Substring(0, 2));
            destinationImageComboBoxEdit.EditValue      = LanguageUtil.GetLongCultureForGoogleTranslator(ConfigUtil.GetStringParameter("Translation").Substring(3, 2));
            useSelectedSettingsLanguageCheckBox.Checked = ConfigUtil.GetBoolParameter("TranslationUseSelect");


            //Tab - Tab
            tabCloseButtonOnComboBox.SelectedIndex = ConfigUtil.GetIntParameter("TabCloseButtonMode");
            tabPositionComboBox.SelectedIndex      = ConfigUtil.GetIntParameter("TabPosition");
            tabOrientationComboBox.SelectedIndex   = ConfigUtil.GetIntParameter("TabOrientation");
            tabMultilineCheckBox.Checked           = ConfigUtil.GetBoolParameter("TabMultiline");

            switch (ConfigUtil.GetIntParameter("TabsSwitchType"))
            {
            case 0:
                tabsSwitchModeKeyboardRadioButton.Checked = true;
                break;

            case 1:
                tabsSwitchModeMouseRadioButton.Checked = true;
                break;
            }


            //Tab - Note Mode
            noteModeTabsCheckBox.Checked     = ConfigUtil.GetBoolParameter("NoteModeTabs");
            noteModeSizeXNumericUpDown.Value = ConfigUtil.GetIntParameter("NoteModeSizeX");
            noteModeSizeYNumericUpDown.Value = ConfigUtil.GetIntParameter("NoteModeSizeY");


            //Tab - View
            stayOnTopCheckBox.Checked = !ConfigUtil.GetBoolParameter("StayOnTopDisabled");
            if (form.WindowMode == Customs.CustomForm.WindowModeEnum.Fullscreen)
            {
                stayOnTopCheckBox.Enabled = false;
            }

            minimizeOnTrayIconCheckBox.Checked = !ConfigUtil.GetBoolParameter("MinimizeOnTrayIconDisabled");
            splashScreenCheckBox.Checked       = ConfigUtil.GetBoolParameter("ShowSplashScreen");
            toolbarCheckBox.Checked            = !ConfigUtil.GetBoolParameter("ToolbarInvisible");
            statusBarCheckBox.Checked          = !ConfigUtil.GetBoolParameter("StatusBarInvisible");
            internalExplorerCheckBox.Checked   = !ConfigUtil.GetBoolParameter("InternalExplorerInvisible");
            lineNumbersCheckBox.Checked        = ConfigUtil.GetBoolParameter("LineNumbersVisible");

            hideLinesCheckBox.Checked      = ConfigUtil.GetBoolParameter("CheckLineNumber");
            hideLinesNumericUpDown.Value   = ConfigUtil.GetIntParameter("CheckLineNumberMax");
            hideLinesCheckBox.Enabled      = lineNumbersCheckBox.Checked;
            hideLinesNumericUpDown.Enabled = hideLinesCheckBox.Checked && hideLinesCheckBox.Enabled;


            //Tab - Look & Feel
            renderModeComboBox.SelectedIndex = ConfigUtil.GetIntParameter("LookAndFeel");


            //Tab - Internet
            enableProxySettingsCheckBox.Checked = ConfigUtil.GetBoolParameter("ProxyEnabled");
            usernameTextBox.Text              = (passwordList[0]).value;
            passwordTextBox.Text              = CodingUtil.DecodeByte((passwordList[1]).value);
            domainTextBox.Text                = (passwordList[2]).value;
            proxyHostTextBox.Text             = ConfigUtil.GetStringParameter("ProxyHost");
            proxyPortNumericUpDown.Value      = ConfigUtil.GetIntParameter("ProxyPort");
            defaultBrowserRadioButton.Checked = ConfigUtil.GetBoolParameter("UseDefaultBrowser");
            customBrowserRadioButton.Checked  = !ConfigUtil.GetBoolParameter("UseDefaultBrowser");
            customBrowserTextBox.Text         = ConfigUtil.GetStringParameter("CustomBrowserCommand");


            //Tab - Updates
            switch (periodicVersionCheck)
            {
            case 0:
                enableAutomaticUpdateCheckBox.Checked    = false;
                frequencyAutomaticUpdateComboBox.Enabled = false;
                break;

            case 1:
            case 2:
                enableAutomaticUpdateCheckBox.Checked          = true;
                frequencyAutomaticUpdateComboBox.Enabled       = true;
                frequencyAutomaticUpdateComboBox.SelectedIndex = periodicVersionCheck - 1;
                break;
            }

            lastCheckLabel.Text += " " + ConfigUtil.GetDateParameter("LastVersionCheck").ToString(LanguageUtil.GetShortDateTimeFormat());


            //Tab - Dropbox
            dropboxRememberCheckBox.Checked = ConfigUtil.GetBoolParameter("RememberDropboxAccess");
            dropboxDeleteCheckBox.Checked   = ConfigUtil.GetBoolParameter("EnableDropboxDelete");


            //Tab - Integration
            sendToCheckBox.Checked   = previousSendTo;
            openWithCheckBox.Checked = previousOpenWith;
            jumpListCheckBox.Checked = previousJumpListActivated;
        }