public DictionaryHomographConfiguration(HomographConfiguration config)
 {
     HomographNumberBefore       = config.HomographNumberBefore;
     ShowSenseNumber             = config.ShowSenseNumberRef;
     ShowSenseNumberReversal     = config.ShowSenseNumberReversal;
     ShowHwNumber                = config.ShowHomographNumber(HomographConfiguration.HeadwordVariant.Main);
     ShowHwNumInCrossRef         = config.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef);
     ShowHwNumInReversalCrossRef = config.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef);
     HomographWritingSystem      = config.WritingSystem;
     CustomHomographNumberList   = config.CustomHomographNumbers;
 }
Example #2
0
 /// <summary>
 /// This method will use the current homograph-number settings to insert the homograph number into the string
 /// </summary>
 public static void InsertHomographNumber(ITsIncStrBldr tisb, int nHomograph, HomographConfiguration hc,
                                          HomographConfiguration.HeadwordVariant hv, LcmCache cache)
 {
     if (nHomograph > 0 && hc.ShowHomographNumber(hv))
     {
         tisb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, HomographConfiguration.ksHomographNumberStyle);
         if (!string.IsNullOrEmpty(hc.WritingSystem))
         {
             tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, cache.WritingSystemFactory.GetWsFromStr(hc.WritingSystem));
         }
         else
         {
             tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, cache.DefaultVernWs);
         }
         var hnString = nHomograph.ToString();
         if (hc.CustomHomographNumbers.Count == 10)
         {
             for (var i = 0; i < 10; ++i)
             {
                 hnString = hnString.Replace(i.ToString(), hc.CustomHomographNumbers[i]);
             }
         }
         tisb.Append(hnString);
         tisb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, null);
     }
 }
        public void PersistData()
        {
            var hc = new HomographConfiguration();

            Assert.That(hc.PersistData, Is.EqualTo(""));
            hc.HomographNumberBefore = true;
            hc.ShowSenseNumberRef    = false;
            Assert.That(hc.PersistData, Is.EqualTo("before snRef "));
            var hc2 = new HomographConfiguration();

            hc2.PersistData = hc.PersistData;
            Assert.That(hc2.ShowSenseNumberRef, Is.False);
            Assert.That(hc2.HomographNumberBefore, Is.True);
            Assert.That(hc2.ShowSenseNumberReversal, Is.True);

            hc.SetShowHomographNumber(HomographConfiguration.HeadwordVariant.Main, false);
            hc2.PersistData = hc.PersistData;
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.Main), Is.False);
            Assert.That(hc2.HomographNumberBefore, Is.False);

            hc.SetShowHomographNumber(HomographConfiguration.HeadwordVariant.Main, true);
            hc.SetShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef, false);
            hc2.PersistData = hc.PersistData;
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.Main), Is.True);
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef), Is.False);
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef), Is.True);

            hc.SetShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef, false);
            hc2.PersistData = hc.PersistData;
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.Main), Is.True);
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef), Is.False);
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef), Is.False);

            hc.SetShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef, true);
            hc2.PersistData = hc.PersistData;
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.Main), Is.True);
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef), Is.True);
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef), Is.False);

            hc.ShowSenseNumberRef      = true;
            hc.ShowSenseNumberReversal = false;
            hc2.PersistData            = hc.PersistData;
            Assert.That(hc2.ShowSenseNumberRef, Is.True);
            Assert.That(hc2.ShowSenseNumberReversal, Is.False);
        }
Example #4
0
        public void SetsViewDataFromDefaultsIfNoHomographConfigurationInConfigurationModel()
        {
            var hc   = new HomographConfiguration();
            var view = new TestHeadwordNumbersView
            {
                HomographBefore = !hc.HomographNumberBefore,
                ShowHomograph   = !hc.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef),
                ShowSenseNumber = !hc.ShowSenseNumberRef
            };
            var model = new DictionaryConfigurationModel();
            // ReSharper disable once UnusedVariable
            var testController = new HeadwordNumbersController(view, model, Cache);

            view.Show();
            Assert.AreEqual(view.HomographBefore, hc.HomographNumberBefore);
            Assert.AreEqual(view.ShowHomographOnCrossRef, hc.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef));
            Assert.AreEqual(view.ShowSenseNumber, hc.ShowSenseNumberRef);
        }
 private static void InsertHomographNumber(TsIncStrBldr tisb, int nHomograph, HomographConfiguration hc,
                                           HomographConfiguration.HeadwordVariant hv)
 {
     if (nHomograph > 0 && hc.ShowHomographNumber(hv))
     {
         tisb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, HomographConfiguration.ksHomographNumberStyle);
         tisb.Append(nHomograph.ToString());
         tisb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, null);
     }
 }
        public void HomographConfiguration_Persist_RestoresOldConfig()
        {
            // property string settings which set homograph to before, turn off the dictionary cross reference(hn:dcr),
            // turn off the reversal cross reference(hn:rcr), turn off show sense number in both dictionary and reversal
            const string oldConfigString = "before hn:dcr hn:rcr snRef snRev";
            var          settings        = new HomographConfiguration();

            Assert.IsFalse(settings.HomographNumberBefore);
            Assert.IsTrue(settings.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef));
            Assert.IsTrue(settings.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef));
            Assert.IsTrue(settings.ShowSenseNumberRef);
            Assert.IsTrue(settings.ShowSenseNumberReversal);
            settings.PersistData = oldConfigString;
            Assert.IsTrue(settings.HomographNumberBefore);
            Assert.IsFalse(settings.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef));
            Assert.IsFalse(settings.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef));
            Assert.IsFalse(settings.ShowSenseNumberRef);
            Assert.IsFalse(settings.ShowSenseNumberReversal);
        }
        protected string m_helpTopic = "";         // Default help topic ID


        public void SetupDialog(HomographConfiguration hc, FdoCache cache, FwStyleSheet stylesheet, IApp app,
                                IHelpTopicProvider helpTopicProvider)
        {
            SetHelpTopic("khtpConfigureHomograph");             // Default help topic ID
            m_helpProvider = new HelpProvider();
            m_helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            m_helpProvider.SetShowHelp(this, true);

            m_cache             = cache;
            m_stylesheet        = stylesheet;
            m_app               = app;
            m_helpTopicProvider = helpTopicProvider;
            if (m_helpTopicProvider != null)
            {
                m_helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
                SetHelpButtonEnabled();
            }

            if (hc.ShowHomographNumber(HomographConfiguration.HeadwordVariant.Main))
            {
                m_radioHide.Checked                 = false;
                m_radioBefore.Checked               = hc.HomographNumberBefore;
                m_radioAfter.Checked                = !hc.HomographNumberBefore;
                m_chkShowSenseNumInDict.Checked     = hc.ShowSenseNumberRef;
                m_chkShowSenseNumInReversal.Checked = hc.ShowSenseNumberReversal;
            }
            else
            {
                m_radioHide.Checked                 = true;
                m_radioBefore.Checked               = false;
                m_radioAfter.Checked                = false;
                m_chkShowSenseNumInDict.Checked     = false;
                m_chkShowSenseNumInReversal.Checked = false;
            }
            m_chkShowHomographNumInDict.Checked =
                hc.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef);
            m_chkShowHomographNumInReversal.Checked =
                hc.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef);
            EnableControls();
        }