Exemple #1
0
        private static IDisposable ShowPinWindow(IntPtr hWnd, PinOperations operation)
        {
            var vmodel = new NotificationWindowViewModel
            {
                Title = ProductInfo.Title,
                Body  = $"{(operation.HasFlag(PinOperations.Window) ? "Window" : "Application")} {(operation.HasFlag(PinOperations.Pin) ? "Pinned" : "Unpinned")}",
            };
            var source = new CancellationTokenSource();
            var window = new PinWindow(hWnd)
            {
                DataContext = vmodel,
            };

            window.Show();

            Task.Delay(TimeSpan.FromMilliseconds(Settings.General.NotificationDuration), source.Token)
            .ContinueWith(_ => window.Close(), TaskScheduler.FromCurrentSynchronizationContext());

            return(Disposable.Create(() => source.Cancel()));
        }