Пример #1
0
        private void Watcher_Changed(object sender, FileSystemEventArgs e)
        {
            lock (ThreadLock)
            {
                Timer.Restart();

                if (!Waiting)
                {
                    Waiting = true;
                    BeforeChange?.Invoke(this, e);
                    Task.Run(() => {
                        while (true)
                        {
                            lock (ThreadLock)
                            {
                                Waiting = true;
                                if (Timer.ElapsedMilliseconds >= Threshold)
                                {
                                    break;
                                }
                            }

                            Thread.Sleep(1);
                        }

                        Waiting = false;
                        AfterChange?.Invoke(this, e);
                    });
                }
            }
        }
Пример #2
0
 private void onSuggestionListClick(object sender, EventArgs e)
 {
     //Text = m_list.SelectedItems[0].Text;
     //Select(0, Text.Length);
     m_fromKeyboard = false;
     hideDropDown();
     if (AfterChange != null)
     {
         AfterChange.Invoke(this, e);
     }
 }
Пример #3
0
        /// <summary>
        /// if the dropdown is visible some keystrokes
        /// should behave in a custom way
        /// </summary>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            m_fromKeyboard = true;
            if (!m_dropDown.Visible || m_list.Items.Count == 0)
            {
                base.OnKeyDown(e);
                return;
            }
            switch (e.KeyCode)
            {
            case Keys.Down:
                if (m_list.SelectedItems.Count == 0)
                {
                    m_list.Items[0].Selected = true;
                    m_list.Items[0].EnsureVisible();
                }
                else if (m_list.SelectedIndices[0] < m_list.Items.Count - 1)
                {
                    m_list.Items[m_list.SelectedIndices[0] + 1].Selected = true;
                    m_list.Items[m_list.SelectedIndices[0]].EnsureVisible();
                }
                else
                {
                    m_list.Items[0].Selected = true;
                    m_list.Items[0].EnsureVisible();
                }
                break;

            case Keys.Up:
                if (m_list.SelectedIndices.Count > 0)
                {
                    m_list.Items[m_list.SelectedIndices[0] - 1].Selected = true;
                    m_list.Items[m_list.SelectedIndices[0]].EnsureVisible();
                }
                else if (m_list.Items.Count > 0)
                {
                    m_list.Items[m_list.Items.Count - 1].Selected = true;
                    m_list.Items[m_list.Items.Count - 1].EnsureVisible();
                }

                break;

            case Keys.Enter:
                if (m_list.SelectedItems.Count > 0)
                {
                    Text = m_list.SelectedItems[0].Text;
                    if (AfterChange != null)
                    {
                        AfterChange.Invoke(this, e);
                    }
                }
                //Select(0, Text.Length);
                hideDropDown();
                break;

            case Keys.Escape:
                hideDropDown();
                break;

            default:
                base.OnKeyDown(e);
                return;
            }
            e.Handled          = true;
            e.SuppressKeyPress = true;
        }