Exemple #1
0
        /// <summary>
        /// Populates the window list with the current running windows.
        /// </summary>
        private void LoadData(InitialFocus focus)
        {
            _unfilteredWindowList = AppWindow.AllAltTabWindows
                                    .Select(window => new AppWindowViewModel(window))
                                    .OrderBy(w => w.WindowTitle)
                                    .ToList();

            var firstWindow = _unfilteredWindowList.FirstOrDefault();

            _filteredWindowList = new ObservableCollection <AppWindowViewModel>(_unfilteredWindowList);
            _windowCloser       = new WindowCloser();

            foreach (var window in _unfilteredWindowList)
            {
                window.FormattedTitle        = new XamlHighlighter().Highlight(new[] { new StringPart(window.AppWindow.Title) });
                window.FormattedProcessTitle =
                    new XamlHighlighter().Highlight(new[] { new StringPart(window.AppWindow.ProcessTitle) });
            }

            lb.DataContext = null;
            lb.DataContext = _filteredWindowList;

            FocusItemInList(focus);

            tb.Clear();
            tb.Focus();
            CenterWindowBelowCursor();
            ScrollSelectedItemIntoView();
        }
        /// <summary>
        /// Populates the window list with the current running windows.
        /// </summary>
        private void LoadData(InitialFocus focus)
        {
            _unfilteredWindowList = new WindowFinder().GetWindows().Select(window => new AppWindowViewModel(window)).ToList();

            var firstWindow = _unfilteredWindowList.FirstOrDefault();

            var foregroundWindowMovedToBottom = false;

            // Move first window to the bottom of the list if it's related to the foreground window
            if (firstWindow != null && AreWindowsRelated(firstWindow.AppWindow, _foregroundWindow))
            {
                _unfilteredWindowList.RemoveAt(0);
                _unfilteredWindowList.Add(firstWindow);
                foregroundWindowMovedToBottom = true;
            }

            _filteredWindowList = new ObservableCollection <AppWindowViewModel>(_unfilteredWindowList);
            _windowCloser       = new WindowCloser();

            for (var i = 0; i < _unfilteredWindowList.Count; i++)
            {
                _unfilteredWindowList[i].FormattedTitle        = new XamlHighlighter().Highlight(new[] { new StringPart(_unfilteredWindowList[i].AppWindow.Title) });
                _unfilteredWindowList[i].FormattedProcessTitle =
                    new XamlHighlighter().Highlight(new[] { new StringPart(_unfilteredWindowList[i].AppWindow.ProcessTitle) });
            }

            if (_sortWinList == true)
            {
                _unfilteredWindowList = _unfilteredWindowList.OrderBy(x => x.FormattedProcessTitle).ToList();
            }

            var _itemsCountToHighlight = Math.Min(_unfilteredWindowList.Count, 10);

            for (var i = 0; i < _itemsCountToHighlight; i++)
            {
                _unfilteredWindowList[i].FormattedTitle = new XamlHighlighter().Highlight(new[] { new StringPart("" + (i + 1) + " ", true) }) + _unfilteredWindowList[i].FormattedTitle;
            }

            if (_sortWinList == true)
            {
                lb.DataContext = null;
                lb.DataContext = _unfilteredWindowList;
            }
            else
            {
                lb.DataContext = _filteredWindowList;
            }

            FocusItemInList(focus, foregroundWindowMovedToBottom);

            if (tb.IsEnabled)
            {
                tb.Clear();
            }
            tb.Focus();
            CenterWindow();
            ScrollSelectedItemIntoView();
        }
        private void HideWindow()
        {
            if (_windowCloser != null)
            {
                _windowCloser.Dispose();
                _windowCloser = null;
            }

            Hide();
        }
Exemple #4
0
        /// <summary>
        /// Populates the window list with the current running windows.
        /// </summary>
        private void LoadData(InitialFocus focus)
        {
            _unfilteredWindowList = new WindowFinder().GetWindows().Select(window => new AppWindowViewModel(window)).ToList();

            // Move all un-activated top-most windows to the bottom of the list
            var topMostWindowList = _unfilteredWindowList.TakeWhile(windowModel =>
                                                                    windowModel.AppWindow.TopMost && windowModel.AppWindow != _foregroundWindow).ToList();

            _unfilteredWindowList = _unfilteredWindowList.Except(topMostWindowList).Concat(topMostWindowList).ToList();

            var firstWindow = _unfilteredWindowList.FirstOrDefault();
            var foregroundWindowMovedToBottom = false;

            // Move first window to the bottom of the list if it's related to the foreground window
            if (firstWindow != null && AreWindowsRelated(firstWindow.AppWindow, _foregroundWindow))
            {
                _unfilteredWindowList.RemoveAt(0);
                _unfilteredWindowList.Add(firstWindow);
                foregroundWindowMovedToBottom = true;
            }

            _filteredWindowList = new ObservableCollection <AppWindowViewModel>(_unfilteredWindowList);
            _windowCloser       = new WindowCloser();

            foreach (var window in _unfilteredWindowList)
            {
                window.FormattedTitle        = new XamlHighlighter().Highlight(new[] { new StringPart(window.AppWindow.Title) });
                window.FormattedProcessTitle =
                    new XamlHighlighter().Highlight(new[] { new StringPart(window.AppWindow.ProcessTitle) });
            }

            if (_sortWinList == true)
            {
                _unfilteredWindowList = _unfilteredWindowList.OrderBy(x => x.FormattedProcessTitle).ToList();
                AddPrefixNumbersToFormattedTitle(_unfilteredWindowList);

                lb.DataContext = null;
                lb.DataContext = _unfilteredWindowList;
            }
            else
            {
                AddPrefixNumbersToFormattedTitle(_filteredWindowList);
                lb.DataContext = _filteredWindowList;
            }

            FocusItemInList(focus, foregroundWindowMovedToBottom);

            if (tb.IsEnabled)
            {
                tb.Clear();
            }
            tb.Focus();
            CenterWindow();
            ScrollSelectedItemIntoView();
        }
