Initialize() public method

Initializes this CharContextCtrl
public Initialize ( SIL.FieldWorks.FDO.FdoCache cache, IWritingSystemContainer wsContainer, IWritingSystem ws, IApp app, Font contextFont, System.Windows.Forms.DataGridView tokenGrid ) : void
cache SIL.FieldWorks.FDO.FdoCache The cache.
wsContainer IWritingSystemContainer The writing system container.
ws IWritingSystem The language definition.
app IApp The application.
contextFont System.Drawing.Font The context font.
tokenGrid System.Windows.Forms.DataGridView The token grid.
return void
Ejemplo n.º 1
0
        public void GetTokenSubstrings_ValidatorThatRemovesSomeResults()
        {
            using (var ctrl = new CharContextCtrl())
            {
                ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems,
                                null, null, null, null);
                ctrl.ListValidator = RemoveFirstAndLastSubString;

                var        tokens = new List <ITextToken>();
                ITextToken token  = new ScrCheckingToken();
                ReflectionHelper.SetField(token, "m_sText", "Mom. Dad! Brother(Sister)");
                tokens.Add(token);
                var inventory = new DummyScrInventory
                {
                    m_references = new List <TextTokenSubstring>
                    {
                        new TextTokenSubstring(token, 3, 2),
                        new TextTokenSubstring(token, 8, 2),
                        new TextTokenSubstring(token, 17, 1),
                        new TextTokenSubstring(token, 24, 1)
                    }
                };
                var validatedList =
                    (List <TextTokenSubstring>)ReflectionHelper.GetResult(ctrl, "GetTokenSubstrings",
                                                                          inventory, tokens);
                Assert.AreEqual(2, validatedList.Count);
                Assert.AreEqual("! ", validatedList[0].Text);
                Assert.AreEqual("(", validatedList[1].Text);
            }
        }
Ejemplo n.º 2
0
        public void NormalizeFileData_Hebrew()
        {
            using (var ctrl = new CharContextCtrl())
            {
                ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems,
                                null, null, null, null);

                // First string is the normalized order that ICU produces.
                // Second string is the normalized order that .Net produces.
                var icuStyleNormalizationOrder    = "\u05E9\u05c1\u05b4\u0596";
                var dotnetStyleNormalizationOrder = "\u05E9\u05b4\u05c1\u0596";
                ReflectionHelper.SetField(ctrl, "m_fileData",
                                          new[] { icuStyleNormalizationOrder, dotnetStyleNormalizationOrder });

                // SUT
                ReflectionHelper.CallMethod(ctrl, "NormalizeFileData");

                // Verify
                var results = (string[])ReflectionHelper.GetField(ctrl, "m_fileData");
                Assert.That(results.Length, Is.EqualTo(2));
                Assert.That(results[0], Is.EqualTo(icuStyleNormalizationOrder),
                            GetMessage("Expect ICU-style normalization (from ICU order)",
                                       icuStyleNormalizationOrder,
                                       results[0]));
                Assert.That(results[1], Is.EqualTo(icuStyleNormalizationOrder),
                            GetMessage("Expect ICU-style normalization (from .NET order)",
                                       icuStyleNormalizationOrder,
                                       results[1]));
            }
        }
Ejemplo n.º 3
0
        public void NormalizeFileData_EnsureNFD()
        {
            using (var ctrl = new CharContextCtrl())
            {
                ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems,
                                null, null, null, null);

                // First string is the normalized order that ICU produces.
                // Second string is the normalized order that .Net produces.
                ReflectionHelper.SetField(ctrl, "m_fileData", new[] { "\u2074" });

                ReflectionHelper.CallMethod(ctrl, "NormalizeFileData");

                var results = (string[])ReflectionHelper.GetField(ctrl, "m_fileData");
                Assert.AreEqual(1, results.Length);
                Assert.AreEqual("\u2074", results[0], "Expect ICU-style normalization");
            }
        }
