Skip to content

Commit

Permalink
* Fix notification window shows wrong position
Browse files Browse the repository at this point in the history
  • Loading branch information
sontx committed Dec 29, 2020
1 parent 5fc0a86 commit f0b7db6
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions Views/NotificationWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using DropZone.Utils;
using DropZone.ViewModels;
using System;
using System.IO;
using System.Media;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;

namespace DropZone.Views
{
Expand All @@ -19,16 +17,6 @@ public NotificationWindow()
{
InitializeComponent();

Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() =>
{
var workingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
var transform = PresentationSource.FromVisual(this).CompositionTarget.TransformFromDevice;
var corner = transform.Transform(new Point(workingArea.Right, workingArea.Bottom));

this.Left = corner.X - this.ActualWidth;
this.Top = corner.Y - this.ActualHeight;
}));

Loaded += NotificationWindow_Loaded;
MouseLeftButtonDown += NotificationWindow_MouseLeftButtonDown;
}
Expand All @@ -44,6 +32,12 @@ private void NotificationWindow_MouseLeftButtonDown(object sender, MouseButtonEv

private void NotificationWindow_Loaded(object sender, RoutedEventArgs e)
{
var workingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
var transform = PresentationSource.FromVisual(this).CompositionTarget.TransformFromDevice;
var corner = transform.Transform(new Point(workingArea.Right, workingArea.Bottom));

this.Left = corner.X - this.ActualWidth;
this.Top = corner.Y - this.ActualHeight;
Loaded -= NotificationWindow_Loaded;
PlayNotificationSound();
ScheduleClose();
Expand Down

0 comments on commit f0b7db6

Please sign in to comment.