Esempio n. 1
0
        public void GeckoListBox_TestAddItem()
        {
            IWritingSystemDefinition ws  = WritingSystemDefinition.Parse("fr");
            IWritingSystemDefinition ws2 = WritingSystemDefinition.Parse("en");
            var listBox = new GeckoListBox();

            listBox.FormWritingSystem    = ws;
            listBox.MeaningWritingSystem = ws2;
            listBox.Name = "ControlUnderTest";
            Assert.IsNotNull(listBox);

            String volvo  = "Volvo";
            String saab   = "Saab";
            String toyota = "Toyota";

            listBox.AddItem(volvo);
            listBox.AddItem(saab);
            listBox.AddItem(toyota);

            Assert.AreSame(saab, listBox.GetItem(1));
            Assert.AreSame(toyota, listBox.GetItem(2));
            Assert.AreEqual(3, listBox.Length);
            Assert.AreSame(ws2, listBox.MeaningWritingSystem);

            listBox.Clear();
            Assert.AreEqual(0, listBox.Length);
        }
Esempio n. 2
0
        public void GeckoListBox_CreateWithWritingSystem()
        {
            IWritingSystemDefinition ws = WritingSystemDefinition.Parse("fr");
            var listBox = new GeckoListBox(ws, null);

            Assert.IsNotNull(listBox);
            Assert.AreSame(ws, listBox.WritingSystem);
            Assert.AreSame(ws, listBox.FormWritingSystem);
        }
Esempio n. 3
0
        public void GeckoListBox_TestGetRectangle()
        {
            _countOfItemsDrawn     = 0;
            _itemToNotDrawYetDrawn = false;
            IWritingSystemDefinition ws  = WritingSystemDefinition.Parse("fr");
            IWritingSystemDefinition ws2 = WritingSystemDefinition.Parse("en");

            _listBox = new GeckoListBox();
            _listBox.FormWritingSystem    = ws;
            _listBox.MeaningWritingSystem = ws2;
            _listBox.Name = "ControlUnderTest";
            Assert.IsNotNull(_listBox);

            String volvo  = "Volvo";
            String saab   = "Saab";
            String toyota = "Toyota";

            _listBox.AddItem(volvo);
            _listBox.AddItem(saab);
            _listBox.AddItem(toyota);

            _listBox.ItemDrawer = GeckoListBox_TestDrawItem;
            _listBox.ListCompleted();

            Application.DoEvents();

            _window.Controls.Add(_listBox);
            _window.Show();
            ControlTester t = new ControlTester("ControlUnderTest", _window);

            Application.DoEvents();
            Rectangle r = _listBox.GetItemRectangle(1);

            Application.DoEvents();

            using (MouseController mc = new MouseController(t))
            {
                mc.Click(r.Right + 5, r.Top + 5);
            }

            Application.DoEvents();
            Application.DoEvents();

            Assert.AreEqual(1, _listBox.SelectedIndex);
            Assert.AreSame(_listBox.SelectedItem, saab);
        }
Esempio n. 4
0
        public void GeckoListBox_TestDrawItem()
        {
            _countOfItemsDrawn     = 0;
            _itemToNotDrawYetDrawn = false;
            IWritingSystemDefinition ws  = WritingSystemDefinition.Parse("fr");
            IWritingSystemDefinition ws2 = WritingSystemDefinition.Parse("en");

            _listBox = new GeckoListBox();
            _listBox.FormWritingSystem    = ws;
            _listBox.MeaningWritingSystem = ws2;
            _listBox.Name = "ControlUnderTest";
            Assert.IsNotNull(_listBox);

            String volvo  = "Volvo";
            String saab   = "Saab";
            String toyota = "Toyota";

            _listBox.AddItem(volvo);
            _listBox.AddItem(saab);
            _listBox.AddItem(toyota);

            _listBox.ItemToNotDrawYet = saab;
            _listBox.ItemDrawer       = GeckoListBox_TestDrawItem;
            _listBox.ListCompleted();

            Application.DoEvents();

            _window.Controls.Add((GeckoListBox)_listBox);
            _window.Show();

            Application.DoEvents();

            // Count may be 2 or 4 depending on whether adjust height
            // ran yet or not
            if (_countOfItemsDrawn != 2)
            {
                Assert.AreEqual(4, _countOfItemsDrawn);
            }
            Assert.IsTrue(_itemToNotDrawYetDrawn == false);
        }
Esempio n. 5
0
        public GeckoAutoCompleteTextBox()
        {
            if (DesignMode)
            {
                return;
            }

            _formToObjectFinderDelegate = DefaultFormToObjectFinder;
            _itemFilterDelegate         = FilterList;

            Leave += Popup_Deactivate;

            _toolTip    = new ToolTip();
            MouseHover += OnMouseHover;

            // Create the list box that will hold matching items
            _listBox             = new GeckoListBox();
            _listBox.MaximumSize = new Size(800, 100);
            _listBox.Cursor      = Cursors.Hand;
            _listBox.BorderStyle = BorderStyle.FixedSingle;
            _listBox.MultiColumn = false;
            //_listBox.SelectedIndexChanged += List_SelectedIndexChanged;
            _listBox.UserClick      += List_Click;
            _listBox.ListLostFocus  += OnListLostFocus;
            _listBox.Enter          += List_Enter;
            _listBox.Leave          += List_Leave;
            _listBox.ItemHeight      = _listBox.Font.Height;
            _listBox.Visible         = false;
            _listBox.Sorted          = false;
            _listBox.HighlightSelect = true;

            // Add default triggers.
            triggers.Add(new TextLengthTrigger(2));
            triggers.Add(new ShortCutTrigger(Keys.Enter, TriggerState.Select));
            triggers.Add(new ShortCutTrigger(Keys.Tab, TriggerState.Select));
            triggers.Add(new ShortCutTrigger(Keys.Control | Keys.Space, TriggerState.ShowAndConsume));
            triggers.Add(new ShortCutTrigger(Keys.Escape, TriggerState.HideAndConsume));
        }