Skip to content

Commit

Permalink
results sorting
Browse files Browse the repository at this point in the history
- Added sorting of results by price when you press F5
- "Checked combinations" now show number with spaces (made it easier to see)
  • Loading branch information
Prevter committed Aug 13, 2022
1 parent a0debfd commit 9cf0f47
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
12 changes: 12 additions & 0 deletions FloatTool/Common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Net.Http;
Expand Down Expand Up @@ -167,6 +168,17 @@ public static string EscapeLocalization(string input)

return input;
}

public static void Sort<T>(this ObservableCollection<T> collection, Comparison<T> comparison)
{
var sortableList = new List<T>(collection);
sortableList.Sort(comparison);

for (int i = 0; i < sortableList.Count; i++)
{
collection.Move(collection.IndexOf(sortableList[i]), i);
}
}
}

public class UpdateResult
Expand Down
2 changes: 1 addition & 1 deletion FloatTool/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public int ThreadCount

public string CombinationsLabel
{
get { return $"{ParsedCombinations}/{TotalCombinations}"; }
get { return $"{ParsedCombinations:n0}/{TotalCombinations}"; }
set { OnPropertyChanged(); }
}

Expand Down
7 changes: 5 additions & 2 deletions FloatTool/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public partial class MainWindow : Window
public MainViewModel ViewModel;
public Settings Settings;
private RPCSettingsPersist RPCSettings = new();

private static long PassedCombinations;
private static List<Task> ThreadPool;
private static CancellationTokenSource TokenSource = new();
public CancellationToken CancellationToken;
private static SoundPlayer CombinationFoundSound;

public void UpdateRichPresence(bool clear=false)
public void UpdateRichPresence(bool clear = false)
{
if (clear)
{
Expand Down Expand Up @@ -137,6 +137,9 @@ private void Window_KeyUp(object sender, KeyEventArgs e)
var link = $"https://steamcommunity.com/market/listings/730/{ViewModel.FullSkinName}";
Process.Start(new ProcessStartInfo { FileName = link, UseShellExecute = true });
break;
case Key.F5:
ViewModel.FoundCombinations.Sort((a, b) => a.Price.CompareTo(b.Price));
break;
case Key.F12:
// TODO: Create a dev tools window
break;
Expand Down

0 comments on commit 9cf0f47

Please sign in to comment.