Agregado boton the cerrar a la ventana de notificacion.

This commit is contained in:
Miguel 2024-07-15 14:08:37 +02:00
parent 0a14530315
commit d58f5c496a
2 changed files with 18 additions and 23 deletions

View File

@ -1,14 +1,13 @@
<Window x:Class="GTPCorrgir.notificacion" <Window x:Class="GTPCorrgir.notificacion" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="100" Width="300" Topmost="True"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ShowInTaskbar="False" WindowStyle="None" AllowsTransparency="True" Background="Transparent">
Height="100" Width="300"
Topmost="True" ShowInTaskbar="False"
WindowStyle="None" AllowsTransparency="True"
Background="Transparent">
<Border CornerRadius="10" Background="#AAF0F0F0"> <Border CornerRadius="10" Background="#AAF0F0F0">
<StackPanel> <StackPanel>
<TextBlock x:Name="TitleText" FontSize="16" FontWeight="Bold" Margin="10"/> <TextBlock x:Name="TitleText" FontSize="16" FontWeight="Bold" Margin="10" />
<TextBlock x:Name="MessageText" FontSize="14" Margin="10"/> <TextBlock x:Name="MessageText" FontSize="14" Margin="10" />
<Button Content="Cerrar" Width="75" Height="20" Margin="0" Click="CloseButton_Click"
HorizontalAlignment="Right" />
</StackPanel> </StackPanel>
</Border> </Border>
</Window> </Window>

View File

@ -1,16 +1,5 @@
using System; using System.Windows;
using System.Collections.Generic; using Application = System.Windows.Application;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace GTPCorrgir namespace GTPCorrgir
{ {
@ -24,22 +13,29 @@ namespace GTPCorrgir
InitializeComponent(); InitializeComponent();
PositionWindow(); PositionWindow();
} }
private void PositionWindow() private void PositionWindow()
{ {
// Obtener la posición del cursor // Obtener la posición del cursor
var cursorPosition = System.Windows.Forms.Cursor.Position; var cursorPosition = System.Windows.Forms.Cursor.Position;
// Determinar en qué pantalla está el cursor // Determinar en qué pantalla está el cursor
var screen = Screen.FromPoint(cursorPosition); var screen = System.Windows.Forms.Screen.FromPoint(cursorPosition);
// Configurar la ubicación de la ventana para que aparezca en la esquina inferior derecha // Configurar la ubicación de la ventana para que aparezca en la esquina inferior derecha
this.Left = screen.WorkingArea.Right - this.Width; this.Left = screen.WorkingArea.Right - this.Width;
this.Top = screen.WorkingArea.Bottom - this.Height; this.Top = screen.WorkingArea.Bottom - this.Height;
} }
public void UpdateNotification(string title, string message) public void UpdateNotification(string title, string message)
{ {
TitleText.Text = title; TitleText.Text = title;
MessageText.Text = message; MessageText.Text = message;
} }
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
} }
} }