public WritingSystemTreeModel(WritingSystemSetupModel setupModel) { _setupModel = setupModel; _setupModel.ItemAddedOrDeleted += OnSetupModel_ItemAddedOrDeleted; _setupModel.CurrentItemUpdated += OnCurrentItemUpdated; Suggestor = new WritingSystemSuggestor(_setupModel.WritingSystemFactory); }
public WritingSystemTreeModel(WritingSystemSetupModel setupModel) { _setupModel = setupModel; _setupModel.ItemAddedOrDeleted += OnSetupModel_ItemAddedOrDeleted; _setupModel.CurrentItemUpdated += OnCurrentItemUpdated; Suggestor = new WritingSystemSuggestor(_setupModel.WritingSystemFactory); }
public void OtherKnownWritingSystems_TokPisinAlreadyExists_DoesNotHaveTokPisin() { var suggestor = new WritingSystemSuggestor(new TestWritingSystemFactory()); var existingWritingSystems = new List<WritingSystemDefinition>{new WritingSystemDefinition("tpi")}; Assert.That(suggestor.GetOtherLanguageSuggestions(existingWritingSystems).Any(ws => ws.Label == "Tok Pisin"), Is.False); }
[Test] // ok public void GetSuggestions_HasNormalAndIPA_DoesNotIncludeItemToCreateIPA() { var etr = new WritingSystemDefinition("etr", string.Empty, string.Empty, string.Empty, "edo", false); var etrIpa = new WritingSystemDefinition("etr", string.Empty, string.Empty, "fonipa", "edo", false); var list = new List<WritingSystemDefinition>(new[] { etr, etrIpa }); var suggestor = new WritingSystemSuggestor(new TestWritingSystemFactory()); IEnumerable<IWritingSystemDefinitionSuggestion> suggestions = suggestor.GetSuggestions(etr, list); Assert.That(suggestions.Any(defn => defn is IpaSuggestion), Is.False); }
public void GetSuggestions_MajorWorlLanguage_SuggestsOnlyIfSuppressSuggesstionsForMajorWorldLanguagesIsFalse() { var english = new WritingSystemDefinition("en", string.Empty, string.Empty, string.Empty, "eng", false); var list = new List<WritingSystemDefinition>(new[] { english }); var suggestor = new WritingSystemSuggestor(new TestWritingSystemFactory()); suggestor.SuppressSuggestionsForMajorWorldLanguages = false; var suggestions = suggestor.GetSuggestions(english, list); Assert.That(suggestions.Any(defn => defn is IpaSuggestion), Is.True); suggestor.SuppressSuggestionsForMajorWorldLanguages = true; suggestions = suggestor.GetSuggestions(english, list); Assert.That(suggestions.Any(defn => defn is IpaSuggestion), Is.False); }
public void GetSuggestions_HasNormalLacksIpa_IpaSuggestedWhichCopiesAllRelevantFields() { var etr = new WritingSystemDefinition("etr", string.Empty, "region", "variant", "edo", true) {DefaultFont = new FontDefinition("font"), DefaultFontSize = 33}; var list = new List<WritingSystemDefinition>(new[] {etr }); var suggestor = new WritingSystemSuggestor(new TestWritingSystemFactory()); var suggestions = suggestor.GetSuggestions(etr, list); WritingSystemDefinition ipa = suggestions.First(defn => defn is IpaSuggestion).ShowDialogIfNeededAndGetDefinition(); Assert.That(ipa.Language, Is.EqualTo(new LanguageSubtag("etr", "Edolo"))); Assert.That(ipa.Variants, Is.EqualTo(new VariantSubtag[] {"fonipa"})); Assert.That(ipa.Region, Is.EqualTo((RegionSubtag) "region")); //Assert.AreEqual("arial unicode ms", ipa.DefaultFontName); this depends on what fonts are installed on the test system Assert.That(ipa.DefaultFontSize, Is.EqualTo(33)); Assert.That(ipa.Keyboard.ToLower().Contains("ipa"), Is.True); }
public void OtherKnownWritingSystems_TokPisinDoesNotAlreadyExist_HasTokPisin() { var suggestor = new WritingSystemSuggestor(new TestWritingSystemFactory()); Assert.That(suggestor.GetOtherLanguageSuggestions(Enumerable.Empty<WritingSystemDefinition>()).Any(ws => ws.Label == "Tok Pisin"), Is.True); }
/// <summary> /// Creates the presentation model object based off of a writing system store of some sort. /// </summary> public WritingSystemSetupModel(IWritingSystemRepository writingSystemRepository) { if (writingSystemRepository == null) { throw new ArgumentNullException("writingSystemRepository"); } _writingSystemFactory = writingSystemRepository.WritingSystemFactory; WritingSystemSuggestor = new WritingSystemSuggestor(_writingSystemFactory); _writingSystemRepository = writingSystemRepository; _writingSystemDefinitions = new List<WritingSystemDefinition>(_writingSystemRepository.AllWritingSystems); _deletedWritingSystemDefinitions = new List<WritingSystemDefinition>(); _currentIndex = -1; _usingRepository = true; }
/// <summary> /// Creates the presentation model object based off of a single writing system definition. /// This is the easiest form to use if you only want part of the UI elements or only operate on /// one WritingSystemDefiniion /// </summary> public WritingSystemSetupModel(WritingSystemDefinition ws) { if (ws == null) { throw new ArgumentNullException("ws"); } _writingSystemFactory = new SldrWritingSystemFactory(); WritingSystemSuggestor = new WritingSystemSuggestor(_writingSystemFactory); _currentWritingSystem = ws; _currentIndex = 0; _writingSystemRepository = null; _writingSystemDefinitions = new List<WritingSystemDefinition> {ws}; _deletedWritingSystemDefinitions = null; _usingRepository = false; }