コード例 #1
0
		public WritingSystemTreeModel(WritingSystemSetupModel setupModel)
		{
			_setupModel = setupModel;
			_setupModel.ItemAddedOrDeleted += new EventHandler(OnSetupModel_ItemAddedOrDeleted);
			_setupModel.CurrentItemUpdated += new EventHandler(OnCurrentItemUpdated);
			Suggestor = new WritingSystemSuggestor();
		}
コード例 #2
0
		public VoiceIdentifierView(WritingSystemSetupModel model)
		{
			_model = model;
			InitializeComponent();


		}
コード例 #3
0
		public WritingSystemTreeModel(WritingSystemSetupModel setupModel)
		{
			_setupModel = setupModel;
			_setupModel.ItemAddedOrDeleted += OnSetupModel_ItemAddedOrDeleted;
			_setupModel.CurrentItemUpdated += OnCurrentItemUpdated;
			Suggestor = new WritingSystemSuggestor(_setupModel.WritingSystemFactory);
		}
コード例 #4
0
		public CustomIdentifierView(WritingSystemSetupModel model)
		{
			_model = model;
			InitializeComponent();
			if (model != null)
			{
				model.SelectionChanged += UpdateDisplayFromModel;
			}
			UpdateDisplayFromModel(null,null);
		}
コード例 #5
0
		//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();
		}
コード例 #6
0
		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";
		}
コード例 #7
0
		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";
		}
コード例 #8
0
ファイル: UITests.cs プロジェクト: jwickberg/libpalaso
		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();
					}
				});
		}
コード例 #9
0
		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();
		}
コード例 #10
0
		public void SingleWSMode_WSIsSelected()
		{
			_model = new WritingSystemSetupModel(new WritingSystemDefinition());
			Assert.IsTrue(_model.HasCurrentSelection);
		}
コード例 #11
0
 public WSPickerUsingComboBox(WritingSystemSetupModel model) : this()
 {
     BindToModel(model);
 }
コード例 #12
0
		public void SingleWSMode_ChangingCurrentIndex_Throws()
		{
			_model = new WritingSystemSetupModel(new WritingSystemDefinition());
			Assert.Throws<InvalidOperationException>(
				() => _model.CurrentIndex = -1
			);
		}
コード例 #13
0
		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"));
		}
コード例 #14
0
		public void Setup()
		{
			ErrorReport.IsOkToInteractWithUser = false;
			ShowOncePerSessionBasedOnExactMessagePolicy.Reset();

			_testFilePath = Path.GetTempFileName();
			_writingSystemRepository = new TestLdmlInXmlWritingSystemRepository();
			_model = new WritingSystemSetupModel(_writingSystemRepository);
		}
コード例 #15
0
		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"));
		}
コード例 #16
0
        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);
                }
            }
        }
コード例 #17
0
		public void SingleWSMode_DuplicateCurrent_Throws()
		{
			_model = new WritingSystemSetupModel(new WritingSystemDefinition());
			Assert.Throws<InvalidOperationException>(
				() => _model.DuplicateCurrent()
			);
		}
コード例 #18
0
		public void SingleWSMode_Save_Throws()
		{
			_model = new WritingSystemSetupModel(new WritingSystemDefinition());

			Assert.Throws<InvalidOperationException>(
				() => _model.Save()
			);
		}
コード例 #19
0
		public void SingleWSMode_HasOnlyOne()
		{
			_model = new WritingSystemSetupModel(new WritingSystemDefinition());
			Assert.AreEqual(1, _model.WritingSystemCount);
		}
コード例 #20
0
		public void SingleWSMode_UsingStore_IsFalse()
		{
			_model = new WritingSystemSetupModel(new WritingSystemDefinition());
			Assert.IsFalse(_model.UsingWritingSystemRepository);
		}
コード例 #21
0
		public void ImportFile_SingleWSMode_Throws()
		{
			_model = new WritingSystemSetupModel(new WritingSystemDefinition());
			Assert.Throws<InvalidOperationException>(
				() => _model.ImportFile("foo.xml")
			);
		}
コード例 #22
0
		public NothingSpecialView(WritingSystemSetupModel model)
		{
			_model = model;
			InitializeComponent();
		}
コード例 #23
0
 public VoiceIdentifierView(WritingSystemSetupModel model)
 {
     _model = model;
     InitializeComponent();
 }