Ejemplo n.º 4
0
        public void NormalizeFileData_EnsureNFD()
        {
            using (var ctrl = new CharContextCtrl())
            {
                ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems,
                                null, null, null, null);

                ReflectionHelper.SetField(ctrl, "m_fileData", new[] { "\u2074" });

                // SUT
                ReflectionHelper.CallMethod(ctrl, "NormalizeFileData");

                // Verify
                var results = (string[])ReflectionHelper.GetField(ctrl, "m_fileData");
                Assert.That(results.Length, Is.EqualTo(1));
                Assert.That(results[0], Is.EqualTo("\u2074"), "Expect ICU-style normalization");
            }
        }
Ejemplo n.º 5
0
        public void GetTokenSubstrings_NoValidator()
        {
            using (var ctrl = new CharContextCtrl())
            {
                ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems,
                                null, null, null, null);

                var        tokens = new List <ITextToken>();
                ITextToken token  = new ScrCheckingToken();
                ReflectionHelper.SetField(token, "m_sText", "Mom. Dad!");
                tokens.Add(token);
                var inventory = new DummyScrInventory
                {
                    m_references = new List <TextTokenSubstring>
                    {
                        new TextTokenSubstring(token, 3, 2)
                    }
                };
                var validatedList = (List <TextTokenSubstring>)ReflectionHelper.GetResult(ctrl, "GetTokenSubstrings",
                                                                                          inventory, tokens);
                Assert.AreEqual(1, validatedList.Count);
                Assert.AreEqual(". ", validatedList[0].Text);
            }
        }
Ejemplo n.º 6
0
		public void GetTokenSubstrings_ValidatorThatRemovesSomeResults()
		{
			using (var ctrl = new CharContextCtrl())
			{
				ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems,
					null, null, null, null);
				ctrl.ListValidator = RemoveFirstAndLastSubString;

				var tokens = new List<ITextToken>();
				ITextToken token = new ScrCheckingToken();
				ReflectionHelper.SetField(token, "m_sText", "Mom. Dad! Brother(Sister)");
				tokens.Add(token);
				var inventory = new DummyScrInventory
									{
										m_references = new List<TextTokenSubstring>
														{
															new TextTokenSubstring(token, 3, 2),
															new TextTokenSubstring(token, 8, 2),
															new TextTokenSubstring(token, 17, 1),
															new TextTokenSubstring(token, 24, 1)
														}
									};
				var validatedList =
					(List<TextTokenSubstring>)ReflectionHelper.GetResult(ctrl, "GetTokenSubstrings",
					inventory, tokens);
				Assert.AreEqual(2, validatedList.Count);
				Assert.AreEqual("! ", validatedList[0].Text);
				Assert.AreEqual("(", validatedList[1].Text);
			}
		}
Ejemplo n.º 7
0
		public void GetTokenSubstrings_NoValidator()
		{
			using (var ctrl = new CharContextCtrl())
			{
				ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems,
					null, null, null, null);

				var tokens = new List<ITextToken>();
				ITextToken token = new ScrCheckingToken();
				ReflectionHelper.SetField(token, "m_sText", "Mom. Dad!");
				tokens.Add(token);
				var inventory = new DummyScrInventory
													{
														m_references = new List<TextTokenSubstring>
															{ new TextTokenSubstring(token, 3, 2) }
													};
				var validatedList = (List<TextTokenSubstring>)ReflectionHelper.GetResult(ctrl, "GetTokenSubstrings",
					inventory, tokens);
				Assert.AreEqual(1, validatedList.Count);
				Assert.AreEqual(". ", validatedList[0].Text);
			}
		}
Ejemplo n.º 8
0
		public void NormalizeFileData_EnsureNFD()
		{
			using (var ctrl = new CharContextCtrl())
			{
				ctrl.Initialize(Cache, Cache.ServiceLocator.WritingSystems,
					null, null, null, null);

				// First string is the normalized order that ICU produces.
				// Second string is the normalized order that .Net produces.
				ReflectionHelper.SetField(ctrl, "m_fileData", new[] { "\u2074" });

				ReflectionHelper.CallMethod(ctrl, "NormalizeFileData");

				var results = (string[])ReflectionHelper.GetField(ctrl, "m_fileData");
				Assert.AreEqual(1, results.Length);
				Assert.AreEqual("\u2074", results[0], "Expect ICU-style normalization");
			}
		}