Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/csharp-dotnet-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
runs-on: windows-latest
runs-on: windows-2025-vs2026

steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 6 additions & 6 deletions GUI/WPF/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
<Window.CommandBindings>
<CommandBinding Command="Open" Executed="_openDatabase_MenuItem_Click"/>
<CommandBinding Command="New" Executed="_newUser_MenuItem_Click"/>
<CommandBinding Command="Print" Executed="_generatePassword_MenuItem_Click"/>
</Window.CommandBindings>
<Window.InputBindings>
<KeyBinding Key="O" Modifiers="Control" Command="Open"/>
<KeyBinding Key="N" Modifiers="Control" Command="New"/>
<KeyBinding Key="P" Modifiers="Control" Command="Print"/>
</Window.InputBindings>
<StackPanel>
<Menu>
Expand All @@ -29,15 +31,13 @@
</Menu.ItemsPanel>
<MenuItem Header="_Open database"
Command="Open"
InputGestureText="Ctrl+O"
Click="_openDatabase_MenuItem_Click"/>
InputGestureText="Ctrl+O"/>
<MenuItem Header="_New User"
Command="New"
InputGestureText="Ctrl+N"
Click="_newUser_MenuItem_Click"/>
InputGestureText="Ctrl+N"/>
<MenuItem Header="_Generate random Password"
HorizontalAlignment="Right"
Click="_generatePassword_MenuItem_Click"/>
Command="Print"
HorizontalAlignment="Right"/>
</Menu>
<Grid>
<Grid.RowDefinitions>
Expand Down
4 changes: 2 additions & 2 deletions GUI/WPF/Upsilon.Apps.Passkey.GUI.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<Authors>Yassin Lokhat</Authors>
<Description>A local stored Password Manager GUI.</Description>
<Version>3.0.0</Version>
<AssemblyVersion>1.0.1</AssemblyVersion>
<FileVersion>1.0.1</FileVersion>
<AssemblyVersion>1.0.2</AssemblyVersion>
<FileVersion>1.0.2</FileVersion>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>

Expand Down
37 changes: 36 additions & 1 deletion GUI/WPF/ViewModels/Controls/IdentifiantViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System.Text.RegularExpressions;
using System.Windows.Media;
using Upsilon.Apps.Passkey.GUI.WPF.Themes;
using Upsilon.Apps.Passkey.Interfaces.Models;
Expand All @@ -10,6 +11,15 @@ public class IdentifierViewModel : INotifyPropertyChanged
{
private readonly IAccount _account;

public static readonly Dictionary<string, string> IdentifiersTypes = new()
{
{ "[Username]", "👤" },
{ "[Email]", "📧" },
{ "[Phone Number]", "🖁" },
{ "[Passkey]", "🗝" },
{ "[Authentificator App]", "📲" },
};

public Brush IdentifierBackground => _account.HasChanged("Identifiers") ? DarkMode.ChangedBrush : DarkMode.UnchangedBrush2;

public string Identifier
Expand All @@ -19,7 +29,16 @@ public string Identifier
{
if (field != value)
{
field = value;
if (IdentifiersTypes.Keys.Union(IdentifiersTypes.Values).All(x => !value.StartsWith(x, StringComparison.CurrentCultureIgnoreCase)))
{
value = _getIdentifierType(value);
}

foreach (var idType in IdentifiersTypes)
{
field = value.Replace(idType.Key, idType.Value);
}

OnPropertyChanged(nameof(Identifier));
}
}
Expand All @@ -43,5 +62,21 @@ public void Refresh()
{
OnPropertyChanged(nameof(IdentifierBackground));
}

private static string _getIdentifierType(string identifier)
{
Regex phoneRegex = new(@"^\+\d{1,3}[\d\s\-\.]{6,20}$");
Regex emailRegex = new(@"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$");

if (phoneRegex.IsMatch(identifier))
{
return "🖁" + identifier;
}
if (emailRegex.IsMatch(identifier))
{
return "📧" + identifier;
}
return "👤" + identifier;
}
}
}
15 changes: 14 additions & 1 deletion GUI/WPF/Views/Controls/AccountView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@ public AccountView()

public string? GetIdentifier()
{
return _identifiers_LB.SelectedItem is not IdentifierViewModel identifierViewModel ? null : identifierViewModel.Identifier;
string? identifier = _identifiers_LB.SelectedItem is not IdentifierViewModel identifierViewModel ? null : identifierViewModel.Identifier;

if (identifier is not null)
{
foreach (string idType in IdentifierViewModel.IdentifiersTypes.Values)
{
if (identifier.StartsWith(idType))
{
identifier = identifier[idType.Length..];
}
}
}

return identifier;
}

