added option to sort keys alphabetically

This commit is contained in:
WeeXnes 2023-06-09 16:04:27 +02:00
parent 89d3bd8409
commit 79933338c9
8 changed files with 53 additions and 3 deletions

View file

@ -84,6 +84,11 @@ namespace WeeXnes
SaveSettingsHandler.Data.KeyManager.Section, SaveSettingsHandler.Data.KeyManager.Section,
SaveSettingsHandler.Data.KeyManager.CopyOnSelect)); SaveSettingsHandler.Data.KeyManager.CopyOnSelect));
KeyManagerView.Data.sortList.Value =
Convert.ToBoolean(SettingsView.Data.settingsFile.GetValue(
SaveSettingsHandler.Data.KeyManager.Section,
SaveSettingsHandler.Data.KeyManager.SortList));
//Load paths //Load paths
string customRpcPath = SettingsView.Data.settingsFile.GetValue( string customRpcPath = SettingsView.Data.settingsFile.GetValue(

View file

@ -8,7 +8,7 @@ namespace WeeXnes.Core
{ {
public class Information public class Information
{ {
public const string Version = "4.4.1"; public const string Version = "4.4.2";
public const string EncryptionHash = "8zf5#RdyQ]$4x4_"; public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest"; public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
} }

View file

@ -24,6 +24,7 @@ namespace WeeXnes.Core
public const string Section = "KEY_MANAGER"; public const string Section = "KEY_MANAGER";
public const string CensorKeys = "CensorKeys"; public const string CensorKeys = "CensorKeys";
public const string CopyOnSelect = "CopyOnSelect"; public const string CopyOnSelect = "CopyOnSelect";
public const string SortList = "SortList";
} }
public static class DiscordRpcFiles public static class DiscordRpcFiles
{ {
@ -58,6 +59,18 @@ namespace WeeXnes.Core
KeyManagerView.Data.copyOnSelect.Value.ToString() KeyManagerView.Data.copyOnSelect.Value.ToString()
); );
}; };
KeyManagerView.Data.sortList.ValueChanged += () =>
{
SettingsView.Data.settingsFile.SetValue(
Data.KeyManager.Section,
Data.KeyManager.SortList,
KeyManagerView.Data.sortList.Value.ToString()
);
};
Global.AppDataPathRPC.ValueChanged += () => Global.AppDataPathRPC.ValueChanged += () =>
{ {
SettingsView.Data.settingsFile.SetValue( SettingsView.Data.settingsFile.SetValue(

View file

@ -17,7 +17,9 @@
Background="Transparent" Background="Transparent"
Foreground="White" Foreground="White"
BorderThickness="0" BorderThickness="0"
SelectionChanged="ListviewKeys_OnSelectionChanged"> SelectionChanged="ListviewKeys_OnSelectionChanged"
IsTextSearchEnabled="True"
>
<ListView.ContextMenu> <ListView.ContextMenu>
<ContextMenu> <ContextMenu>
<MenuItem Header="Export" <MenuItem Header="Export"

View file

@ -2,6 +2,7 @@
using System.Collections.Specialized; using System.Collections.Specialized;
using System.ComponentModel; using System.ComponentModel;
using System.IO; using System.IO;
using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using WeeXnes.Core; using WeeXnes.Core;
@ -15,6 +16,7 @@ namespace WeeXnes.Views.KeyManager
public static BindingList<KeyItem> KeyItemsList = new BindingList<KeyItem>(); public static BindingList<KeyItem> KeyItemsList = new BindingList<KeyItem>();
public static UpdateVar<bool> censorKeys = new UpdateVar<bool>(); public static UpdateVar<bool> censorKeys = new UpdateVar<bool>();
public static UpdateVar<bool> copyOnSelect = new UpdateVar<bool>(); public static UpdateVar<bool> copyOnSelect = new UpdateVar<bool>();
public static UpdateVar<bool> sortList = new UpdateVar<bool>();
} }
public KeyManagerView() public KeyManagerView()
{ {
@ -24,6 +26,9 @@ namespace WeeXnes.Views.KeyManager
} }
private void KeyManagerView_OnLoaded(object sender, RoutedEventArgs e) private void KeyManagerView_OnLoaded(object sender, RoutedEventArgs e)
{ {
if(Data.sortList.Value)
resortList();
ListviewKeys.Items.Refresh(); ListviewKeys.Items.Refresh();
} }
@ -52,6 +57,16 @@ namespace WeeXnes.Views.KeyManager
} }
ClearInputs(); ClearInputs();
if(Data.sortList.Value)
resortList();
}
private void resortList()
{
BindingList<KeyItem> newList = new BindingList<KeyItem>(Data.KeyItemsList.OrderBy(x => x.Name).ToList());
Data.KeyItemsList = newList;
ListviewKeys.ItemsSource = Data.KeyItemsList;
} }
private void ClearInputs() private void ClearInputs()

View file

@ -61,6 +61,10 @@
Name="CheckboxCopyOnSelect" Name="CheckboxCopyOnSelect"
Checked="CheckboxCopyOnSelect_OnChecked" Checked="CheckboxCopyOnSelect_OnChecked"
Unchecked="CheckboxCopyOnSelect_OnUnchecked"/> Unchecked="CheckboxCopyOnSelect_OnUnchecked"/>
<CheckBox Content="Sort Keys alphabetically"
Name="CheckboxSortKeys"
Checked="CheckboxSortKeys_OnChecked"
Unchecked="CheckboxSortKeys_OnUnchecked"/>
<TextBlock Text="Discord RPC" <TextBlock Text="Discord RPC"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Foreground="White"/> Foreground="White"/>

View file

@ -29,6 +29,7 @@ namespace WeeXnes.Views.Settings
{ {
CheckboxCensorKeys.IsChecked = KeyManagerView.Data.censorKeys.Value; CheckboxCensorKeys.IsChecked = KeyManagerView.Data.censorKeys.Value;
CheckboxCopyOnSelect.IsChecked = KeyManagerView.Data.copyOnSelect.Value; CheckboxCopyOnSelect.IsChecked = KeyManagerView.Data.copyOnSelect.Value;
CheckboxSortKeys.IsChecked = KeyManagerView.Data.sortList.Value;
} }
private void CheckboxCensorKeys_OnChecked(object sender, RoutedEventArgs e) private void CheckboxCensorKeys_OnChecked(object sender, RoutedEventArgs e)
{ {
@ -120,5 +121,15 @@ namespace WeeXnes.Views.Settings
{ {
KeyManagerView.Data.copyOnSelect.Value = false; KeyManagerView.Data.copyOnSelect.Value = false;
} }
private void CheckboxSortKeys_OnChecked(object sender, RoutedEventArgs e)
{
KeyManagerView.Data.sortList.Value = true;
}
private void CheckboxSortKeys_OnUnchecked(object sender, RoutedEventArgs e)
{
KeyManagerView.Data.sortList.Value = false;
}
} }
} }

View file

@ -4,7 +4,7 @@
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Version>4.4.1</Version> <Version>4.4.2</Version>
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid> <ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>WeeXnes</RootNamespace> <RootNamespace>WeeXnes</RootNamespace>