private static extern int GetWindowRect(IntPtr hwnd, out NotificationView.RECT rc);
public static void Notify(List<MetroTwitStatusBase> newTweets, string notificationName, bool showtoasts, bool playsound) { bool runningFullScreen = false; IntPtr foregroundWindow = NotificationView.GetForegroundWindow(); if (!foregroundWindow.Equals((object) IntPtr.Zero)) { IntPtr num1 = NotificationView.desktopHandle; IntPtr num2 = NotificationView.shellHandle; IntPtr handle = (PresentationSource.FromVisual((Visual) System.Windows.Application.Current.MainWindow) as HwndSource).Handle; if (!foregroundWindow.Equals((object) NotificationView.desktopHandle) && !foregroundWindow.Equals((object) NotificationView.shellHandle) && !foregroundWindow.Equals((object) handle)) { NotificationView.RECT rc; NotificationView.GetWindowRect(foregroundWindow, out rc); Rectangle bounds = Screen.FromHandle(foregroundWindow).Bounds; runningFullScreen = rc.Bottom - rc.Top == bounds.Height && rc.Right - rc.Left == bounds.Width; } else runningFullScreen = false; } if (NotificationView.notificationwindow == null && NotificationView.w == null && !NotificationView.ThreadStarting) { NotificationView.ThreadStarting = true; Thread thread = new Thread((ThreadStart) (() => { NotificationView.w = new Window(); NotificationView.w.Top = -100.0; NotificationView.w.Left = -100.0; NotificationView.w.Width = 1.0; NotificationView.w.Height = 1.0; NotificationView.w.WindowStyle = WindowStyle.ToolWindow; NotificationView.w.Show(); NotificationView.notificationwindow = new NotificationView(); NotificationView.notificationwindow.Owner = NotificationView.w; NotificationView.w.Hide(); NotificationView.w.Closed += (EventHandler) ((sender2, e2) => NotificationView.w.Dispatcher.InvokeShutdown()); NotificationView.ThreadStarting = false; Dispatcher.Run(); })); thread.SetApartmentState(ApartmentState.STA); thread.Name = "NotificationUIThread"; thread.Start(); } if (NotificationView.w == null || NotificationView.w.Dispatcher == null) return; NotificationView.w.Dispatcher.BeginInvoke((Action) (() => { if (NotificationView.notificationwindow == null) return; if (!NotificationView.notificationwindow.IsShowing && !runningFullScreen) { NotificationView.notificationwindow.IsShowing = true; NotificationView.notificationwindow.Show(); } NotificationView.notificationwindow.AddNotification(newTweets, notificationName, showtoasts, playsound); }), DispatcherPriority.ContextIdle, new object[0]); }