public void Setup() { BasilProject.InitializeForTests(); WritingSystem writingSystem = new WritingSystem(_writingSystemId, new Font(FontFamily.GenericSansSerif, 24)); _papaNameWidget = new WeSayTextBox(writingSystem, null); _papaNameWidget.Text = "John"; _ghostFirstNameWidget = new WeSayTextBox(writingSystem, null); _binding = new GhostBinding<Child>(_papa.Children, "First", writingSystem, _ghostFirstNameWidget); _didNotify = false; //Window w = new Window("test"); //VBox box = new VBox(); //w.Add(box); //box.PackStart(_papaNameWidget); //box.PackStart(_ghostFirstNameWidget); //box.ShowAll(); //w.ShowAll(); _papaNameWidget.Show(); // while (Gtk.Application.EventsPending()) // { Gtk.Application.RunIteration(); } //Application.Run(); _papaNameWidget.Focus(); _ghostFirstNameWidget.Focus(); }
public LocalizationData(LocalizationLanguage languageID, string languageName, TextAsset newDataFile) { language = languageID; dataFile = newDataFile; data = new Dictionary <LocalizationKeyword, string>(); writingSystem = WritingSystem.LTR; }
public void Setup() { BasilProject.InitializeForTests(); _FilePath = Path.GetTempFileName(); _lexEntryRepository = new LexEntryRepository(_FilePath); _outputPath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); _writingSystemIds = new List<string>(new string[] {"red", "green", "blue"}); _headwordWritingSystem = new WritingSystem(_writingSystemIds[0], new Font(FontFamily.GenericSansSerif, 10)); _viewTemplate = new ViewTemplate(); _viewTemplate.Add(new Field(LexEntry.WellKnownProperties.Citation, "LexEntry", new string[] {"blue", "red"})); _viewTemplate.Add(new Field(LexEntry.WellKnownProperties.LexicalUnit, "LexEntry", new string[] {"red", "green", "blue"})); _viewTemplate.Add(new Field(LexEntry.WellKnownProperties.BaseForm, "LexEntry", _writingSystemIds)); Field visibleCustom = new Field("VisibleCustom", "LexEntry", _writingSystemIds, Field.MultiplicityType.ZeroOr1, "MultiText"); visibleCustom.Visibility = CommonEnumerations.VisibilitySetting.Visible; visibleCustom.DisplayName = "VisibleCustom"; _viewTemplate.Add(visibleCustom); }
private void LoadFontCombo() { // Display the fonts in sorted order. var fontNames = new List <string>(); fontNames.AddRange(Browser.NamesOfFontsThatBrowserCanRender()); fontNames.Sort(); var defaultFont = WritingSystem.GetDefaultFontName(); foreach (var font in fontNames) { _fontCombo.Items.Add(font); if (font == defaultFont) { _fontCombo.SelectedItem = font; } } // Make the font combobox wide enough to display the longest value. int width = _fontCombo.DropDownWidth; using (Graphics g = _fontCombo.CreateGraphics()) { Font font = _fontCombo.Font; int vertScrollBarWidth = (_fontCombo.Items.Count > _fontCombo.MaxDropDownItems) ? SystemInformation.VerticalScrollBarWidth : 0; width = (from string s in _fontCombo.Items select TextRenderer.MeasureText(g, s, font).Width).Concat(new[] { width }).Max() + vertScrollBarWidth; } _fontCombo.DropDownWidth = width; }
public void CreateWithWritingSystem() { WritingSystem ws = new WritingSystem(); WeSayTextBox textBox = new WeSayTextBox(ws, null); Assert.IsNotNull(textBox); Assert.AreSame(ws, textBox.WritingSystem); }
public void TestEqualsNull() { var system = new WritingSystem { Name = Name }; Assert.IsFalse(system.Equals(null)); }
public void TestClone() { var system = new WritingSystem { Name = Name, Bcp47 = Bcp47, Font = Font }; var clonedSystem = system.Clone(); Assert.AreEqual(system, clonedSystem); }
public void TestToString() { var system = new WritingSystem { Name = Name, Bcp47 = Bcp47 }; var sysString = system.ToString(); Assert.IsTrue(sysString.Contains(Name) && sysString.Contains(Bcp47)); }
public void TestEquals() { var system = new WritingSystem { Name = Name }; Assert.That(system.Equals(new WritingSystem { Name = Name })); }
public void TestNotEquals() { var system = new WritingSystem { Name = Name, Bcp47 = Bcp47 }; Assert.IsFalse(system.Equals(new WritingSystem { Name = Name })); }
void AppendWritingSystem(WritingSystem ws, string label, StringBuilder bldr) { if (string.IsNullOrEmpty(ws?.Iso639Code)) { bldr.AppendLine("No " + label + " defined"); } else { bldr.AppendLine(label + " -> iso: '" + ws.Iso639Code + "', font: " + ws.FontName + (ws.IsRightToLeft ? " RTL" : string.Empty)); } }
public void SerializeOne() { // since Linux may not have Arial, we // need to test against the font mapping Font font = new Font("Arial", 99); WritingSystem ws = new WritingSystem("one", font); string s = NetReflector.Write(ws); string expected = "<WritingSystem><Abbreviation>one</Abbreviation><FontName>" + font.Name + "</FontName><FontSize>" + font.Size + "</FontSize><Id>one</Id><RightToLeft>False</RightToLeft><SortUsing>one</SortUsing>" + "<SpellCheckingId>one</SpellCheckingId></WritingSystem>"; Assert.AreEqual(expected, s); }
public MissingInfoTask(MissingInfoConfiguration config, LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate) : base( config, lexEntryRepository) { if (config.MissingInfoField == null) { throw new ArgumentNullException("MissingInfoField"); } if (viewTemplate == null) { throw new ArgumentNullException("viewTemplate"); } _missingInfoField = viewTemplate[config.MissingInfoField]; _viewTemplate = CreateViewTemplateFromListOfFields(viewTemplate, config.FieldsToShow); MarkReadOnlyFields(config.FieldsToShowReadOnly); //hack until we overhaul how Tasks are setup: _isBaseFormFillingTask = config.FieldsToShow.Contains(LexEntry.WellKnownProperties.BaseForm); if (_isBaseFormFillingTask) { Field flagField = new Field(); flagField.DisplayName = StringCatalog.Get("~This word has no Base Form", "The user will click this to say that this word has no baseform. E.g. Kindess has Kind as a baseform, but Kind has no other word as a baseform."); flagField.DataTypeName = "Flag"; flagField.ClassName = "LexEntry"; flagField.FieldName = "flag_skip_" + config.MissingInfoField; flagField.Enabled = true; _viewTemplate.Add(flagField); } _writingSystem = BasilProject.Project.WritingSystems.UnknownVernacularWritingSystem; // use the master view Template instead of the one for this task. (most likely the one for this // task doesn't have the EntryLexicalForm field specified but the Master (Default) one will Field fieldDefn = WeSayWordsProject.Project.DefaultViewTemplate.GetField( Field.FieldNames.EntryLexicalForm.ToString()); if (fieldDefn != null) { if (fieldDefn.WritingSystemIds.Count > 0) { _writingSystem = BasilProject.Project.WritingSystems[fieldDefn.WritingSystemIds[0]]; } else { throw new ConfigurationException("There are no writing systems enabled for the Field '{0}'", fieldDefn.FieldName); } } }
public void TestClone() { var system = new WritingSystem { Name = Name, Bcp47 = "en", Font = "calibri" }; var project = new Project { Name = Name, VernacularWritingSystem = system }; var domain = new SemanticDomain { Name = Name, Id = "1", Description = "text" }; project.SemanticDomains.Add(domain); var project2 = project.Clone(); Assert.AreEqual(project, project2); }
public void SetUp() { WeSayWordsProject.InitializeForTests(); _tempFolder = new TemporaryFolder(); _filePath = _tempFolder.GetTemporaryFile(); _lexEntryRepository = new LexEntryRepository(_filePath); _writingSystem = new WritingSystem("pretendVernacular", new Font(FontFamily.GenericSansSerif, 24)); CreateTestEntry("apple", "red thing", "An apple a day keeps the doctor away."); CreateTestEntry("banana", "yellow food", "Monkeys like to eat bananas."); CreateTestEntry("car", "small motorized vehicle", "Watch out for cars when you cross the street."); CreateTestEntry("dog", "animal with four legs; man's best friend", "He walked his dog."); string[] analysisWritingSystemIds = new string[] {"analysis"}; string[] vernacularWritingSystemIds = new string[] {_writingSystem.Id}; RtfRenderer.HeadWordWritingSystemId = vernacularWritingSystemIds[0]; _viewTemplate = new ViewTemplate(); _viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(), "LexEntry", vernacularWritingSystemIds)); _viewTemplate.Add(new Field(LexSense.WellKnownProperties.Definition, "LexSense", analysisWritingSystemIds)); _viewTemplate.Add(new Field(Field.FieldNames.ExampleSentence.ToString(), "LexExampleSentence", vernacularWritingSystemIds)); Field exampleTranslationField = new Field( Field.FieldNames.ExampleTranslation.ToString(), "LexExampleSentence", analysisWritingSystemIds); _viewTemplate.Add(exampleTranslationField); _missingTranslationRecordList = _lexEntryRepository.GetEntriesWithMissingFieldSortedByLexicalUnit( exampleTranslationField, _writingSystem); }
public GatherWordListControl(GatherWordListTask task, WritingSystem lexicalUnitWritingSystem) { _task = task; InitializeComponent(); InitializeDisplaySettings(); _vernacularBox.AutoSizeMode = AutoSizeMode.GrowAndShrink; _listViewOfWordsMatchingCurrentItem.Items.Clear(); _vernacularBox.WritingSystemsForThisField = new WritingSystem[] {lexicalUnitWritingSystem}; _vernacularBox.TextChanged += _vernacularBox_TextChanged; _vernacularBox.KeyDown += _boxVernacularWord_KeyDown; _vernacularBox.MinimumSize = _boxForeignWord.Size; _listViewOfWordsMatchingCurrentItem.WritingSystem = _task.WordWritingSystem; // _listViewOfWordsMatchingCurrentItem.ItemHeight = (int)Math.Ceiling(_task.WordWritingSystem.Font.GetHeight()); UpdateStuff(); _movingLabel.Font = _vernacularBox.TextBoxes[0].Font; _movingLabel.Finished += OnAnimator_Finished; }
// private bool _suspendNotificationOfNavigation=false; public GatherWordListTask(IGatherWordListConfig config, LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate) : base(config, lexEntryRepository, viewTemplate) { if (config.WordListFileName == null) { throw new ArgumentNullException("wordListFileName"); } if (config.WordListWritingSystemId == null) { throw new ArgumentNullException("wordListWritingSystemId"); } if (viewTemplate == null) { throw new ArgumentNullException("viewTemplate"); } Field lexicalFormField = viewTemplate.GetField(Field.FieldNames.EntryLexicalForm.ToString()); if (lexicalFormField == null || lexicalFormField.WritingSystemIds.Count < 1) { _lexicalUnitWritingSystem = BasilProject.Project.WritingSystems.UnknownVernacularWritingSystem; } else { string firstWSid = lexicalFormField.WritingSystemIds[0]; WritingSystem firstWS = BasilProject.Project.WritingSystems[firstWSid]; _lexicalUnitWritingSystem = firstWS; } _wordListFileName = config.WordListFileName; _words = null; _writingSystemIdForWordListWords = config.WordListWritingSystemId; }
protected WordGatheringTaskBase(ITaskConfiguration config, LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate) : base( config, lexEntryRepository) { if (viewTemplate == null) { throw new ArgumentNullException("viewTemplate"); } _viewTemplate = viewTemplate; Field lexicalFormField = viewTemplate.GetField(Field.FieldNames.EntryLexicalForm.ToString()); WritingSystemCollection writingSystems = BasilProject.Project.WritingSystems; if (lexicalFormField == null || lexicalFormField.WritingSystemIds.Count < 1) { _lexicalFormWritingSystem = writingSystems.UnknownVernacularWritingSystem; } else { _lexicalFormWritingSystem = writingSystems[lexicalFormField.WritingSystemIds[0]]; } }
public void GetHashCode_DifferentSortUsing_Different() { Font font1 = new Font("Arial", 12); WritingSystem writingSystem1 = new WritingSystem("ws", font1); writingSystem1.SortUsing = "th"; WritingSystem writingSystem2 = new WritingSystem("ws", font1); writingSystem2.SortUsing = "th-TH"; Assert.AreNotEqual(writingSystem1.GetHashCode(), writingSystem2.GetHashCode()); }
public void GetHashCode_DifferentCustomSortRules_Different() { Font font1 = new Font("Arial", 12); WritingSystem writingSystem1 = new WritingSystem("ws", font1); writingSystem1.SortUsing = CustomSortRulesType.CustomSimple.ToString(); writingSystem1.CustomSortRules = "A"; WritingSystem writingSystem2 = new WritingSystem("ws", font1); writingSystem2.SortUsing = CustomSortRulesType.CustomSimple.ToString(); writingSystem2.CustomSortRules = "A a"; Assert.AreNotEqual(writingSystem1.GetHashCode(), writingSystem2.GetHashCode()); }
public void GetHashCode_DifferentId_Different() { Font font1 = new Font("Arial", 12); WritingSystem writingSystem1 = new WritingSystem("ws", font1); WritingSystem writingSystem2 = new WritingSystem("sw", font1); Assert.AreNotEqual(writingSystem1.GetHashCode(), writingSystem2.GetHashCode()); }
public void NoSetupDefaultFont() { WritingSystem ws = new WritingSystem("xx", new Font("Times", 33)); Assert.AreEqual(33, ws.Font.Size); }
public void GetAbbreviation_AbbreviationIsSet_ReturnsAbbreviation() { WritingSystem writingSystem = new WritingSystem(); writingSystem.Abbreviation = "eng"; Assert.AreEqual("eng", writingSystem.Abbreviation); }
private void ParseSemanticDomainFile() { XmlTextReader reader = null; try { reader = new XmlTextReader(_semanticDomainQuestionsFileName); reader.MoveToContent(); if (!reader.IsStartElement("semantic-domain-questions")) { //what are we going to do when the file is bad? Debug.Fail("Bad file format, expected semantic-domain-questions element"); } //string ws = reader.GetAttribute("lang"); got it from the configuration file // should verify that this writing system is in optionslist _semanticDomainWritingSystem = BasilProject.Project.WritingSystems[WritingSystemIdForNamesAndQuestions]; string semanticDomainType = reader.GetAttribute("semantic-domain-type"); // should verify that domain type matches type of optionList in semantic domain field reader.ReadToDescendant("semantic-domain"); while (reader.IsStartElement("semantic-domain")) { string domainKey = reader.GetAttribute("id"); List<string> questions = new List<string>(); XmlReader questionReader = reader.ReadSubtree(); questionReader.MoveToContent(); questionReader.ReadToFollowing("question"); while (questionReader.IsStartElement("question")) { questions.Add(questionReader.ReadElementString("question").Trim()); } _domainKeys.Add(domainKey); if (questions.Count == 0) { questions.Add(string.Empty); } _domainQuestions.Add(domainKey, questions); reader.ReadToFollowing("semantic-domain"); } } catch (XmlException) { // log this; } finally { if (reader != null) { reader.Close(); } } }
private WeSayTextBox AddTextBox(WritingSystem writingSystem, MultiTextBase multiText) { WeSayTextBox box = new WeSayTextBox(writingSystem, Name); box.ReadOnly = (_visibility == CommonEnumerations.VisibilitySetting.ReadOnly); box.Multiline = true; box.WordWrap = true; box.IsSpellCheckingEnabled = _isSpellCheckingEnabled; //box.Enabled = !box.ReadOnly; _textBoxes.Add(box); box.Name = Name.Replace("-mtc", "") + "_" + writingSystem.Id; //for automated tests to find this particular guy box.Text = multiText[writingSystem.Id]; box.TextChanged += OnTextOfSomeBoxChanged; box.KeyDown += OnKeyDownInSomeBox; box.MouseWheel += subControl_MouseWheel; return box; }
public void GetSpellcheckingId_SpellcheckingIdIsSet_ReturnsSpellCheckingId() { WritingSystem writingSystem = new WritingSystem(); writingSystem.SpellCheckingId = "en_US"; Assert.AreEqual("en_US", writingSystem.SpellCheckingId); }
public void CustomSortRules_SortUsingNotCustom_NotSet() { WritingSystem writingSystem = new WritingSystem("one", new Font(FontFamily.GenericSansSerif, 11)); writingSystem.SortUsing = "two"; string rules = "&n < ng <<< Ng <<< NG"; writingSystem.CustomSortRules = rules; Assert.IsNull(writingSystem.CustomSortRules); }
public void CustomSortRules_SortUsingCustomSortRules_Set() { WritingSystem writingSystem = new WritingSystem("one", new Font(FontFamily.GenericSansSerif, 11)); writingSystem.SortUsing = CustomSortRulesType.CustomICU.ToString(); string rules = "&n < ng <<< Ng <<< NG"; writingSystem.CustomSortRules = rules; Assert.AreEqual(rules, writingSystem.CustomSortRules); }
public void SortUsing_null_Id() { WritingSystem writingSystem = new WritingSystem("one", new Font(FontFamily.GenericSansSerif, 11)); writingSystem.SortUsing = null; Assert.AreEqual(writingSystem.Id, writingSystem.SortUsing); }
public void SortUsing_customWithNoRules_sortsLikeInvariant() { WritingSystem writingSystem = new WritingSystem("one", new Font(FontFamily.GenericSansSerif, 11)); writingSystem.SortUsing = CustomSortRulesType.CustomSimple.ToString(); // hard to test because half of the system locales use the invariant table: http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx }
public void Compare_en_sortsLikeEnglish() { WritingSystem writingSystem = new WritingSystem("one", new Font(FontFamily.GenericSansSerif, 11)); writingSystem.SortUsing = "en-US"; //u00c8 is Latin Capital Letter E with Grave //u00ed is Latin small letter i with acute Assert.Greater(writingSystem.Compare("\u00c8dit", "Ed\u00edt"), 0); }
public void GetSpellCheckingId_Uninitialized_ReturnsId() { WritingSystem writingSystem = new WritingSystem(); writingSystem.Id = "en"; Assert.AreEqual("en", writingSystem.SpellCheckingId); }
public void GetHashCode_SameIdDefaultsDifferentFont_Same() { Font font1 = new Font("Arial", 12); WritingSystem writingSystem1 = new WritingSystem("ws", font1); Font font2 = new Font("Arial", 22); WritingSystem writingSystem2 = new WritingSystem("ws", font2); Assert.AreEqual(writingSystem1.GetHashCode(), writingSystem2.GetHashCode()); }
public void GetAbbreviation_Uninitialized_ReturnsId() { WritingSystem writingSystem = new WritingSystem(); writingSystem.Id = "en"; Assert.AreEqual("en", writingSystem.Abbreviation); }
public void GetHashCode_SameIdSortUsingNoCustomRules_Same() { Font font1 = new Font("Arial", 12); WritingSystem writingSystem1 = new WritingSystem("ws", font1); writingSystem1.SortUsing = "th"; Font font2 = new Font("Arial", 22); WritingSystem writingSystem2 = new WritingSystem("ws", font2); writingSystem2.SortUsing = "th"; Assert.AreEqual(writingSystem1.GetHashCode(), writingSystem2.GetHashCode()); }
public void Construct_DefaultFont() { WritingSystem ws = new WritingSystem(); Assert.IsNotNull(ws.Font); }
public void GetHashCode_SameIdSortUsingCustomRules_Same() { Font font1 = new Font("Arial", 12); WritingSystem writingSystem1 = new WritingSystem("ws", font1); writingSystem1.SortUsing = CustomSortRulesType.CustomSimple.ToString(); writingSystem1.CustomSortRules = "A"; Font font2 = new Font("Arial", 22); WritingSystem writingSystem2 = new WritingSystem("ws", font2); writingSystem2.SortUsing = CustomSortRulesType.CustomSimple.ToString(); writingSystem2.CustomSortRules = "A"; Assert.AreEqual(writingSystem1.GetHashCode(), writingSystem2.GetHashCode()); }
public void CustomSortRules_SerializeAndDeserialize() { WritingSystem ws = new WritingSystem("one", new Font("Arial", 99)); ws.SortUsing = CustomSortRulesType.CustomICU.ToString(); string rules = "&n < ng <<< Ng <<< NG"; ws.CustomSortRules = rules; string s = NetReflector.Write(ws); NetReflectorTypeTable t = new NetReflectorTypeTable(); t.Add(typeof (WritingSystem)); NetReflectorReader r = new NetReflectorReader(t); WritingSystem wsRead = (WritingSystem) r.Read(s); Assert.IsNotNull(wsRead); Assert.AreEqual(rules, ws.CustomSortRules); }
public void Setup() { _ws = new WritingSystem("xx", new Font("Arial", (float) 55.9)); // _createNewClickedFired=false; // _valueChangedFired = false; _sourceChoices = new OptionsList(); _choiceKeys = new List<string>(); AddSourceChoice("one", "1", "Notice, this is not the number two."); //nb: key 'two' in there AddSourceChoice("two", "2", "A description of two which includes the word duo."); AddSourceChoice("three", "3", "A description of this which includes the word trio and is not two."); _displayAdaptor = new OptionDisplayAdaptor(_sourceChoices, _ws.Id); _control = new AutoCompleteWithCreationBox<Option, string>( CommonEnumerations.VisibilitySetting.Visible); _control.Name = "autobox"; _control.Box.Items = _sourceChoices.Options; _control.Box.ItemFilterer = _displayAdaptor.GetItemsToOffer; //leave for individual tests _control.CreateNewClicked += new EventHandler<CreateNewArgs>(_control_CreateNewClicked); _control.Box.ItemDisplayStringAdaptor = _displayAdaptor; _control.Box.WritingSystem = _ws; _control.GetKeyValueFromValue = _displayAdaptor.GetOptionFromKey; _control.GetValueFromKeyValue = _displayAdaptor.GetKeyFromOption; _control.ValueChanged += _control_ValueChanged; _dataBeingEditted = new OptionRef(); }