Cambiado los Botones por ToolBarTray y agregada a la solucion libObsidean como dependencia para que se compile automaticamente
This commit is contained in:
parent
59b5300356
commit
509c0f21d7
|
@ -9,6 +9,17 @@
|
|||
<UseWindowsForms>True</UseWindowsForms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="C:\Trabajo\Graphics\Icons\close.png" Link="Icons\close.png" />
|
||||
<Resource Include="C:\Trabajo\Graphics\Icons\delete.png" Link="Icons\delete.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="C:\Trabajo\Graphics\Icons\add-button.png" Link="Icons\add-button.png" />
|
||||
<Resource Include="C:\Trabajo\Graphics\Icons\remove.png" Link="Icons\remove.png" />
|
||||
<Resource Include="C:\Trabajo\Graphics\Icons\use.png" Link="Icons\use.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.6.0" />
|
||||
|
@ -18,9 +29,11 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="libObsidean">
|
||||
<HintPath>..\Libraries\libObsidean\bin\Debug\net8.0-windows\libObsidean.dll</HintPath>
|
||||
</Reference>
|
||||
<Folder Include="Icons\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Libraries\libObsidean\libObsidean.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<Passwords> ConvertArrayToPasswordsList(string[,] tableArray)
|
||||
{
|
||||
var passwordsList = new List<Passwords>();
|
||||
|
||||
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<Passwords> 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)]
|
||||
|
|
|
@ -12,56 +12,47 @@
|
|||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Orientation="Vertical" Margin="10,10,10,10">
|
||||
<DataGrid ItemsSource="{Binding Top_passwords}" AutoGenerateColumns="False" CanUserAddRows="False"
|
||||
CanUserDeleteRows="False" SelectionMode="Single">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Binding="{Binding Categoria}" Width="Auto" />
|
||||
<DataGridTextColumn Binding="{Binding Usuario}" Width="*" />
|
||||
<DataGridTextColumn Binding="{Binding Password}" Width="*" />
|
||||
<DataGridTemplateColumn Header="Acciones" Width="Auto">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Content="Utilizar"
|
||||
Command="{Binding DataContext.UtilizarCommand, RelativeSource={RelativeSource AncestorType=DataGrid}}"
|
||||
CommandParameter="{Binding}" Margin="5,0,0,0" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<DataGrid ItemsSource="{Binding Passwords}" SelectedItem="{Binding SelectedPassword}"
|
||||
<DataGrid Grid.Row="0" ItemsSource="{Binding Passwords}" SelectedItem="{Binding SelectedPassword}"
|
||||
AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" SelectionMode="Single">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Categoria" Binding="{Binding Categoria}" Width="Auto" />
|
||||
<DataGridTextColumn Header="Usuario" Binding="{Binding Usuario}" Width="*" />
|
||||
<DataGridTextColumn Header="Contraseña" Binding="{Binding Password}" Width="*" />
|
||||
<DataGridTemplateColumn Header="Acciones" Width="Auto">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Content="Eliminar"
|
||||
Command="{Binding DataContext.EliminarCommand, RelativeSource={RelativeSource AncestorType=DataGrid}}"
|
||||
CommandParameter="{Binding}" />
|
||||
<Button Content="Utilizar"
|
||||
Command="{Binding DataContext.UtilizarCommand, RelativeSource={RelativeSource AncestorType=DataGrid}}"
|
||||
CommandParameter="{Binding}" Margin="5,0,0,0" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="1,1,1,1">
|
||||
<Button Content="Agregar" Command="{Binding AgregarCommand}" Margin="15" />
|
||||
<Button Content="Cerrar" Command="{Binding CerrarCommand}" Margin="15" />
|
||||
<StackPanel Orientation="Horizontal" Margin="1,1,1,1" HorizontalAlignment="Center">
|
||||
<ToolBarTray>
|
||||
<ToolBar>
|
||||
<Button Command="{Binding AgregarCommand}" ToolTip="Agregar">
|
||||
<StackPanel>
|
||||
<Image Source="Icons/add-button.png" Width="24" Height="24" />
|
||||
<TextBlock Text="Agregar" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Command="{Binding UtilizarCommand}" ToolTip="Use">
|
||||
<StackPanel>
|
||||
<Image Source="Icons/use.png" Width="24" Height="24" />
|
||||
<TextBlock Text="Utilizar" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Command="{Binding EliminarCommand}" ToolTip="Delete">
|
||||
<StackPanel>
|
||||
<Image Source="Icons/delete.png" Width="24" Height="24" />
|
||||
<TextBlock Text="Eliminar" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Command="{Binding CerrarCommand}" ToolTip="Close">
|
||||
<StackPanel>
|
||||
<Image Source="Icons/close.png" Width="24" Height="24" />
|
||||
<TextBlock Text="Cerrar" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</ToolBar>
|
||||
</ToolBarTray>
|
||||
</StackPanel>
|
||||
<Label Content="mav - 2024 - v0.1" Opacity="0.3" HorizontalAlignment="Right" />
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
@ -15,7 +15,6 @@ using MouseEventArgs = System.Windows.Forms.MouseEventArgs;
|
|||
namespace EscribePassword
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
|
@ -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
|
||||
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Passwords> ConvertArrayToPasswordsList(string[,] tableArray)
|
||||
{
|
||||
var passwordsList = new List<Passwords>();
|
||||
|
||||
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<Passwords> 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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue