private void _scriptsAndVariants_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { // This is a Script link, so for now we'll limit the dialog to only the ScriptRegionVariant combo option. var wsSetupModel = new WritingSystemSetupModel(new WritingSystemDefinition(_model.SelectedLanguage.LanguageTag), WritingSystemSetupModel.SelectionsForSpecialCombo.ScriptRegionVariant, false); wsSetupModel.IdentifierScriptRegionVariantSelected(); using (var dlg = new ScriptsAndVariantsDialog()) { dlg.BindToModel(wsSetupModel); if (dlg.ShowDialog() != DialogResult.OK) { return; } // Allow the user to think of the the Script and Variant's Abbreviation as the primary language tag // for unlisted languages. Otherwise, why show it or allow it to be edited? var tag = wsSetupModel.CurrentDefinition.LanguageTag; var abbr = wsSetupModel.CurrentDefinition.Abbreviation; if (tag.Length >= 3 && LanguageSubtag.IsUnlistedCode(tag.Substring(0, 3)) && abbr.Length == 3 && LanguageSubtag.IsUnlistedCode(abbr) && abbr != tag.Substring(0, 3)) { tag = abbr + tag.Substring(3); } _model.SelectedLanguage.LanguageTag = tag; UpdateReadiness(); } }
private void SetScriptsAndVariantsLabel() { _scriptsAndVariantsLink.Enabled = _model.HaveSufficientInformation; if (!_model.HaveSufficientInformation) { _scriptsAndVariantsLabel.Text = ""; _scriptsAndVariantsLabel.Visible = false; } else { // Usually it's not interesting to see this unless some script, region, or variant data is present. // But when the user has entered a custom unknown language code, this is the only way to confirm it. if (_model.LanguageTagContainsScriptRegionVariantInfo || LanguageSubtag.IsUnlistedCode(_model.SelectedLanguage.LanguageTag)) { _scriptsAndVariantsLabel.Text = "(" + _model.LanguageTag + ")"; _scriptsAndVariantsLabel.Visible = true; } else { _scriptsAndVariantsLabel.Text = ""; _scriptsAndVariantsLabel.Visible = false; } } }