예제 #1
0
 private void AddToDictionary(string language, string s)
 {
     _dictionaries[language].Add(s);
     _hotSpotProvider.RefreshAll();
 }
예제 #2
0
        public void RefreshAll_TriggersRetrieveHotSpotEventForAllEnabled()
        {
            TextBox textBox1 = new TextBox();
            TextBox textBox2 = new TextBox();
            TextBox textBox3 = new TextBox();
            TextBox textBox4 = new TextBox();

            _hotSpotProvider.SetEnableHotSpots(textBox1, true);
            _hotSpotProvider.SetEnableHotSpots(textBox2, false);
            _hotSpotProvider.SetEnableHotSpots(textBox3, false);
            _hotSpotProvider.SetEnableHotSpots(textBox4, true);

            bool retrieveHotSpots1Called = false;
            bool retrieveHotSpots2Called = false;
            bool retrieveHotSpots3Called = false;
            bool retrieveHotSpots4Called = false;

            _hotSpotProvider.RetrieveHotSpots +=
                delegate(object sender, RetrieveHotSpotsEventArgs e)
            {
                if (e.Control == textBox1)
                {
                    retrieveHotSpots1Called = true;
                    return;
                }
                if (e.Control == textBox2)
                {
                    retrieveHotSpots2Called = true;
                    return;
                }
                if (e.Control == textBox3)
                {
                    retrieveHotSpots3Called = true;
                    return;
                }
                if (e.Control == textBox4)
                {
                    retrieveHotSpots4Called = true;
                    return;
                }
                throw new InvalidOperationException();
            };

            // reset since installing the handler causes it to fire.
            retrieveHotSpots1Called = false;
            retrieveHotSpots2Called = false;
            retrieveHotSpots3Called = false;
            retrieveHotSpots4Called = false;

            // force hotSpotProvider to retrieve HotSpots
            _hotSpotProvider.RefreshAll();

            Assert.IsTrue(retrieveHotSpots1Called);
            Assert.IsFalse(retrieveHotSpots2Called);
            Assert.IsFalse(retrieveHotSpots3Called);
            Assert.IsTrue(retrieveHotSpots4Called);

            textBox1.Dispose();
            textBox2.Dispose();
            textBox3.Dispose();
            textBox4.Dispose();
        }