diff --git a/EscribePassword.csproj b/EscribePassword.csproj index 210a385..5a5374a 100644 --- a/EscribePassword.csproj +++ b/EscribePassword.csproj @@ -26,6 +26,7 @@ + diff --git a/MainWindow.xaml b/MainWindow.xaml index 9889ee4..c08fc93 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -2,8 +2,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:local="clr-namespace:EscribePassword" mc:Ignorable="d" Title="MainWindow" Height="450" Width="300" - AllowsTransparency="True" WindowStyle="None" MouseDown="Window_MouseDown" Topmost="True"> + xmlns:local="clr-namespace:EscribePassword" mc:Ignorable="d" Title="MainWindow" + AllowsTransparency="True" WindowStyle="None" MouseDown="Window_MouseDown" Topmost="True" Width="400" Height="500"> @@ -12,14 +12,16 @@ - - - - - - - + + + + + + + + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 3c0c297..c97e90f 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -1,16 +1,15 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using System.Collections.ObjectModel; -using System.Text.Json; -using System.IO; using System.Windows; using Application = System.Windows.Application; using System.Windows.Input; using MouseButton = System.Windows.Input.MouseButton; using Gma.System.MouseKeyHook; using MouseEventArgs = System.Windows.Forms.MouseEventArgs; - - +using System.Diagnostics; +using System.Windows.Controls; +using Clipboard = System.Windows.Clipboard; namespace EscribePassword { @@ -30,6 +29,40 @@ namespace EscribePassword HookManager(); } + private void DataGrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e) + { + if (sender is DataGrid dataGrid && dataGrid.CurrentCell.Item is Passwords selectedPassword) + { + var cellContent = (dataGrid.CurrentCell.Column.GetCellContent(selectedPassword) as TextBlock)?.Text; + if (!string.IsNullOrEmpty(cellContent)) + { + Clipboard.SetText(cellContent); + + // Mostrar notificación de que el valor fue copiado + ShowNotification("Valor copiado al portapapeles."); + } + } + } + + private void ShowNotification(string message) + { + NotifyIcon notifyIcon = new NotifyIcon(); + notifyIcon.Visible = true; + notifyIcon.Icon = SystemIcons.Information; + notifyIcon.BalloonTipTitle = "Notificación"; + notifyIcon.BalloonTipText = message; + notifyIcon.ShowBalloonTip(2000); + + // Ocultar el icono después de 2 segundos + var timer = new System.Timers.Timer(2000); + timer.Elapsed += (s, e) => + { + notifyIcon.Dispose(); + timer.Dispose(); + }; + timer.Start(); + } + private void MainWindow_Loaded(object sender, RoutedEventArgs e) { ((App)Application.Current).SetInitialWindowPosition(); @@ -107,19 +140,25 @@ namespace EscribePassword [ObservableProperty] private Passwords selectedPassword; + Stopwatch timeSteps = new Stopwatch(); + public void OnWheel(object sender, MouseWheelEventArgs e) { if (Passwords.Count == 0) return; - - var index = Passwords.IndexOf(SelectedPassword); - var max = Passwords.Count; - if (e.Delta > 0) - index++; - else index--; - if (index < 0) index = max-1; - if (index >= max) index = 0; - SelectedPassword = Passwords[index]; + if (timeSteps.ElapsedMilliseconds > 200) + { + var index = Passwords.IndexOf(SelectedPassword); + var max = Passwords.Count; + if (e.Delta < 0) + index++; + else if (e.Delta > 0) index--; + if (index < 0) index = max - 1; + if (index >= max) index = 0; + + SelectedPassword = Passwords[index]; + timeSteps.Restart(); + } } partial void OnSelectedPasswordChanged(Passwords value) @@ -136,6 +175,8 @@ namespace EscribePassword top_passwords = new ObservableCollection(); passwords = new ObservableCollection(EstadoPersistente.Instance.Passwords); SelectedPassword = passwords.FirstOrDefault(); + + timeSteps.Start(); } private void OnApplicationExit(object sender, ExitEventArgs e)