Exemplo n.º 1
0
        private void SelectItem(StringHost item)
        {
            if (item == null)
            {
                // clearn current selection
                if (_SelectedItem != null)
                {
                    _SelectedItem.IsSelected = false;
                }
            }
            else if (item != null && item._IsSelectable)
            {
                // clearn current selection
                if (_SelectedItem != null)
                {
                    _SelectedItem.IsSelected = false;
                }

                // select the new item
                _SelectedItem   = item;
                item.IsSelected = true;

                // udpate the index
                _SelectedIndexInView = StringHostItems.IndexOf(item);
            }
        }
Exemplo n.º 2
0
        private void ItemMouseDown(object sender, MouseEventArgs e)
        {
            FrameworkElement element = (sender as FrameworkElement);

            if (element != null)
            {
                StringHost item = (element.DataContext as StringHost);
                SelectItem(item);
            }
        }
Exemplo n.º 3
0
        private void ItemMouseLeave(object sender, MouseEventArgs e)
        {
            if (this.IsMouseCaptured)
            {
                FrameworkElement element = (sender as FrameworkElement);
                if (element != null)
                {
                    StringHost item  = (element.DataContext as StringHost);
                    int        index = StringHostItems.IndexOf(item);

                    if (index == 9)
                    {
                        Point p = e.GetPosition(element);

                        if (p.Y > 0)
                        {
                            if (_SelectNextTimer == null)
                            {
                                _SelectNextTimer          = new DispatcherTimer();
                                _SelectNextTimer.Tick    += new EventHandler(_SelectNextTimer_Tick);
                                _SelectNextTimer.Interval = TimeSpan.FromMilliseconds(100);
                            }

                            _SelectNextTimer.Start();
                        }
                    }

                    if (index == 0)
                    {
                        Point p = e.GetPosition(element);

                        if (p.Y < 0)
                        {
                            if (_SelectPreviousTimer == null)
                            {
                                _SelectPreviousTimer          = new DispatcherTimer();
                                _SelectPreviousTimer.Tick    += new EventHandler(_SelectPreviousTimer_Tick);
                                _SelectPreviousTimer.Interval = TimeSpan.FromMilliseconds(100);
                            }

                            _SelectPreviousTimer.Start();
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        private int SelectItemByIndex(int index)
        {
            // coerce the index property
            if (index >= CompletionItems.Count)
            {
                index = CompletionItems.Count - 1;
            }
            if (index < 0)
            {
                index = 0;
            }

            StringHost item = StringHostItems[index];

            SelectItem(item);

            return(_SelectedIndexInView);
        }
Exemplo n.º 5
0
        private void ItemMouseEnter(object sender, MouseEventArgs e)
        {
            if (_SelectNextTimer != null)
            {
                _SelectNextTimer.Stop();
            }

            if (_SelectPreviousTimer != null)
            {
                _SelectPreviousTimer.Stop();
            }

            if (this.IsMouseCaptured)
            {
                FrameworkElement element = (sender as FrameworkElement);
                if (element != null)
                {
                    StringHost item = (element.DataContext as StringHost);
                    SelectItem(item);
                }
            }
        }
Exemplo n.º 6
0
        private void SelectItem(StringHost item)
        {
            if (item == null)
            {
                // clearn current selection
                if (_SelectedItem != null) _SelectedItem.IsSelected = false;
            }
            else if (item != null && item._IsSelectable)
            {
                // clearn current selection
                if (_SelectedItem != null) _SelectedItem.IsSelected = false;

                // select the new item
                _SelectedItem = item;
                item.IsSelected = true;

                // udpate the index
                _SelectedIndexInView = StringHostItems.IndexOf(item);
            }
        }