public void GetStandardVariants_ListsLanguageSpecificWithVariants() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "fr-x-extra" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); CollectionAssert.Contains(model.GetStandardVariants().Select(v => v.Name), "Early Modern French"); }
public void ValidateIetfCode_ReturnsExpected(string newCode, bool expectedValue) { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "qaa" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); Assert.That(model.ValidateIetfCode(newCode), Is.EqualTo(expectedValue)); }
// [TestCase("x-privateusewaytoolong", false)] // libpalaso fix needs to happen public void ValidateOtherVariantsWorks(string code, bool expectedResult) { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "fr" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); Assert.That(model.ValidateOtherVariants(code), Is.EqualTo(expectedResult)); }
public void EnableScriptCodeDoesNotCrashOnEmptyRegion() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "qaa-x-special" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); Assert.That(model.EnableScriptCode, Is.False); }
private void BindConverterTab(FwWritingSystemSetupModel model) { m_lblEncodingConverter.Text = string.Format(FwCoreDlgs.WritingSystemSetup_EncodingConverterForImporting, model.WritingSystemName); model.ShowModifyEncodingConverters = ShowModifyEncodingConverter; BindEncodingConverterCombo(model); }
public void IsRegionCodeEnabled(string languageCode, bool shouldBeEnabled) { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { languageCode }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); Assert.That(model.EnableRegionCode, Is.EqualTo(shouldBeEnabled)); }
public void ScriptItemChange_UpdatesCode() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "qaa-Qaaa-x-Kalaba-Kala-extra", "fr" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.Script = new AdvancedScriptRegionVariantModel.ScriptListItem(new ScriptSubtag("Mala", "not Kala")); Assert.That(model.Code, Is.EqualTo("qaa-Qaaa-x-Kalaba-Mala-extra")); }
public void GetScriptList_ContainsQaaa() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "qaa" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); var scripts = model.GetScripts(); Assert.IsTrue(scripts.Any(s => s.IsPrivateUse && s.Code == "Qaaa")); }
public void StandardVariantChange_SetToNull_Removes_AndUpdatesCode() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "de-DE-fonipa", "fr" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.StandardVariant = null; Assert.That(model.Code, Is.EqualTo("de-DE")); }
public void GetRegionList_ContainsQM() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "qaa" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); var regions = model.GetRegions(); Assert.IsTrue(regions.Any(r => r.IsPrivateUse && r.Code == "QM")); }
public void SetScriptNameUpdatesModel() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "qaa-Qaaa-x-kal-Kala" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.ScriptName = "Kalabanolized"; Assert.That(model.ScriptCode, Is.EqualTo("Kala")); Assert.That(fwWsModel.CurrentWsSetupModel.CurrentIso15924Script.Name, Is.EqualTo("Kalabanolized")); }
public void OtherVariantChange_UpdatesCode() { // Including fonipa sets the StandardVariant var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "de-DE", "fr" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.OtherVariants = "x-special"; Assert.That(model.Code, Is.EqualTo("de-DE-x-special")); }
public void SetRegionUpdatesCodeAndRegionCode() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "fr-x-special" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.Region = new AdvancedScriptRegionVariantModel.RegionListItem(StandardSubtags.RegisteredRegions.First(s => s.Code == "US")); Assert.That(model.RegionCode, Is.EqualTo("US")); Assert.That(model.Code, Is.EqualTo("fr-US-x-special")); }
public void SetScriptUpdatesCodeAndScriptCode() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "fr" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.Script = new AdvancedScriptRegionVariantModel.ScriptListItem(StandardSubtags.RegisteredScripts.First(s => s.Code == "Arab")); Assert.That(model.ScriptCode, Is.EqualTo("Arab")); Assert.That(model.Code, Is.EqualTo("fr-Arab")); }
public void SetScriptToQaaaFromEmptyWorks() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "qaa" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); var scripts = model.GetScripts(); model.Script = scripts.First(s => s.Code == "Qaaa"); Assert.That(model.ScriptCode, Is.EqualTo("Qaaa")); Assert.That(model.Script.Code, Is.EqualTo("Qaaa")); }
public void SetCustomRegionCodeToRealCodeDoesNotLoseCustomStatus() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "fr-QM-x-CT" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.RegionName = "South Texas"; model.RegionCode = "CM"; Assert.That(model.RegionName, Is.EqualTo("South Texas")); Assert.That(model.Code, Is.EqualTo("fr-QM-x-CM")); }
private void ConfigureAnalysisClick(object sender, System.EventArgs e) { var wsSetupModel = new FwWritingSystemSetupModel(_model.WritingSystemContainer, FwWritingSystemSetupModel.ListType.Analysis, _model.WritingSystemManager); using (var wsDlg = new FwWritingSystemSetupDlg(wsSetupModel, _helpTopicProvider)) { wsDlg.ShowDialog(this); } }
/// <summary/> public FwWritingSystemSetupDlg(FwWritingSystemSetupModel model = null, IHelpTopicProvider helpTopicProvider = null, IApp app = null) : base() { InitializeComponent(); _helpTopicProvider = helpTopicProvider; _app = app; if (model != null) { BindToModel(model); } }
public void CodeSetToFullNonSILCustomFillsInAllData() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "qaa" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.Code = "qaa-Qaax-QX-fonipa-x-kal-Kala-KA-extra1-extra2"; Assert.That(model.ScriptCode, Is.EqualTo("Qaax")); // Not Qaaa so the Kala is just a custom variant Assert.That(model.RegionCode, Is.EqualTo("QX")); // Not QM so KA is just a custom variant Assert.That(model.StandardVariant, Is.EqualTo("fonipa")); Assert.That(model.OtherVariants, Is.EqualTo("x-Kala-KA-extra1-extra2")); }
public void SetRegionCodeDoesNotBlankOutRegion() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "fr-Qaaa-QM-x-Cust-CT" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.RegionName = "CustReg"; model.Region = model.GetRegions().First(r => r.Name == "CustReg"); Assert.That(model.Region.Label, Is.EqualTo("CustReg (CT)")); model.RegionCode = "CM"; Assert.That(model.Region.Label, Is.EqualTo("CustReg (CM)")); }
public void SetScriptToQaaaDoesNotLoseCustomCodeOrName() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "fr-Qaaa-x-Cust" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.ScriptName = "SouthernDrawn"; model.Script = model.GetScripts().First(r => r.Code == "Qaaa"); Assert.That(model.ScriptCode, Is.EqualTo("Cust")); Assert.That(model.ScriptName, Is.EqualTo("SouthernDrawn")); Assert.That(model.Code, Is.EqualTo("fr-Qaaa-x-Cust")); }
public void SetScriptCodeDoesNotBlankOutScript() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "fr-Qaaa-QM-x-Cust-CT" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.ScriptName = "CustScr"; model.Script = model.GetScripts().First(r => r.Name == "CustScr"); Assert.That(model.Script.Label, Is.EqualTo("CustScr (Cust)")); model.ScriptCode = "Crud"; Assert.That(model.Script.Label, Is.EqualTo("CustScr (Crud)")); }
public void SetCustomScriptCodeDoesNotLoseCustomName() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "qaa-Qaaa" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); Assert.That(model.ScriptCode, Is.EqualTo("Qaaa")); model.ScriptName = "SuperScript"; Assert.That(model.ScriptName, Is.EqualTo("SuperScript")); model.ScriptCode = "Cust"; Assert.That(model.ScriptName, Is.EqualTo("SuperScript")); }
public void CodeRemovingPUCodesWorks() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "fr-Qaaa-QM-x-Cust-CT" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.RegionName = "CustomRegion"; Assert.That(model.RegionCode, Is.EqualTo("CT")); Assert.That(model.ScriptCode, Is.EqualTo("Cust")); model.Code = "fr-Qaaa-QM"; Assert.That(model.ScriptCode, Is.EqualTo("Qaaa"), "Private use script code was not removed."); Assert.That(model.RegionCode, Is.EqualTo("QM"), "Private use region code was not removed."); }
public void GetStandardVariants_ListsBasics() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "qaa" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); CollectionAssert.AreEquivalent(new[] { "None", "ALA-LC Romanization, 1997 edition", "International Phonetic Alphabet", "Kirshenbaum Phonetic Alphabet", "North American Phonetic Alphabet", "Simplified form", "Uralic Phonetic Alphabet", "X-SAMPA transcription" }, model.GetStandardVariants().Select(v => v.Name)); }
private void BindHeader(FwWritingSystemSetupModel model) { _languageNameTextbox.TextChanged -= LanguageNameTextboxOnTextChanged; _toolTip.SetToolTip(_shareWithSldrCheckbox, FwCoreDlgs.WritingSystemSetup_SharingDataWithSldr); _shareWithSldrCheckbox.CheckedChanged -= ShareWithSldrCheckboxCheckChanged; _ethnologueLink.Text = model.EthnologueLabel; _languageCode.Text = model.LanguageCode; _languageNameTextbox.Text = model.LanguageName; _shareWithSldrCheckbox.Visible = model.ShowSharingWithSldr; _shareWithSldrCheckbox.Checked = model.IsSharingWithSldr; model.ShowChangeLanguage = ShowChangeLanguage; _shareWithSldrCheckbox.CheckedChanged += ShareWithSldrCheckboxCheckChanged; _languageNameTextbox.TextChanged += LanguageNameTextboxOnTextChanged; }
public void CodeSetToFullSILCustomFillsInAllData() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "qaa" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.Code = "qaa-Qaaa-QM-fonipa-x-kal-Kala-KA-extra1-extra2"; Assert.That(model.Script.Code, Is.EqualTo("Kala")); Assert.That(model.Script.IsPrivateUse, Is.True); Assert.That(model.ScriptCode, Is.EqualTo("Kala")); Assert.That(model.Region.Code, Is.EqualTo("KA")); Assert.That(model.Region.IsPrivateUse, Is.True); Assert.That(model.RegionCode, Is.EqualTo("KA")); Assert.That(model.StandardVariant, Is.EqualTo("fonipa")); Assert.That(model.OtherVariants, Is.EqualTo("x-extra1-extra2")); }
public void SetCodeToLangOnlyReturnsEmptyScriptRegionVariant() { var fwWsModel = new FwWritingSystemSetupModel(new TestWSContainer(new[] { "qaa-Qaaa-QM-fonipa-x-Scrp-ST-extra" }, new[] { "en" }), FwWritingSystemSetupModel.ListType.Vernacular); var model = new AdvancedScriptRegionVariantModel(fwWsModel); model.Code = "qaa"; Assert.That(model.ScriptCode, Is.Null); Assert.That(model.ScriptName, Is.Null); Assert.That(model.Script.Code, Is.Null); Assert.That(model.RegionCode, Is.Null); Assert.That(model.RegionName, Is.Null); Assert.That(model.Region.Code, Is.Null); Assert.That(model.StandardVariant, Is.Null); Assert.That(model.OtherVariants, Is.Empty); }
private void BindGeneralTab(FwWritingSystemSetupModel model) { if (Keyboard.Controller != null && model.Cache != null) { IKeyboardDefinition userInterfaceKeyboard; if (Keyboard.Controller.TryGetKeyboard(model.Cache.DefaultUserWs, out userInterfaceKeyboard)) { userInterfaceKeyboard.Activate(); } } m_FullCode.Text = model.CurrentWsSetupModel.CurrentLanguageTag; _spellingCombo.SelectedIndexChanged -= SpellingDictionaryChanged; _spellingCombo.Items.Clear(); // ReSharper disable once CoVariantArrayConversion -- No writes occur in AddRange _spellingCombo.Items.AddRange(model.GetSpellingDictionaryComboBoxItems()); _spellingCombo.SelectedItem = model.SpellingDictionary; _spellingCombo.SelectedIndexChanged += SpellingDictionaryChanged; _rightToLeftCheckbox.CheckedChanged -= RightToLeftCheckChanged; _rightToLeftCheckbox.Checked = model.CurrentWsSetupModel.CurrentRightToLeftScript; _rightToLeftCheckbox.CheckedChanged += RightToLeftCheckChanged; if (model.ShowAdvancedScriptRegionVariantView) { _generalTab.Controls.Remove(_identifiersControl); _generalTab.Controls.Add(_advancedIdentifiersControl); _identifiersControl.Visible = false; _advancedIdentifiersControl.Visible = true; _advancedIdentifiersControl.Enabled = true; _advancedIdentifiersControl.BindToModel(new AdvancedScriptRegionVariantModel(model)); _advancedIdentifiersControl.Selected(); } else { _generalTab.Controls.Remove(_advancedIdentifiersControl); _generalTab.Controls.Add(_identifiersControl); _identifiersControl.Visible = true; _advancedIdentifiersControl.Visible = false; _identifiersControl.UnwireBeforeClosing(); _identifiersControl.BindToModel(model.CurrentWsSetupModel); _identifiersControl.Selected(); } _enableAdvanced.CheckedChanged -= EnableAdvancedOnCheckedChanged; _enableAdvanced.Visible = model.ShowAdvancedScriptRegionVariantCheckBox; _enableAdvanced.Checked = model.ShowAdvancedScriptRegionVariantView; _enableAdvanced.CheckedChanged += EnableAdvancedOnCheckedChanged; }
/// <summary/> public static bool ShowNewDialog(IWin32Window parentForm, LcmCache cache, IHelpTopicProvider helpProvider, IApp app, FwWritingSystemSetupModel.ListType type, out IEnumerable <CoreWritingSystemDefinition> newWritingSystems) { newWritingSystems = new List <CoreWritingSystemDefinition>(); var model = new FwWritingSystemSetupModel(cache.ServiceLocator.WritingSystems, type, cache.ServiceLocator.WritingSystemManager, cache); var oldWsSet = new HashSet <WSListItemModel>(model.WorkingList); using (var dlg = new FwWritingSystemSetupDlg(model, helpProvider, app)) { dlg.ShowDialog(parentForm); if (dlg.DialogResult == DialogResult.OK) { newWritingSystems = model.WorkingList.Where(item => !oldWsSet.Contains(item)).Select(item => item.WorkingWs); return(true); } } return(false); }