Skip to content

Commit

Permalink
Merge pull request #23 from elig0n/first_ten_numbers_bold
Browse files Browse the repository at this point in the history
Fix where items would not get sorted
  • Loading branch information
elig0n authored May 20, 2020
2 parents 2f3eb15 + c1e7606 commit 31b8abb
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Switcheroo/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,25 @@ private void LoadData(InitialFocus focus)
_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();

}

for (var i = 0; i < 10; 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;
}
Expand All @@ -388,17 +403,6 @@ private void LoadData(InitialFocus focus)
lb.DataContext = _filteredWindowList;
}

for (var i = 0; i < _unfilteredWindowList.Count; i++)
{
if (i < 10)
{
_unfilteredWindowList[i].FormattedTitle = new XamlHighlighter().Highlight(new[] { new StringPart("" + (i + 1) + " ", true) });
}
_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) });
}

FocusItemInList(focus, foregroundWindowMovedToBottom);

if ( tb.IsEnabled ) tb.Clear();
Expand Down

0 comments on commit 31b8abb

Please sign in to comment.