diff --git a/EscribePassword.csproj b/EscribePassword.csproj index 9a73dee..210a385 100644 --- a/EscribePassword.csproj +++ b/EscribePassword.csproj @@ -9,6 +9,17 @@ True + + + + + + + + + + + @@ -18,9 +29,11 @@ - - ..\Libraries\libObsidean\bin\Debug\net8.0-windows\libObsidean.dll - + + + + + diff --git a/EscribePassword.sln b/EscribePassword.sln index f18a733..76df8b1 100644 --- a/EscribePassword.sln +++ b/EscribePassword.sln @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.10.34928.147 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EscribePassword", "EscribePassword.csproj", "{10D3496B-A382-49CD-833F-54C23578CA5C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EscribePassword", "EscribePassword.csproj", "{10D3496B-A382-49CD-833F-54C23578CA5C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "libObsidean", "..\Libraries\libObsidean\libObsidean.csproj", "{C07333F1-D969-48F9-BD66-A012229F4741}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +17,10 @@ Global {10D3496B-A382-49CD-833F-54C23578CA5C}.Debug|Any CPU.Build.0 = Debug|Any CPU {10D3496B-A382-49CD-833F-54C23578CA5C}.Release|Any CPU.ActiveCfg = Release|Any CPU {10D3496B-A382-49CD-833F-54C23578CA5C}.Release|Any CPU.Build.0 = Release|Any CPU + {C07333F1-D969-48F9-BD66-A012229F4741}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C07333F1-D969-48F9-BD66-A012229F4741}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C07333F1-D969-48F9-BD66-A012229F4741}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C07333F1-D969-48F9-BD66-A012229F4741}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/KeyboardHelper.cs b/KeyboardHelper.cs index ec2c4a0..1dce5aa 100644 --- a/KeyboardHelper.cs +++ b/KeyboardHelper.cs @@ -7,64 +7,6 @@ using CommunityToolkit.Mvvm.ComponentModel; namespace EscribePassword { - public partial class Passwords : ObservableObject - { - [ObservableProperty] - private string usuario; - - [ObservableProperty] - private string password; - - [ObservableProperty] - private string categoria; - - public static List ConvertArrayToPasswordsList(string[,] tableArray) - { - var passwordsList = new List(); - - for (int i = 0; i < tableArray.GetLength(0); i++) - { - var passwords = new Passwords(); - - if (tableArray.GetLength(1) >= 1) - passwords.Categoria = tableArray[i, 0]; - if (tableArray.GetLength(1) >= 2) - passwords.Usuario = tableArray[i, 1]; - if (tableArray.GetLength(1) >= 3) - passwords.Password = tableArray[i, 2]; - passwordsList.Add(passwords); - } - - return passwordsList; - } - - public static string[,] ConvertPasswordsListToArray(List passwordsList) - { - if (passwordsList == null || passwordsList.Count == 0) - return new string[0, 0]; - - int rows = passwordsList.Count; - int columns = 3; // Asumimos que siempre hay tres columnas: Usuario, Password, Categoria - - string[,] tableArray = new string[rows + 1, columns]; - - // Fill header - tableArray[0, 0] = "Class"; - tableArray[0, 1] = "User"; - tableArray[0, 2] = "Password"; - - // Fill data - for (int i = 0; i < rows; i++) - { - tableArray[i + 1, 0] = passwordsList[i].Usuario; - tableArray[i + 1, 1] = passwordsList[i].Password; - tableArray[i + 1, 2] = passwordsList[i].Categoria; - } - - return tableArray; - } - } - public class KeyboardHelper { [DllImport("user32.dll", SetLastError = true)] diff --git a/MainWindow.xaml b/MainWindow.xaml index 63169ea..0b99b17 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -12,56 +12,47 @@ - - - - - - - - - - - + + + + + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index b009289..3c0c297 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -15,7 +15,6 @@ using MouseEventArgs = System.Windows.Forms.MouseEventArgs; namespace EscribePassword { - /// /// Interaction logic for MainWindow.xaml /// @@ -154,23 +153,24 @@ namespace EscribePassword } [RelayCommand] - private void Eliminar(Passwords password) + private void Eliminar() { - if (password != null) + if (SelectedPassword != null) { - passwords.Remove(password); + Passwords.Remove(SelectedPassword); SelectedPassword = null; } } [RelayCommand] - private void Utilizar(Passwords password) + private void Utilizar() { - if (password != null) + if (SelectedPassword != null) { - ((App)Application.Current).PasteLogic.RestoreAndSimulatePaste(password); + ((App)Application.Current).PasteLogic.RestoreAndSimulatePaste(SelectedPassword); - // Cerrar la aplicación después de la acción + // Cerrar la aplicación después de la acción + Application.Current.Shutdown(); } } diff --git a/Passwords.cs b/Passwords.cs new file mode 100644 index 0000000..6387a2e --- /dev/null +++ b/Passwords.cs @@ -0,0 +1,62 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace EscribePassword +{ + public partial class Passwords : ObservableObject + { + [ObservableProperty] + private string usuario; + + [ObservableProperty] + private string password; + + [ObservableProperty] + private string categoria; + + public static List ConvertArrayToPasswordsList(string[,] tableArray) + { + var passwordsList = new List(); + + for (int i = 0; i < tableArray.GetLength(0); i++) + { + var passwords = new Passwords(); + + if (tableArray.GetLength(1) >= 1) + passwords.Categoria = tableArray[i, 0]; + if (tableArray.GetLength(1) >= 2) + passwords.Usuario = tableArray[i, 1]; + if (tableArray.GetLength(1) >= 3) + passwords.Password = tableArray[i, 2]; + passwordsList.Add(passwords); + } + + return passwordsList; + } + + public static string[,] ConvertPasswordsListToArray(List passwordsList) + { + if (passwordsList == null || passwordsList.Count == 0) + return new string[0, 0]; + + int rows = passwordsList.Count; + int columns = 3; // Asumimos que siempre hay tres columnas: Usuario, Password, Categoria + + string[,] tableArray = new string[rows + 1, columns]; + + // Fill header + tableArray[0, 0] = "Class"; + tableArray[0, 1] = "User"; + tableArray[0, 2] = "Password"; + + // Fill data + for (int i = 0; i < rows; i++) + { + tableArray[i + 1, 0] = passwordsList[i].Usuario; + tableArray[i + 1, 1] = passwordsList[i].Password; + tableArray[i + 1, 2] = passwordsList[i].Categoria; + } + + return tableArray; + } + } +}