public string? GetPassword() => _viewModel?.Password;
Expand Down
23 changes: 19 additions & 4 deletions GUI/WPF/Views/InsertIdentifierView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,37 @@
Title="Insert identifier"
ResizeMode="CanMinimize"
WindowStartupLocation="CenterScreen"
Height="200" Width="300">
Height="200" Width="483">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0"
Orientation="Horizontal">
<TextBox Name="_identifier_TB"
Width="230"
Width="415"
Text="{Binding Identifier, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
KeyUp="_identifier_TextBox_KeyUp"/>
<Button Content="✕"/>
<Button Content="✕"
Click="_clearFilter_Button_Click"/>
</StackPanel>
<StackPanel Grid.Row="1"
Orientation="Horizontal">
<Button Content="Username"
Click="_insertIdentifierType_Button_Click"/>
<Button Content="Email"
Click="_insertIdentifierType_Button_Click"/>
<Button Content="Phone Number"
Click="_insertIdentifierType_Button_Click"/>
<Button Content="Passkey"
Click="_insertIdentifierType_Button_Click"/>
<Button Content="Authentificator App"
Click="_insertIdentifierType_Button_Click"/>
</StackPanel>
<ListBox Name="_identifiers_LB"
Grid.Row="1"
Grid.Row="2"
SelectionChanged="_identifiers_LB_SelectionChanged"/>
</Grid>
</Window>
16 changes: 16 additions & 0 deletions GUI/WPF/Views/InsertIdentifierView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Windows.Controls;
using Upsilon.Apps.Passkey.GUI.WPF.Helper;
using Upsilon.Apps.Passkey.GUI.WPF.ViewModels;
using Upsilon.Apps.Passkey.GUI.WPF.ViewModels.Controls;

namespace Upsilon.Apps.Passkey.GUI.WPF.Views
{
Expand Down Expand Up @@ -65,5 +66,20 @@ private void _identifiers_LB_SelectionChanged(object sender, SelectionChangedEve
_selectedIdentifier = _identifiers_LB.SelectedItem as string;
DialogResult = true;
}

private void _insertIdentifierType_Button_Click(object sender, RoutedEventArgs e)
{
string? idType = ((Button)sender).Content as string;

if (idType is not null)
{
_viewModel.Identifier = IdentifierViewModel.IdentifiersTypes[$"[{idType}]"] + _viewModel.Identifier;
}
}

private void _clearFilter_Button_Click(object sender, RoutedEventArgs e)
{
_viewModel.Identifier = string.Empty;
}
}
}
16 changes: 11 additions & 5 deletions GUI/WPF/Views/UserServicesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@
MinWidth="1300">
<Window.CommandBindings>
<CommandBinding Command="Save" Executed="_save_MenuItem_Click"/>
<CommandBinding Command="Print" Executed="_generateRandomPassword_MenuItem_Click"/>
<CommandBinding Command="Find" Executed="_filterCommand_CommandBinding_Executed"/>
<CommandBinding Command="Stop" Executed="_filterClear_Button_Click"/>
</Window.CommandBindings>
<Window.InputBindings>
<KeyBinding Key="S" Modifiers="Control" Command="Save"/>
<KeyBinding Key="P" Modifiers="Control" Command="Print"/>
<KeyBinding Key="F" Modifiers="Control" Command="Find"/>
<KeyBinding Key="F3" Command="Find"/>
<KeyBinding Key="F" Modifiers="Control+Shift" Command="Stop"/>
<KeyBinding Key="F3" Modifiers="Shift" Command="Stop"/>
</Window.InputBindings>
<Grid>
<Grid.RowDefinitions>
Expand All @@ -34,13 +42,11 @@
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem Header="_Save"
Click="_save_MenuItem_Click"
Command="Save"
InputGestureText="Ctrl+S"/>
Command="Save"/>
<MenuItem Header="_User settings"
Click="_userSettings_MenuItem_Click"/>
<MenuItem Header="_Generate random Password"
Click="_generateRandomPassword_MenuItem_Click"/>
Command="Print"/>
<MenuItem Header="_Show activities"
Click="_showActivities_MenuItem_Click"/>
<MenuItem Name="_warnings_MI"
Expand Down Expand Up @@ -97,7 +103,7 @@
IsChecked="{Binding ChangedItemsOnly}"/>
<Button Grid.Column="7"
Content="✕"
Click="_filterClear_Button_Click"/>
Command="Stop"/>
</Grid>
</GroupBox>
</StackPanel>
Expand Down
11 changes: 0 additions & 11 deletions GUI/WPF/Views/UserServicesView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,6 @@ private UserServicesView()

_ = _serviceFilter_TB.Focus();

CommandBinding filterCommand = new(new RoutedCommand()
{
InputGestures =
{
new KeyGesture(Key.F, ModifierKeys.Control),
new KeyGesture(Key.F3),
},
});
filterCommand.Executed += _filterCommand_CommandBinding_Executed;
_ = CommandBindings.Add(filterCommand);

MainViewModel.Database.DatabaseClosed += _database_DatabaseClosed;
MainViewModel.Database.WarningsUpdated += _database_WarningUpdated;
Loaded += _userServicesView_Loaded;
Expand Down
Loading