Exemple #5
0
        private void HideWindow()
        {
            if (_windowCloser != null)
            {
                _windowCloser.Dispose();
                _windowCloser = null;
            }

            _altTabAutoSwitch = false;
            Opacity           = 0;
            Dispatcher.BeginInvoke(new Action(Hide), DispatcherPriority.Input);
        }
Exemple #6
0
        /// <summary>
        /// Populates the window list with the current running windows.
        /// </summary>
        private void LoadData()
        {
            _unfilteredWindowList = new WindowFinder().GetWindows().Select(window => new AppWindowViewModel(window)).ToList();
            _filteredWindowList   = new ObservableCollection <AppWindowViewModel>(_unfilteredWindowList);
            _windowCloser         = new WindowCloser();

            foreach (var window in _unfilteredWindowList)
            {
                window.FormattedTitle        = new XamlHighlighter().Highlight(new[] { new StringPart(window.AppWindow.Title) });
                window.FormattedProcessTitle = new XamlHighlighter().Highlight(new[] { new StringPart(window.AppWindow.ProcessTitle) });
            }

            lb.DataContext   = null;
            lb.DataContext   = _filteredWindowList;
            lb.SelectedIndex = 0;
            tb.Clear();
            tb.Focus();
            Resize();
        }
Exemple #7
0
        /// <summary>
        /// Populates the window list with the current running windows.
        /// </summary>
        private void LoadData(InitialFocus focus)
        {
            _unfilteredWindowList = new WindowFinder().GetWindows().Select(window => new AppWindowViewModel(window)).ToList();

            var firstWindow = _unfilteredWindowList.FirstOrDefault();

            var foregroundWindowMovedToBottom = false;

            // Move first window to the bottom of the list if it's related to the foreground window
            if (firstWindow != null && AreWindowsRelated(firstWindow.AppWindow, _foregroundWindow))
            {
                _unfilteredWindowList.RemoveAt(0);
                _unfilteredWindowList.Add(firstWindow);
                foregroundWindowMovedToBottom = true;
            }

            _filteredWindowList = new ObservableCollection <AppWindowViewModel>(_unfilteredWindowList.OrderBy(i => i.WindowTitle));
            _windowCloser       = new WindowCloser();

            foreach (var window in _unfilteredWindowList)
            {
                window.FormattedTitle        = new XamlHighlighter().Highlight(new[] { new StringPart(window.WindowTitle) });
                window.FormattedProcessTitle =
                    new XamlHighlighter().Highlight(new[] { new StringPart(window.AppWindow.ProcessTitle) });
            }

            lb.DataContext = null;
            lb.DataContext = _filteredWindowList;

            FocusItemInList(focus, foregroundWindowMovedToBottom);

            tb.Clear();
            tb.Focus();
            CenterWindow();
            ScrollSelectedItemIntoView();
        }
        private void HideWindow()
        {
            if (_windowCloser != null)
            {
                _windowCloser.Dispose();
                _windowCloser = null;
            }

            Hide();           
        }
        /// <summary>
        /// Populates the window list with the current running windows.
        /// </summary>
        private void LoadData(InitialFocus focus)
        {
            _unfilteredWindowList = new WindowFinder().GetWindows().Select(window => new AppWindowViewModel(window)).ToList();

            var firstWindow = _unfilteredWindowList.FirstOrDefault();

            var foregroundWindowMovedToBottom = false;
            
            // Move first window to the bottom of the list if it's related to the foreground window
            if (firstWindow != null && AreWindowsRelated(firstWindow.AppWindow, _foregroundWindow))
            {
                _unfilteredWindowList.RemoveAt(0);
                _unfilteredWindowList.Add(firstWindow);
                foregroundWindowMovedToBottom = true;
            }

            _filteredWindowList = new ObservableCollection<AppWindowViewModel>(_unfilteredWindowList);
            _windowCloser = new WindowCloser();

            foreach (var window in _unfilteredWindowList)
            {
                window.FormattedTitle = new XamlHighlighter().Highlight(new[] {new StringPart(window.AppWindow.Title)});
                window.FormattedProcessTitle =
                    new XamlHighlighter().Highlight(new[] {new StringPart(window.AppWindow.ProcessTitle)});
            }

            lb.DataContext = null;
            lb.DataContext = _filteredWindowList;

            FocusItemInList(focus, foregroundWindowMovedToBottom);

            tb.Clear();
            tb.Focus();
            CenterWindow();
            ScrollSelectedItemIntoView();
        }
        private void HideWindow()
        {
            if (_windowCloser != null)
            {
                _windowCloser.Dispose();
                _windowCloser = null;
            }

            Opacity = 0;

            // Avoid flicker by delaying the "Hide" a bit. This makes sure
            // that "Opacity = 0" is taking effect before the window is hidden.
            var timer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(50)};
            timer.Tick += (sender, args) =>
            {
                Hide();
                timer.Stop();
            };
            timer.Start();
        }