Beispiel #1
0
        public OpenProjectFileForm(IEnumerable <FileListObject> allObjects)
        {
            _allObjects = allObjects;

            InitializeComponent();
            SelectedListObject = null;
            MouseDown         += (sender, e) =>
            {
                if (e.ChangedButton == MouseButton.Left)
                {
                    this.DragMove();
                }
            };

            txtSearch.Focus();

            txtSearch.TextChanged += (sender, e) => UpdateVisibleObjects();

            UpdateVisibleObjects();
        }
Beispiel #2
0
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
            {
                e.Handled = true;
                Close();
            }

            bool internal_handled = false;

            if (lbItems.Items.Count > 0)
            {
                if (e.Key == Key.Down)
                {
                    if (lbItems.SelectedIndex == -1)
                    {
                        lbItems.SelectedIndex = 0;
                    }
                    else
                    {
                        lbItems.SelectedIndex = (lbItems.SelectedIndex + 1) % lbItems.Items.Count;
                    }
                    internal_handled = true;
                }
                else if (e.Key == Key.Up)
                {
                    if (lbItems.SelectedIndex != -1)
                    {
                        int index = lbItems.SelectedIndex - 1;
                        if (index < 0)
                        {
                            index = lbItems.Items.Count - 1;
                        }
                        lbItems.SelectedIndex = index;
                    }
                    else
                    {
                        lbItems.SelectedIndex = lbItems.Items.Count - 1;
                    }
                    internal_handled = true;
                }
                else if (e.Key == Key.Enter)
                {
                    if (lbItems.SelectedIndex != -1)
                    {
                        SelectedListObject = (FileListObject)lbItems.SelectedItem;

                        e.Handled = true;
                        Close();
                        return;
                    }
                }
            }

            if (internal_handled)
            {
                base.OnPreviewKeyDown(e);
                return;
            }

            lbItems.SelectedIndex = lbItems.Items.Count > 0 ? 0 : -1;

            base.OnPreviewKeyDown(e);
            txtSearch.Focus();
        }