public WritingSystemTreeModel(WritingSystemSetupModel setupModel) { _setupModel = setupModel; _setupModel.ItemAddedOrDeleted += new EventHandler(OnSetupModel_ItemAddedOrDeleted); _setupModel.CurrentItemUpdated += new EventHandler(OnCurrentItemUpdated); Suggestor = new WritingSystemSuggestor(); }
public VoiceIdentifierView(WritingSystemSetupModel model) { _model = model; InitializeComponent(); }
public WritingSystemTreeModel(WritingSystemSetupModel setupModel) { _setupModel = setupModel; _setupModel.ItemAddedOrDeleted += OnSetupModel_ItemAddedOrDeleted; _setupModel.CurrentItemUpdated += OnCurrentItemUpdated; Suggestor = new WritingSystemSuggestor(_setupModel.WritingSystemFactory); }
public CustomIdentifierView(WritingSystemSetupModel model) { _model = model; InitializeComponent(); if (model != null) { model.SelectionChanged += UpdateDisplayFromModel; } UpdateDisplayFromModel(null,null); }
//public const string DefaultName = "~Unlisted Language"; //public const string DefaultCode = "v"; //public const string DefaultAbbreviation = DefaultCode; public UnlistedLanguageView(WritingSystemSetupModel model) { _model = model; InitializeComponent(); if (model != null) { model.SelectionChanged += UpdateDisplayFromModel; } UpdateDisplayFromModel(null, null); //Selected(); }
public ScriptRegionVariantView(WritingSystemSetupModel model) { _model = model; InitializeComponent(); if (model != null) { model.SelectionChanged += UpdateDisplayFromModel; } _scriptCombo.Items.Add(new Iso15924Script("", "")); // add a blank item at the top of the list _scriptCombo.Items.AddRange(StandardTags.ValidIso15924Scripts.ToArray()); _scriptCombo.DisplayMember = "Label"; _regionCombo.Items.Add(new IanaSubtag("region", "", "")); // add a blank item at the top of the list _regionCombo.Items.AddRange(StandardTags.ValidIso3166Regions.ToArray()); _regionCombo.DisplayMember = "Description"; }
public ScriptRegionVariantView(WritingSystemSetupModel model) { _model = model; InitializeComponent(); if (model != null) { model.SelectionChanged += UpdateDisplayFromModel; } _scriptCombo.Items.Add(new ScriptSubtag("blank")); // add a blank item at the top of the list _scriptCombo.Items.AddRange(StandardSubtags.RegisteredScripts.Cast<object>().ToArray()); _scriptCombo.DisplayMember = "Name"; _regionCombo.Items.Add(new RegionSubtag("blank")); // add a blank item at the top of the list _regionCombo.Items.AddRange(StandardSubtags.RegisteredRegions.Cast<object>().ToArray()); _regionCombo.DisplayMember = "Name"; }
public void WritingSystemSetupViewWithComboAttached() { var runner = new CrossThreadTestRunner(); runner.RunInSTA( delegate { using (var folder = new TemporaryFolder("WS-Test")) { var f = new Form(); f.Size = new Size(800, 600); var repository = LdmlInFolderWritingSystemRepository.Initialize(folder.Path); var model = new WritingSystemSetupModel(repository); var v = new WritingSystemSetupView(model); var combo = new WSPickerUsingComboBox(model); f.Controls.Add(combo); f.Controls.Add(v); f.ShowDialog(); } }); }
public void BindToModel(WritingSystemSetupModel model) { if (_model != null) { _model.SelectionChanged -= ModelSelectionChanged; } _model = model; if (_model != null) { _model.SelectionChanged += ModelSelectionChanged; } // UpdateProxyFromModel(); this.Disposed += OnDisposed; AddDetailsControl(new NothingSpecialView(model)); AddDetailsControl(new IpaIdentifierView(model)); AddDetailsControl(new VoiceIdentifierView(model)); AddDetailsControl(new ScriptRegionVariantView(model)); //AddDetailsControl(new CustomIdentifierView(model)); comboBox1.DisplayMember = "ChoiceName"; comboBox1.SelectedIndex = 0; UpdateFromModel(); }
public void SingleWSMode_WSIsSelected() { _model = new WritingSystemSetupModel(new WritingSystemDefinition()); Assert.IsTrue(_model.HasCurrentSelection); }
public WSPickerUsingComboBox(WritingSystemSetupModel model) : this() { BindToModel(model); }
public void SingleWSMode_ChangingCurrentIndex_Throws() { _model = new WritingSystemSetupModel(new WritingSystemDefinition()); Assert.Throws<InvalidOperationException>( () => _model.CurrentIndex = -1 ); }
public void SetAllPossibleAndRemoveOthers_DuplicateIsCreatedFromWsAlreadyInRepoAndWouldBeRenamedToSelf_SetsToRepo() { Assert.That(_writingSystemRepository.Count, Is.EqualTo(0)); var ws = new WritingSystemDefinition("en-x-dupl0"); //reinitialize the model with a prepopulated repo _writingSystemRepository.Set(new WritingSystemDefinition("en")); _writingSystemRepository.Set(ws); _model = new WritingSystemSetupModel(_writingSystemRepository); //Now change the Id so it's a duplicate of another ws already in the repo ws.Variants.Clear(); _model.SetAllPossibleAndRemoveOthers(); Assert.That(_writingSystemRepository.Count, Is.EqualTo(2)); Assert.That(_writingSystemRepository.Contains("en")); Assert.That(_writingSystemRepository.Contains("en-x-dupl0")); }
public void Setup() { ErrorReport.IsOkToInteractWithUser = false; ShowOncePerSessionBasedOnExactMessagePolicy.Reset(); _testFilePath = Path.GetTempFileName(); _writingSystemRepository = new TestLdmlInXmlWritingSystemRepository(); _model = new WritingSystemSetupModel(_writingSystemRepository); }
public void SetAllPossibleAndRemoveOthers_NewDuplicateWs_SetsToRepo() { Assert.That(_writingSystemRepository.Count, Is.EqualTo(0)); //reinitialize the model with a prepopulated repo _writingSystemRepository.Set(new WritingSystemDefinition("en")); _model = new WritingSystemSetupModel(_writingSystemRepository); //add a new writing system definition with identical Id _model.AddPredefinedDefinition(new WritingSystemDefinition("en")); _model.SetAllPossibleAndRemoveOthers(); Assert.That(_writingSystemRepository.Count, Is.EqualTo(2)); Assert.That(_writingSystemRepository.Contains("en")); Assert.That(_writingSystemRepository.Contains("en-x-dupl0")); }
public ProjectSettingsViewModel(Project project) { Project = project; WsModel = new WritingSystemSetupModel(project.WritingSystem) { CurrentDefaultFontName = project.FontFamily, CurrentDefaultFontSize = project.FontSizeInPoints, CurrentRightToLeftScript = project.RightToLeftScript }; RecordingProjectName = project.Name; AudioStockNumber = project.AudioStockNumber; BundlePath = project.OriginalBundlePath; LanguageName = project.LanguageName; IsoCode = project.LanguageIsoCode; PublicationId = project.Id; PublicationName = project.PublicationName; Versification = project.Versification; m_chapterAnnouncementStyle = project.ChapterAnnouncementStyle; SkipChapterAnnouncementForFirstChapter = project.SkipChapterAnnouncementForFirstChapter; SkipChapterAnnouncementForSingleChapterBooks = SkipChapterAnnouncementForFirstChapter || project.SkipChapterAnnouncementForSingleChapterBooks; var block = project.IncludedBooks.SelectMany(book => book.GetScriptBlocks().Where(b => b.ContainsVerseNumber)).FirstOrDefault(); if (block != null) { SampleText = block.GetText(false); } var multiChapterBooks = project.IncludedBooks.Where(book => Versification.GetLastChapter(BCVRef.BookToNumber(book.BookId)) > 1); foreach (var book in multiChapterBooks) { var chapterBlocks = book.GetScriptBlocks().Where(b => b.IsChapterAnnouncement).Take(2).ToList(); if (chapterBlocks.Any()) { m_exampleFirstChapterLabel = chapterBlocks.First().BlockElements.OfType <ScriptText>().First().Content; if (chapterBlocks.Count > 1) { m_exampleChapterLabel = chapterBlocks[1].BlockElements.OfType <ScriptText>().First().Content; m_exampleChapterNumber = chapterBlocks[1].ChapterNumber; m_exampleMultiChapterBookId = book.BookId; var title = book.GetScriptBlocks().FirstOrDefault(b => b.StyleTag == "mt"); if (title != null) { m_exampleMultiChapterBookTitle = title.GetText(false); } } break; } } var singleChapterBook = project.IncludedBooks.FirstOrDefault(book => Versification.GetLastChapter(BCVRef.BookToNumber(book.BookId)) == 1); if (singleChapterBook != null) { var chapterBlock = singleChapterBook.GetScriptBlocks().FirstOrDefault(b => b.IsChapterAnnouncement); if (chapterBlock != null) { m_exampleSingleChapterLabel = chapterBlock.BlockElements.OfType <ScriptText>().First().Content; } m_exampleSingleChapterBookId = singleChapterBook.BookId; var title = singleChapterBook.GetScriptBlocks().FirstOrDefault(b => b.StyleTag == "mt"); if (title != null) { m_exampleSingleChapterBookTitle = title.GetText(false); } } }
public void SingleWSMode_DuplicateCurrent_Throws() { _model = new WritingSystemSetupModel(new WritingSystemDefinition()); Assert.Throws<InvalidOperationException>( () => _model.DuplicateCurrent() ); }
public void SingleWSMode_Save_Throws() { _model = new WritingSystemSetupModel(new WritingSystemDefinition()); Assert.Throws<InvalidOperationException>( () => _model.Save() ); }
public void SingleWSMode_HasOnlyOne() { _model = new WritingSystemSetupModel(new WritingSystemDefinition()); Assert.AreEqual(1, _model.WritingSystemCount); }
public void SingleWSMode_UsingStore_IsFalse() { _model = new WritingSystemSetupModel(new WritingSystemDefinition()); Assert.IsFalse(_model.UsingWritingSystemRepository); }
public void ImportFile_SingleWSMode_Throws() { _model = new WritingSystemSetupModel(new WritingSystemDefinition()); Assert.Throws<InvalidOperationException>( () => _model.ImportFile("foo.xml") ); }
public NothingSpecialView(WritingSystemSetupModel model) { _model = model; InitializeComponent(); }