Ejemplo n.º 1
0
        private void FEditorSettings_Load(object sender, EventArgs e)
        {
            var directory = new DirectoryInfo(DirectorSettingsManager.LanguagesPath);

            if (directory.Exists)
            {
                var fileNames = Directory.EnumerateFiles(directory.FullName, "*" + DirectorSettingsManager.LanguageFileExtension, SearchOption.TopDirectoryOnly);
                foreach (var fileName in fileNames)
                {
                    // The language name is not important here.
                    var manager = LanguageManager.CreateFromFile(fileName, fileName);
                    _languages.Add((manager.DisplayName, manager.CodeName));
                }
            }

            cboPreviewRenderMode.Items.Clear();
            for (var i = (int)PreviewerRenderMode.Standard; i <= (int)PreviewerRenderMode.EditorLike; ++i)
            {
                var textKey = $"ui.feditorsettings.dropdown.{i}";
                cboPreviewRenderMode.Items.Add(LanguageManager.Current.GetString(textKey));
            }
            if (cboPreviewRenderMode.Items.Count > 0)
            {
                cboPreviewRenderMode.SelectedIndex = 0;
            }

            cboLanguage.Items.Clear();
            cboLanguage.Items.Add(LanguageManager.TryGetString("lang.use_auto.text") ?? "Auto");
            cboLanguage.Items.AddRange(_languages.Select(v => v.DisplayName).Cast <object>().ToArray());

            var s = _editorSettings;

            int langIndex;

            _originalLanguage = s.Language;
            if (s.Language == null)
            {
                langIndex = 0;
            }
            else
            {
                if (LanguageManager.Current != null)
                {
                    langIndex = _languages.FindIndex(v => v.CodeName == LanguageManager.Current.CodeName);
                    if (langIndex < 0)
                    {
                        langIndex = 0;
                    }
                    else
                    {
                        langIndex += 1;
                    }
                }
                else
                {
                    langIndex = 0;
                }
            }
            cboLanguage.SelectedIndex = langIndex;

            radInvertedScrollingOn.Checked  = s.InvertedScrolling;
            radInvertedScrollingOff.Checked = !s.InvertedScrolling;
            chkShowNoteIndicators.Checked   = s.ShowNoteIndicators;
            txtScrollingSpeed.Value         = s.ScrollingSpeed;
            if (cboPreviewRenderMode.Items.Count > 0)
            {
                cboPreviewRenderMode.SelectedIndex = (int)s.PreviewRenderMode;
            }
            txtPreviewSpeed.Text = s.PreviewSpeed.ToString(CultureInfo.InvariantCulture);

            txtExternalPreviewerFile.Text = s.ExternalPreviewerFile;
            txtExternalPreviewerArgs.Text = s.ExternalPreviwerArgs;
        }