diff --git a/Src/xWorks/ConfiguredLcmGenerator.cs b/Src/xWorks/ConfiguredLcmGenerator.cs index d302e9c60f..f668efebbd 100644 --- a/Src/xWorks/ConfiguredLcmGenerator.cs +++ b/Src/xWorks/ConfiguredLcmGenerator.cs @@ -2476,12 +2476,28 @@ private static string GetSenseNumber(string numberingStyle, ILexSense sense, break; default: // handles %d and %O. We no longer support "%z" (1 b iii) because users can hand-configure its equivalent nextNumber = senseCount.ToString(); - // Use the digits from the CustomHomographNumbers if they are defined - if (info.HomographConfig.CustomHomographNumbers.Count == 10) + // For the sense numbers, use the numbering system associated with the sense number writing system, if there is one. + var senseNumberWs = info.HomographConfig.WritingSystem; + if (senseNumberWs != null) { - for (var digit = 0; digit < 10; ++digit) + CoreWritingSystemDefinition writingSystem = null; + try { - nextNumber = nextNumber.Replace(digit.ToString(), info.HomographConfig.CustomHomographNumbers[digit]); + writingSystem = sense?.Cache.ServiceLocator.WritingSystemManager.Get(senseNumberWs); + } + catch (KeyNotFoundException) + { + //Don't replace sense number digits. + break; + } + var unicodeCharacters = HeadWordNumbersHelper.GetUnicodeCharacters(writingSystem?.NumberingSystem?.Digits); + if (unicodeCharacters != null) + { + for (var digit = 0; digit < 10; ++digit) + { + nextNumber = nextNumber.Replace(digit.ToString(), + unicodeCharacters[digit]); + } } } break; diff --git a/Src/xWorks/DictionaryConfigurationModel.cs b/Src/xWorks/DictionaryConfigurationModel.cs index 9e7a06da32..4155c604d2 100644 --- a/Src/xWorks/DictionaryConfigurationModel.cs +++ b/Src/xWorks/DictionaryConfigurationModel.cs @@ -201,7 +201,6 @@ public void Load(LcmCache cache) else { HomographConfiguration.HomographWritingSystem = string.Empty; - HomographConfiguration.CustomHomographNumbers = string.Empty; } } @@ -370,7 +369,6 @@ public DictionaryHomographConfiguration(DictionaryHomographConfiguration other) ShowSenseNumberReversal = other.ShowSenseNumberReversal; HomographNumberBefore = other.HomographNumberBefore; HomographWritingSystem = other.HomographWritingSystem; - CustomHomographNumberList = other.CustomHomographNumberList != null ? new List(other.CustomHomographNumberList) : null; } public DictionaryHomographConfiguration(HomographConfiguration config) @@ -382,7 +380,6 @@ public DictionaryHomographConfiguration(HomographConfiguration config) ShowHwNumInCrossRef = config.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef); ShowHwNumInReversalCrossRef = config.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef); HomographWritingSystem = config.WritingSystem; - CustomHomographNumberList = config.CustomHomographNumbers; } /// @@ -397,12 +394,8 @@ public void ExportToHomographConfiguration(HomographConfiguration config) config.SetShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef, ShowHwNumInCrossRef); config.SetShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef, ShowHwNumInReversalCrossRef); config.WritingSystem = HomographWritingSystem; - config.CustomHomographNumbers = CustomHomographNumberList; } - [XmlIgnore] - public List CustomHomographNumberList { get; internal set; } - [XmlAttribute("showHwNumInReversalCrossRef")] public bool ShowHwNumInReversalCrossRef { get; set; } @@ -421,19 +414,6 @@ public void ExportToHomographConfiguration(HomographConfiguration config) [XmlAttribute("homographNumberBefore")] public bool HomographNumberBefore { get; set; } - [XmlAttribute("customHomographNumbers")] - public string CustomHomographNumbers - { - get - { - return CustomHomographNumberList == null ? string.Empty : WebUtility.HtmlEncode(string.Join(",", CustomHomographNumberList)); - } - set - { - CustomHomographNumberList = new List(WebUtility.HtmlDecode(value).Split(new []{','}, StringSplitOptions.RemoveEmptyEntries)); - } - } - [XmlAttribute("homographWritingSystem")] public string HomographWritingSystem { get; set; } } diff --git a/Src/xWorks/DictionaryDetailsController.cs b/Src/xWorks/DictionaryDetailsController.cs index 151e812761..05bf2ba91b 100644 --- a/Src/xWorks/DictionaryDetailsController.cs +++ b/Src/xWorks/DictionaryDetailsController.cs @@ -873,7 +873,6 @@ private void HandleHeadwordNumbersButton() // ReSharper disable once AccessToDisposedClosure - can only be used before the dialog is disposed dlg.RunStylesDialog += (sender, e) => HandleStylesBtn((ComboBox) sender, ((ComboBox)sender).Text); dlg.SetupDialog(m_propertyTable.GetValue("HelpTopicProvider")); - dlg.SetStyleSheet = FontHeightAdjuster.StyleSheetFromPropertyTable(m_propertyTable); //dlg.StartPosition = FormStartPosition.CenterScreen; if (dlg.ShowDialog(View.TopLevelControl) != DialogResult.OK) return; diff --git a/Src/xWorks/HeadWordNumbersController.cs b/Src/xWorks/HeadWordNumbersController.cs index e71f236264..5f074ffe1f 100644 --- a/Src/xWorks/HeadWordNumbersController.cs +++ b/Src/xWorks/HeadWordNumbersController.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 SIL International +// Copyright (c) 2017 SIL International // This software is licensed under the LGPL, version 2.1 or later // (http://www.gnu.org/licenses/lgpl-2.1.html) @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using SIL.LCModel; +using SIL.LCModel.Core.WritingSystems; using SIL.LCModel.DomainImpl; namespace SIL.FieldWorks.XWorks @@ -33,9 +34,7 @@ public HeadwordNumbersController(IHeadwordNumbersView view, DictionaryConfigurat model.IsReversal ? xWorksStrings.ReversalIndex : xWorksStrings.Dictionary, Environment.NewLine, model.Label); - _view.SetWsFactoryForCustomDigits(cache.WritingSystemFactory); _view.AvailableWritingSystems = cache.LangProject.CurrentAnalysisWritingSystems.Union(cache.LangProject.CurrentVernacularWritingSystems); - _view.CustomDigits = _homographConfig.CustomHomographNumberList; if (_cache.LangProject.AllWritingSystems.Any(ws => ws.Id == _homographConfig.HomographWritingSystem)) { _view.HomographWritingSystem = string.IsNullOrEmpty(_homographConfig.HomographWritingSystem) @@ -46,19 +45,29 @@ public HeadwordNumbersController(IHeadwordNumbersView view, DictionaryConfigurat { _view.HomographWritingSystem = _cache.LangProject.AllWritingSystems.First().DisplayLabel; } + // If possible, get digits from the writing system's numbering system, + // otherwise use an empty list (which will be treated as default digits in the view). + IEnumerable wsCustomDigits = new List(); + CoreWritingSystemDefinition writingSystem = null; + try + { + writingSystem = cache.ServiceLocator.WritingSystemManager?.Get(_homographConfig.HomographWritingSystem); + } + catch(KeyNotFoundException) + { + // Do nothing; writingSystem is already null. + } + var unicodeCharacters = HeadWordNumbersHelper.GetUnicodeCharacters(writingSystem?.NumberingSystem?.Digits); + if (unicodeCharacters != null) + { + wsCustomDigits = unicodeCharacters; + } + _view.CustomDigits = wsCustomDigits; _view.HomographBefore = _homographConfig.HomographNumberBefore; _view.ShowHomograph = _homographConfig.ShowHwNumber; _view.ShowHomographOnCrossRef = _model.IsReversal ? _homographConfig.ShowHwNumInReversalCrossRef : _homographConfig.ShowHwNumInCrossRef; _view.ShowSenseNumber = _model.IsReversal ? _homographConfig.ShowSenseNumberReversal : _homographConfig.ShowSenseNumber; - _view.OkButtonEnabled = _homographConfig.CustomHomographNumberList == null - || !_homographConfig.CustomHomographNumberList.Any() || _homographConfig.CustomHomographNumberList.Count == 10; - _view.CustomDigitsChanged += OnViewCustomDigitsChanged; - } - - private void OnViewCustomDigitsChanged(object sender, EventArgs eventArgs) - { - _view.OkButtonEnabled = !_view.CustomDigits.Any() - || _view.CustomDigits.Count(digit => !string.IsNullOrWhiteSpace(digit)) == 10; + _view.OkButtonEnabled = true; } /// @@ -93,7 +102,6 @@ public void Save() } _homographConfig.HomographWritingSystem = string.IsNullOrEmpty(_view.HomographWritingSystem) ? null : _cache.LangProject.AllWritingSystems.First(ws => ws.DisplayLabel == _view.HomographWritingSystem).Id; - _homographConfig.CustomHomographNumberList = _view.CustomDigits == null ? new List() : new List(_view.CustomDigits); _model.HomographConfiguration = _homographConfig; _homographConfig.ExportToHomographConfiguration(_cache.ServiceLocator.GetInstance()); } diff --git a/Src/xWorks/HeadWordNumbersDlg.cs b/Src/xWorks/HeadWordNumbersDlg.cs index dd7867ff0a..78b5b6376d 100644 --- a/Src/xWorks/HeadWordNumbersDlg.cs +++ b/Src/xWorks/HeadWordNumbersDlg.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 SIL International +// Copyright (c) 2017 SIL International // This software is licensed under the LGPL, version 2.1 or later // (http://www.gnu.org/licenses/lgpl-2.1.html) @@ -24,7 +24,7 @@ namespace SIL.FieldWorks.XWorks /// public partial class HeadwordNumbersDlg : Form, IHeadwordNumbersView { - private FwTextBox[] _digitBoxes; + private Label[] _digitBoxes; public HeadwordNumbersDlg() { @@ -42,7 +42,6 @@ public HeadwordNumbersDlg() m_digitZero, m_digitOne, m_digitTwo, m_digitThree, m_digitFour, m_digitFive, m_digitSix, m_digitSeven, m_digitEight, m_digitNine }; - Shown += (sender, args) => { UpdateWritingSystemCodeInDigits(); }; } /// @@ -197,22 +196,6 @@ public string HomographWritingSystem } } - /// - /// Set the writing system code in each digit textbox - /// - private void UpdateWritingSystemCodeInDigits() - { - var wsHandle = ((CoreWritingSystemDefinition)m_writingSystemCombo.SelectedItem).Handle; - foreach (var digit in _digitBoxes) - { - digit.WritingSystemCode = wsHandle; - digit.SelectAll(); - digit.ApplyWS(wsHandle); - digit.ApplyStyle("UiElement"); - digit.RemoveSelection(); - } - } - public IEnumerable AvailableWritingSystems { set @@ -234,54 +217,32 @@ public IEnumerable CustomDigits for (var i = 0; i < 10; ++i) { _digitBoxes[i].Text = digitsArray[i]; + _digitBoxes[i].Visible = true; + // Set UseCompatibleTextRendering to false. This causes WindowsForms to use TextRenderer, which provides better fallback font performance. + _digitBoxes[i].UseCompatibleTextRendering = false; } } get { return _digitBoxes.Select(db => db.Text).Where(text => !string.IsNullOrEmpty(text)); } } - public event EventHandler CustomDigitsChanged - { - add - { - foreach (var textBox in _digitBoxes) - { - textBox.TextChanged += value; - } - } - remove - { - foreach (var textBox in _digitBoxes) - { - textBox.TextChanged -= value; - } - } - } - public bool OkButtonEnabled { get { return m_btnOk.Enabled; } set { m_btnOk.Enabled = value; } } - public LcmStyleSheet SetStyleSheet + private void m_writingSystemCombo_SelectedIndexChanged(object sender, EventArgs e) { - set + // Populate digits from ws. + var selectedWs = m_writingSystemCombo.SelectedItem as CoreWritingSystemDefinition; + if (selectedWs?.NumberingSystem != null) { - for (var i = 0; i < 10; ++i) + var digits = selectedWs.NumberingSystem.Digits; + if (!string.IsNullOrEmpty(digits)) { - _digitBoxes[i].StyleSheet = value; + // Populate the custom digits from writing system, if all digits are specified. + var unicodeCharacters = HeadWordNumbersHelper.GetUnicodeCharacters(digits); + if (unicodeCharacters != null) + CustomDigits = unicodeCharacters; } } } - - public void SetWsFactoryForCustomDigits(ILgWritingSystemFactory factory) - { - for (var i = 0; i < 10; ++i) - { - _digitBoxes[i].WritingSystemFactory = factory; - } - } - - private void m_writingSystemCombo_SelectedIndexChanged(object sender, EventArgs e) - { - UpdateWritingSystemCodeInDigits(); - } } } diff --git a/Src/xWorks/HeadWordNumbersDlg.designer.cs b/Src/xWorks/HeadWordNumbersDlg.designer.cs index e4a4f037e0..01cba0d214 100644 --- a/Src/xWorks/HeadWordNumbersDlg.designer.cs +++ b/Src/xWorks/HeadWordNumbersDlg.designer.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2017 SIL International +// Copyright (c) 2017 SIL International // This software is licensed under the LGPL, version 2.1 or later // (http://www.gnu.org/licenses/lgpl-2.1.html) @@ -52,16 +52,16 @@ private void InitializeComponent() this.buttonLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); this.customNumbersPanel = new System.Windows.Forms.Panel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.m_digitNine = new SIL.FieldWorks.Common.Widgets.FwTextBox(); - this.m_digitEight = new SIL.FieldWorks.Common.Widgets.FwTextBox(); - this.m_digitSeven = new SIL.FieldWorks.Common.Widgets.FwTextBox(); - this.m_digitSix = new SIL.FieldWorks.Common.Widgets.FwTextBox(); - this.m_digitFive = new SIL.FieldWorks.Common.Widgets.FwTextBox(); - this.m_digitFour = new SIL.FieldWorks.Common.Widgets.FwTextBox(); - this.m_digitThree = new SIL.FieldWorks.Common.Widgets.FwTextBox(); - this.m_digitTwo = new SIL.FieldWorks.Common.Widgets.FwTextBox(); - this.m_digitOne = new SIL.FieldWorks.Common.Widgets.FwTextBox(); - this.m_digitZero = new SIL.FieldWorks.Common.Widgets.FwTextBox(); + this.m_digitNine = new System.Windows.Forms.Label(); + this.m_digitEight = new System.Windows.Forms.Label(); + this.m_digitSeven = new System.Windows.Forms.Label(); + this.m_digitSix = new System.Windows.Forms.Label(); + this.m_digitFive = new System.Windows.Forms.Label(); + this.m_digitFour = new System.Windows.Forms.Label(); + this.m_digitThree = new System.Windows.Forms.Label(); + this.m_digitTwo = new System.Windows.Forms.Label(); + this.m_digitOne = new System.Windows.Forms.Label(); + this.m_digitZero = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); @@ -90,16 +90,6 @@ private void InitializeComponent() this.buttonLayoutPanel.SuspendLayout(); this.customNumbersPanel.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitNine)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitEight)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitSeven)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitSix)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitFive)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitFour)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitThree)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitTwo)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitOne)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitZero)).BeginInit(); this.homographStylePanel.SuspendLayout(); this.senseNumberStylePanel.SuspendLayout(); this.SuspendLayout(); @@ -263,123 +253,54 @@ private void InitializeComponent() // // m_digitNine // - this.m_digitNine.AcceptsReturn = false; - this.m_digitNine.AdjustStringHeight = true; resources.ApplyResources(this.m_digitNine, "m_digitNine"); - this.m_digitNine.BackColor = System.Drawing.SystemColors.Window; - this.m_digitNine.controlID = null; - this.m_digitNine.HasBorder = true; + this.m_digitNine.BackColor = System.Drawing.SystemColors.Control; this.m_digitNine.Name = "m_digitNine"; - this.m_digitNine.SuppressEnter = false; - this.m_digitNine.WordWrap = false; // // m_digitEight // - this.m_digitEight.AcceptsReturn = false; - this.m_digitEight.AdjustStringHeight = true; resources.ApplyResources(this.m_digitEight, "m_digitEight"); - this.m_digitEight.BackColor = System.Drawing.SystemColors.Window; - this.m_digitEight.controlID = null; - this.m_digitEight.HasBorder = true; this.m_digitEight.Name = "m_digitEight"; - this.m_digitEight.SuppressEnter = false; - this.m_digitEight.WordWrap = false; // // m_digitSeven // - this.m_digitSeven.AcceptsReturn = false; - this.m_digitSeven.AdjustStringHeight = true; resources.ApplyResources(this.m_digitSeven, "m_digitSeven"); - this.m_digitSeven.BackColor = System.Drawing.SystemColors.Window; - this.m_digitSeven.controlID = null; - this.m_digitSeven.HasBorder = true; this.m_digitSeven.Name = "m_digitSeven"; - this.m_digitSeven.SuppressEnter = false; - this.m_digitSeven.WordWrap = false; // // m_digitSix // - this.m_digitSix.AcceptsReturn = false; - this.m_digitSix.AdjustStringHeight = true; resources.ApplyResources(this.m_digitSix, "m_digitSix"); - this.m_digitSix.BackColor = System.Drawing.SystemColors.Window; - this.m_digitSix.controlID = null; - this.m_digitSix.HasBorder = true; this.m_digitSix.Name = "m_digitSix"; - this.m_digitSix.SuppressEnter = false; - this.m_digitSix.WordWrap = false; // // m_digitFive // - this.m_digitFive.AcceptsReturn = false; - this.m_digitFive.AdjustStringHeight = true; resources.ApplyResources(this.m_digitFive, "m_digitFive"); - this.m_digitFive.BackColor = System.Drawing.SystemColors.Window; - this.m_digitFive.controlID = null; - this.m_digitFive.HasBorder = true; this.m_digitFive.Name = "m_digitFive"; - this.m_digitFive.SuppressEnter = false; - this.m_digitFive.WordWrap = false; // // m_digitFour // - this.m_digitFour.AcceptsReturn = false; - this.m_digitFour.AdjustStringHeight = true; resources.ApplyResources(this.m_digitFour, "m_digitFour"); - this.m_digitFour.BackColor = System.Drawing.SystemColors.Window; - this.m_digitFour.controlID = null; - this.m_digitFour.HasBorder = true; this.m_digitFour.Name = "m_digitFour"; - this.m_digitFour.SuppressEnter = false; - this.m_digitFour.WordWrap = false; // // m_digitThree // - this.m_digitThree.AcceptsReturn = false; - this.m_digitThree.AdjustStringHeight = true; resources.ApplyResources(this.m_digitThree, "m_digitThree"); - this.m_digitThree.BackColor = System.Drawing.SystemColors.Window; - this.m_digitThree.controlID = null; - this.m_digitThree.HasBorder = true; this.m_digitThree.Name = "m_digitThree"; - this.m_digitThree.SuppressEnter = false; - this.m_digitThree.WordWrap = false; // // m_digitTwo // - this.m_digitTwo.AcceptsReturn = false; - this.m_digitTwo.AdjustStringHeight = true; resources.ApplyResources(this.m_digitTwo, "m_digitTwo"); - this.m_digitTwo.BackColor = System.Drawing.SystemColors.Window; - this.m_digitTwo.controlID = null; - this.m_digitTwo.HasBorder = true; this.m_digitTwo.Name = "m_digitTwo"; - this.m_digitTwo.SuppressEnter = false; - this.m_digitTwo.WordWrap = false; // // m_digitOne // - this.m_digitOne.AcceptsReturn = false; - this.m_digitOne.AdjustStringHeight = true; resources.ApplyResources(this.m_digitOne, "m_digitOne"); - this.m_digitOne.BackColor = System.Drawing.SystemColors.Window; - this.m_digitOne.controlID = null; - this.m_digitOne.HasBorder = true; this.m_digitOne.Name = "m_digitOne"; - this.m_digitOne.SuppressEnter = false; - this.m_digitOne.WordWrap = false; // // m_digitZero // - this.m_digitZero.AcceptsReturn = false; - this.m_digitZero.AdjustStringHeight = true; resources.ApplyResources(this.m_digitZero, "m_digitZero"); - this.m_digitZero.BackColor = System.Drawing.SystemColors.Window; - this.m_digitZero.controlID = null; - this.m_digitZero.HasBorder = true; this.m_digitZero.Name = "m_digitZero"; - this.m_digitZero.SuppressEnter = false; - this.m_digitZero.WordWrap = false; // // label11 // @@ -533,16 +454,6 @@ private void InitializeComponent() this.customNumbersPanel.PerformLayout(); this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitNine)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitEight)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitSeven)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitSix)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitFive)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitFour)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitThree)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitTwo)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitOne)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.m_digitZero)).EndInit(); this.homographStylePanel.ResumeLayout(false); this.homographStylePanel.PerformLayout(); this.senseNumberStylePanel.ResumeLayout(false); @@ -593,15 +504,15 @@ private void InitializeComponent() private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; - private Common.Widgets.FwTextBox m_digitNine; - private Common.Widgets.FwTextBox m_digitEight; - private Common.Widgets.FwTextBox m_digitSeven; - private Common.Widgets.FwTextBox m_digitSix; - private Common.Widgets.FwTextBox m_digitFive; - private Common.Widgets.FwTextBox m_digitFour; - private Common.Widgets.FwTextBox m_digitThree; - private Common.Widgets.FwTextBox m_digitTwo; - private Common.Widgets.FwTextBox m_digitOne; - private Common.Widgets.FwTextBox m_digitZero; + private System.Windows.Forms.Label m_digitNine; + private System.Windows.Forms.Label m_digitEight; + private System.Windows.Forms.Label m_digitSeven; + private System.Windows.Forms.Label m_digitSix; + private System.Windows.Forms.Label m_digitFive; + private System.Windows.Forms.Label m_digitFour; + private System.Windows.Forms.Label m_digitThree; + private System.Windows.Forms.Label m_digitTwo; + private System.Windows.Forms.Label m_digitOne; + private System.Windows.Forms.Label m_digitZero; } } diff --git a/Src/xWorks/HeadWordNumbersDlg.resx b/Src/xWorks/HeadWordNumbersDlg.resx index 69990a15ca..cd6c3818e9 100644 --- a/Src/xWorks/HeadWordNumbersDlg.resx +++ b/Src/xWorks/HeadWordNumbersDlg.resx @@ -123,10 +123,14 @@ - 15, 161 + 20, 198 + + + + 4, 0, 4, 0 - 287, 13 + 356, 16 5 @@ -150,10 +154,13 @@ True - 6, 21 + 8, 26 + + + 4, 4, 4, 4 - 121, 17 + 152, 20 4 @@ -176,15 +183,17 @@ True - NoControl - 26, 40 + 35, 49 + + + 4, 4, 4, 4 - 96, 17 + 119, 20 5 @@ -205,10 +214,13 @@ 1 - 120, 3 + 160, 4 + + + 4, 4, 4, 4 - 75, 23 + 100, 28 6 @@ -229,10 +241,13 @@ 2 - 201, 3 + 268, 4 + + + 4, 4, 4, 4 - 75, 23 + 100, 28 7 @@ -253,10 +268,13 @@ 1 - 282, 3 + 376, 4 + + + 4, 4, 4, 4 - 75, 23 + 100, 28 8 @@ -280,10 +298,13 @@ True - 5, 19 + 7, 23 + + + 4, 4, 4, 4 - 56, 17 + 68, 20 0 @@ -307,10 +328,13 @@ True - 80, 20 + 107, 25 + + + 4, 4, 4, 4 - 47, 17 + 55, 20 1 @@ -340,10 +364,13 @@ Top, Left, Right - 3, 3 + 4, 4 + + + 4, 4, 4, 4 - 338, 46 + 451, 57 0 @@ -366,13 +393,16 @@ 0 - 3, 55 + 4, 69 + + + 4, 4, 4, 4 True - 338, 31 + 451, 38 1 @@ -397,10 +427,13 @@ Example-string DO NOT LOCALIZE THIS STRING TopDown - 6, 3 + 8, 4 + + + 4, 4, 4, 4 - 360, 97 + 480, 119 2 @@ -418,10 +451,16 @@ Example-string DO NOT LOCALIZE THIS STRING 0 - 6, 279 + 8, 345 + + + 4, 4, 4, 4 + + + 4, 4, 4, 4 - 270, 61 + 360, 75 1 @@ -448,10 +487,13 @@ Example-string DO NOT LOCALIZE THIS STRING NoControl - 153, 20 + 204, 25 + + + 4, 4, 4, 4 - 51, 17 + 61, 20 2 @@ -472,10 +514,16 @@ Example-string DO NOT LOCALIZE THIS STRING 0 - 6, 106 + 8, 131 + + + 4, 4, 4, 4 + + + 4, 4, 4, 4 - 270, 44 + 360, 54 0 @@ -502,10 +550,13 @@ Example-string DO NOT LOCALIZE THIS STRING RightToLeft - 6, 507 + 8, 624 + + + 4, 4, 4, 4 - 360, 31 + 480, 38 18 @@ -529,22 +580,28 @@ Example-string DO NOT LOCALIZE THIS STRING Top, Bottom, Left, Right - Microsoft Sans Serif, 100pt + Segoe UI, 7.8pt - 273, 31 + 364, 39 + + + 4, 4, 4, 4 - 25, 23 + 33, 27 18 + + MiddleCenter + m_digitNine - SIL.FieldWorks.Common.Widgets.FwTextBox, Widgets, Version=8.3.5.25382, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -555,23 +612,32 @@ Example-string DO NOT LOCALIZE THIS STRING Top, Bottom, Left, Right + + True + - Microsoft Sans Serif, 100pt + Segoe UI, 7.8pt - 243, 31 + 324, 39 + + + 4, 4, 4, 4 - 24, 23 + 32, 27 17 + + MiddleCenter + m_digitEight - SIL.FieldWorks.Common.Widgets.FwTextBox, Widgets, Version=8.3.5.25382, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -582,23 +648,32 @@ Example-string DO NOT LOCALIZE THIS STRING Top, Bottom, Left, Right + + True + - Microsoft Sans Serif, 100pt + Segoe UI, 7.8pt - 213, 31 + 284, 39 + + + 4, 4, 4, 4 - 24, 23 + 32, 27 16 + + MiddleCenter + m_digitSeven - SIL.FieldWorks.Common.Widgets.FwTextBox, Widgets, Version=8.3.5.25382, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -609,23 +684,32 @@ Example-string DO NOT LOCALIZE THIS STRING Top, Bottom, Left, Right + + True + - Microsoft Sans Serif, 100pt + Segoe UI, 7.8pt - 183, 31 + 244, 39 + + + 4, 4, 4, 4 - 24, 23 + 32, 27 15 + + MiddleCenter + m_digitSix - SIL.FieldWorks.Common.Widgets.FwTextBox, Widgets, Version=8.3.5.25382, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -636,23 +720,32 @@ Example-string DO NOT LOCALIZE THIS STRING Top, Bottom, Left, Right + + True + - Microsoft Sans Serif, 100pt + Segoe UI, 7.8pt - 153, 31 + 204, 39 + + + 4, 4, 4, 4 - 24, 23 + 32, 27 14 + + MiddleCenter + m_digitFive - SIL.FieldWorks.Common.Widgets.FwTextBox, Widgets, Version=8.3.5.25382, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -663,23 +756,32 @@ Example-string DO NOT LOCALIZE THIS STRING Top, Bottom, Left, Right + + True + - Microsoft Sans Serif, 100pt + Segoe UI, 7.8pt - 123, 31 + 164, 39 + + + 4, 4, 4, 4 - 24, 23 + 32, 27 13 + + MiddleCenter + m_digitFour - SIL.FieldWorks.Common.Widgets.FwTextBox, Widgets, Version=8.3.5.25382, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -690,23 +792,32 @@ Example-string DO NOT LOCALIZE THIS STRING Top, Bottom, Left, Right + + True + - Microsoft Sans Serif, 100pt + Segoe UI, 7.8pt - 93, 31 + 124, 39 + + + 4, 4, 4, 4 - 24, 23 + 32, 27 12 + + MiddleCenter + m_digitThree - SIL.FieldWorks.Common.Widgets.FwTextBox, Widgets, Version=8.3.5.25382, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -717,23 +828,32 @@ Example-string DO NOT LOCALIZE THIS STRING Top, Bottom, Left, Right + + True + - Microsoft Sans Serif, 100pt + Segoe UI, 7.8pt - 63, 31 + 84, 39 + + + 4, 4, 4, 4 - 24, 23 + 32, 27 11 + + MiddleCenter + m_digitTwo - SIL.FieldWorks.Common.Widgets.FwTextBox, Widgets, Version=8.3.5.25382, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -744,23 +864,32 @@ Example-string DO NOT LOCALIZE THIS STRING Top, Bottom, Left, Right + + True + - Microsoft Sans Serif, 100pt + Segoe UI, 7.8pt - 33, 31 + 44, 39 + + + 4, 4, 4, 4 - 24, 23 + 32, 27 10 + + MiddleCenter + m_digitOne - SIL.FieldWorks.Common.Widgets.FwTextBox, Widgets, Version=8.3.5.25382, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -771,23 +900,32 @@ Example-string DO NOT LOCALIZE THIS STRING Top, Bottom, Left, Right + + True + - Microsoft Sans Serif, 100pt + Segoe UI, 7.8pt - 3, 31 + 4, 39 + + + 4, 4, 4, 4 - 24, 23 + 32, 27 4 + + MiddleCenter + m_digitZero - SIL.FieldWorks.Common.Widgets.FwTextBox, Widgets, Version=8.3.5.25382, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -805,10 +943,13 @@ Example-string DO NOT LOCALIZE THIS STRING NoControl - 273, 0 + 364, 0 + + + 4, 0, 4, 0 - 25, 28 + 33, 35 9 @@ -841,10 +982,13 @@ Example-string DO NOT LOCALIZE THIS STRING NoControl - 243, 0 + 324, 0 + + + 4, 0, 4, 0 - 24, 28 + 32, 35 8 @@ -877,10 +1021,13 @@ Example-string DO NOT LOCALIZE THIS STRING NoControl - 213, 0 + 284, 0 + + + 4, 0, 4, 0 - 24, 28 + 32, 35 7 @@ -913,10 +1060,13 @@ Example-string DO NOT LOCALIZE THIS STRING NoControl - 183, 0 + 244, 0 + + + 4, 0, 4, 0 - 24, 28 + 32, 35 6 @@ -949,10 +1099,13 @@ Example-string DO NOT LOCALIZE THIS STRING NoControl - 153, 0 + 204, 0 + + + 4, 0, 4, 0 - 24, 28 + 32, 35 5 @@ -985,10 +1138,13 @@ Example-string DO NOT LOCALIZE THIS STRING NoControl - 123, 0 + 164, 0 + + + 4, 0, 4, 0 - 24, 28 + 32, 35 4 @@ -1021,10 +1177,13 @@ Example-string DO NOT LOCALIZE THIS STRING NoControl - 93, 0 + 124, 0 + + + 4, 0, 4, 0 - 24, 28 + 32, 35 3 @@ -1057,10 +1216,13 @@ Example-string DO NOT LOCALIZE THIS STRING NoControl - 63, 0 + 84, 0 + + + 4, 0, 4, 0 - 24, 28 + 32, 35 2 @@ -1093,10 +1255,13 @@ Example-string DO NOT LOCALIZE THIS STRING NoControl - 33, 0 + 44, 0 + + + 4, 0, 4, 0 - 24, 28 + 32, 35 1 @@ -1126,10 +1291,13 @@ Example-string DO NOT LOCALIZE THIS STRING True - 3, 0 + 4, 0 + + + 4, 0, 4, 0 - 24, 28 + 32, 35 0 @@ -1153,13 +1321,16 @@ Example-string DO NOT LOCALIZE THIS STRING 19 - 7, 75 + 9, 92 + + + 4, 4, 4, 4 2 - 301, 57 + 401, 70 3 @@ -1180,19 +1351,22 @@ Example-string DO NOT LOCALIZE THIS STRING <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_digitNine" Row="1" RowSpan="1" Column="9" ColumnSpan="1" /><Control Name="m_digitEight" Row="1" RowSpan="1" Column="8" ColumnSpan="1" /><Control Name="m_digitSeven" Row="1" RowSpan="1" Column="7" ColumnSpan="1" /><Control Name="m_digitSix" Row="1" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="m_digitFive" Row="1" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="m_digitFour" Row="1" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="m_digitThree" Row="1" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="m_digitTwo" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="m_digitOne" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="m_digitZero" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label11" Row="0" RowSpan="1" Column="9" ColumnSpan="1" /><Control Name="label10" Row="0" RowSpan="1" Column="8" ColumnSpan="1" /><Control Name="label9" Row="0" RowSpan="1" Column="7" ColumnSpan="1" /><Control Name="label8" Row="0" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="label7" Row="0" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="label6" Row="0" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="label4" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="label3" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="label2" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,10,Percent,10,Percent,10,Percent,10,Percent,10,Percent,10,Percent,10,Percent,10,Percent,10,Percent,10" /><Rows Styles="Percent,50,Percent,50" /></TableLayoutSettings> - 6, 45 + 8, 55 + + + 4, 4, 4, 4 True - 346, 38 + 461, 47 2 - To use characters other than 0-9 for homograph and sense numbers enter the characters here: + If the writing system uses custom numbers, they will be displayed below. Custom numbers can be specified in writing system configuration. m_customNumbersLabel @@ -1207,10 +1381,13 @@ Example-string DO NOT LOCALIZE THIS STRING 1 - 5, 18 + 7, 22 + + + 4, 4, 4, 4 - 184, 21 + 244, 24 1 @@ -1231,10 +1408,13 @@ Example-string DO NOT LOCALIZE THIS STRING True - 3, 2 + 4, 2 + + + 4, 0, 4, 0 - 246, 13 + 310, 16 0 @@ -1255,10 +1435,13 @@ Example-string DO NOT LOCALIZE THIS STRING 3 - 6, 346 + 8, 428 + + + 4, 4, 4, 4 - 341, 138 + 455, 170 22 @@ -1276,10 +1459,13 @@ Example-string DO NOT LOCALIZE THIS STRING 4 - 195, 29 + 260, 36 + + + 4, 4, 4, 4 - 75, 21 + 100, 26 3 @@ -1300,13 +1486,16 @@ Example-string DO NOT LOCALIZE THIS STRING 0 - 3, 3 + 4, 4 + + + 4, 4, 4, 4 True - 335, 24 + 447, 30 0 @@ -1327,10 +1516,13 @@ Example-string DO NOT LOCALIZE THIS STRING 1 - 3, 29 + 4, 36 + + + 4, 4, 4, 4 - 186, 21 + 247, 24 4 @@ -1348,10 +1540,13 @@ Example-string DO NOT LOCALIZE THIS STRING 2 - 6, 156 + 8, 193 + + + 4, 4, 4, 4 - 341, 57 + 455, 70 21 @@ -1372,10 +1567,13 @@ Example-string DO NOT LOCALIZE THIS STRING NoControl - 195, 27 + 260, 33 + + + 4, 4, 4, 4 - 75, 21 + 100, 26 6 @@ -1396,13 +1594,16 @@ Example-string DO NOT LOCALIZE THIS STRING 0 - 3, 0 + 4, 0 + + + 4, 4, 4, 4 True - 335, 24 + 447, 30 5 @@ -1423,10 +1624,13 @@ Example-string DO NOT LOCALIZE THIS STRING 1 - 3, 27 + 4, 33 + + + 4, 4, 4, 4 - 186, 21 + 247, 24 7 @@ -1444,10 +1648,13 @@ Example-string DO NOT LOCALIZE THIS STRING 2 - 6, 219 + 8, 271 + + + 4, 4, 4, 4 - 341, 54 + 455, 66 23 @@ -1471,16 +1678,16 @@ Example-string DO NOT LOCALIZE THIS STRING 0, 0 - 5, 5, 5, 5 + 7, 6, 7, 6 - 3, 0, 0, 0 + 4, 0, 0, 0 7 - 369, 541 + 492, 666 16 @@ -1504,13 +1711,16 @@ Example-string DO NOT LOCALIZE THIS STRING True - 6, 13 + 8, 16 - 369, 541 + 492, 666 + + + 4, 4, 4, 4 - 385, 580 + 507, 703 Configure Headword Numbers diff --git a/Src/xWorks/HeadWordNumbersHelper.cs b/Src/xWorks/HeadWordNumbersHelper.cs new file mode 100644 index 0000000000..98ef887fe7 --- /dev/null +++ b/Src/xWorks/HeadWordNumbersHelper.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; + +namespace SIL.FieldWorks.XWorks +{ + public static class HeadWordNumbersHelper + { + public static List GetUnicodeCharacters(string digits) + { + if (!string.IsNullOrEmpty(digits)) + { + // Note that some digits use surrogate pairs in UTF-16, so it's not as simple as splitting into a char array. + // We need to check for surrogate pairs to split everything correctly into Unicode characters. + var characters = new List(); + for (int i = 0; i < digits.Length; i++) + { + // The first part of a surrogate pair is the high surrogate and the second part is the low surrogate. + if (char.IsHighSurrogate(digits[i]) && i + 1 < digits.Length && + char.IsLowSurrogate(digits[i + 1])) + { + characters.Add(digits.Substring(i, 2)); + i++; // Skip the next char since it's part of the surrogate pair we just added. + } + else + { + characters.Add(digits[i].ToString()); + } + } + if (characters.Count == 10) + return characters; + } + return null; + } + } +} diff --git a/Src/xWorks/IHeadwordNumbersView.cs b/Src/xWorks/IHeadwordNumbersView.cs index 5d65a339aa..487c96076e 100644 --- a/Src/xWorks/IHeadwordNumbersView.cs +++ b/Src/xWorks/IHeadwordNumbersView.cs @@ -16,7 +16,6 @@ namespace SIL.FieldWorks.XWorks public interface IHeadwordNumbersView { event EventHandler RunStylesDialog; - event EventHandler CustomDigitsChanged; bool HomographBefore { get; set; } bool ShowHomograph { get; set; } bool ShowHomographOnCrossRef { get; set; } @@ -26,6 +25,5 @@ public interface IHeadwordNumbersView string HomographWritingSystem { get; set; } IEnumerable AvailableWritingSystems { set; } IEnumerable CustomDigits { get; set; } - void SetWsFactoryForCustomDigits(ILgWritingSystemFactory factory); } } \ No newline at end of file diff --git a/Src/xWorks/xWorksTests/DictionaryConfigurationModelTests.cs b/Src/xWorks/xWorksTests/DictionaryConfigurationModelTests.cs index 98691d9b36..62ae86eef8 100644 --- a/Src/xWorks/xWorksTests/DictionaryConfigurationModelTests.cs +++ b/Src/xWorks/xWorksTests/DictionaryConfigurationModelTests.cs @@ -501,7 +501,6 @@ public void Save_HomographConfigurationValidatesAgainstSchema() Label = "root", HomographConfiguration = new DictionaryHomographConfiguration { - CustomHomographNumbers = "0;1;2;3;4;5;6;7;8;9", HomographNumberBefore = true, HomographWritingSystem = "en", ShowHwNumber = true, @@ -1234,7 +1233,6 @@ public void CanDeepClone() // If we were on NUnit 4 // Assert.That(model.HomographConfiguration, Is.EqualTo(clone.HomographConfiguration).UsingPropertiesComparer()); // But we're not, so we have to do it manually or implement otherwise unnecessary equality interfaces - Assert.That(model.HomographConfiguration.CustomHomographNumbers, Is.EqualTo(clone.HomographConfiguration.CustomHomographNumbers)); Assert.That(model.HomographConfiguration.HomographNumberBefore, Is.EqualTo(clone.HomographConfiguration.HomographNumberBefore)); Assert.That(model.HomographConfiguration.HomographWritingSystem, Is.EqualTo(clone.HomographConfiguration.HomographWritingSystem)); Assert.That(model.HomographConfiguration.ShowHwNumber, Is.EqualTo(clone.HomographConfiguration.ShowHwNumber)); diff --git a/Src/xWorks/xWorksTests/HeadwordNumbersControllerTests.cs b/Src/xWorks/xWorksTests/HeadwordNumbersControllerTests.cs index 68b78005de..8eee92e86b 100644 --- a/Src/xWorks/xWorksTests/HeadwordNumbersControllerTests.cs +++ b/Src/xWorks/xWorksTests/HeadwordNumbersControllerTests.cs @@ -9,6 +9,7 @@ using SIL.LCModel.Core.WritingSystems; using SIL.LCModel.Core.KernelInterfaces; using SIL.LCModel.DomainImpl; +using SIL.WritingSystems; namespace SIL.FieldWorks.XWorks { @@ -138,49 +139,34 @@ public void Save_SetsModelContents_Reversal() public void Ok_Enabled_WithNoCustomNumbers() { // Test enabled on initial setup - var view = new TestHeadwordNumbersView {OkButtonEnabled = false}; + var view = new TestHeadwordNumbersView { OkButtonEnabled = false }; var model = new DictionaryConfigurationModel(); var controller = new HeadwordNumbersController(view, model, Cache); // verify ok button enabled on setup with no numbers - Assert.That(view.OkButtonEnabled, Is.True, "Ok not enabled by controller constructor"); - view.OkButtonEnabled = false; - // verify ok button enabled when event is triggered and there are no custom numbers - view.TriggerCustomDigitsChanged(); - Assert.That(view.OkButtonEnabled, Is.True, "Ok button not enabled when event is fired"); + Assert.That(view.OkButtonEnabled, Is.True, + "Ok not enabled by controller constructor"); } [Test] - public void Ok_Enabled_WithAllTenNumbers() + public void CustomDigits_Default_Ok_Enabled_WhenNotAllTenNumbersSet() { - // Test enabled on initial setup - var view = new TestHeadwordNumbersView { OkButtonEnabled = false }; - var model = new DictionaryConfigurationModel + var model = new DictionaryConfigurationModel() { - HomographConfiguration = new DictionaryHomographConfiguration - { - CustomHomographNumbers = "a,b,c,d,e,f,g,h,i,j" - } + HomographConfiguration = new DictionaryHomographConfiguration() }; - var controller = new HeadwordNumbersController(view, model, Cache); - // verify ok button enabled on setup with 10 numbers - Assert.That(view.OkButtonEnabled, Is.True, "Ok not enabled by controller constructor"); - view.OkButtonEnabled = false; - // verify ok button enabled when event is triggered and there are 10 custom numbers - view.TriggerCustomDigitsChanged(); - Assert.That(view.OkButtonEnabled, Is.True, "Ok button not enabled when event is fired"); - } + var view = new TestHeadwordNumbersView() + { + HomographWritingSystem = model.HomographConfiguration.HomographWritingSystem = "en" + }; + var writingSystem = Cache.ServiceLocator.WritingSystemManager.Get(view.HomographWritingSystem); + writingSystem.NumberingSystem = NumberingSystemDefinition.CreateCustomSystem("1"); - [Test] - public void Ok_Disabled_WhenNotAllTenNumbersSet() - { - // Test enabled on initial setup - var view = new TestHeadwordNumbersView(); - var model = new DictionaryConfigurationModel(); - var controller = new HeadwordNumbersController(view, model, Cache); - view.OkButtonEnabled = true; - view.CustomDigits = new List { "1" }; - view.TriggerCustomDigitsChanged(); - Assert.That(view.OkButtonEnabled, Is.False, "Ok button still enabled after event is fired"); + // If the writing system doesn't have a valid numbering system with 10 digits, + // the view should fall back to the default latin digits and still enable Ok. + var defaultNumberingSystem = NumberingSystemDefinition.CreateCustomSystem("0123456789"); + var testController = new HeadwordNumbersController(view, model, Cache); + Assert.That(view.CustomDigits, Is.EqualTo(HeadWordNumbersHelper.GetUnicodeCharacters(defaultNumberingSystem.Digits))); + Assert.That(view.OkButtonEnabled, Is.True, "Ok button not enabled after event is fired"); } [Test] @@ -235,20 +221,21 @@ public void ConstructorSetsDefaultWritingSystemInView() } [Test] - public void ConstructorSetsCustomHeadwordNumbersInView() + public void ConstructorSetsHeadwordWritingSystemNumbersInView() { - var view = new TestHeadwordNumbersView(); - var model = new DictionaryConfigurationModel + var model = new DictionaryConfigurationModel() { - HomographConfiguration = new DictionaryHomographConfiguration - { - CustomHomographNumbers = "a;b;c;d;e;f;g;h;i;j;k" - } + HomographConfiguration = new DictionaryHomographConfiguration() }; - // ReSharper disable once UnusedVariable - // SUT + var view = new TestHeadwordNumbersView() + { + HomographWritingSystem = model.HomographConfiguration.HomographWritingSystem = "en" + }; + var writingSystem = Cache.ServiceLocator.WritingSystemManager.Get(view.HomographWritingSystem); + writingSystem.NumberingSystem = NumberingSystemDefinition.CreateCustomSystem("abcdefghij"); + var testController = new HeadwordNumbersController(view, model, Cache); - Assert.That(view.CustomDigits, Is.EqualTo(model.HomographConfiguration.CustomHomographNumberList)); + Assert.That(view.CustomDigits, Is.EqualTo(HeadWordNumbersHelper.GetUnicodeCharacters(writingSystem.NumberingSystem.Digits))); } public class TestHeadwordNumbersView : IHeadwordNumbersView @@ -267,13 +254,7 @@ public class TestHeadwordNumbersView : IHeadwordNumbersView #pragma warning restore 67 public IEnumerable AvailableWritingSystems { private get; set; } public IEnumerable CustomDigits { get; set; } - public event EventHandler CustomDigitsChanged; public bool OkButtonEnabled { get; set; } - - internal void TriggerCustomDigitsChanged() - { - CustomDigitsChanged(this, null); - } public void SetWsFactoryForCustomDigits(ILgWritingSystemFactory factory) { } } }