Exemplo n.º 1
0
        private static IDisposable ShowWindow(NotificationWindowViewModel vm)
        {
            var source = new CancellationTokenSource();
            var window = new NotificationWindow
            {
                DataContext = vm,
            };
            window.Show();

            Task.Delay(TimeSpan.FromSeconds(2.5), source.Token)
                .ContinueWith(_ => window.Close(), TaskScheduler.FromCurrentSynchronizationContext());

            return Disposable.Create(() => source.Cancel());
        }
        private static IDisposable ShowWindow(int index)
        {
            var vmodel = new NotificationWindowViewModel
            {
                Title = ProductInfo.Title,
                Header = "Virtual Desktop Switched",
                Body = "Current Desktop: Desktop " + index,
            };
            var source = new CancellationTokenSource();
            var window = new NotificationWindow
            {
                DataContext = vmodel,
            };
            window.Show();

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

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