void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.SopranePopup = ((Messenger.Dialogs.NotifyMessageWindow)(target)); return; case 2: #line 29 "..\..\..\Dialogs\NotifyMessageWindow.xaml" ((System.Windows.Media.Animation.DoubleAnimation)(target)).Completed += new System.EventHandler(this.StoryboardCompleted); #line default #line hidden return; case 3: this.Header = ((System.Windows.Controls.TextBlock)(target)); return; } this._contentLoaded = true; }
private Task StartService(CancellationToken cancellationToken) { var dispatcher = Application.Current.Dispatcher; return Task.Run(() => { do { // Gets the next display location in the screen int nextLocation = FindNextLocation(); if (nextLocation <= -1) continue; NotifyMessage msg; // Retrieve the message from the queue if (!QueuedMessages.TryDequeue(out msg)) continue; // construct a View Model and binds it to the Popup Window var viewModel = new NotifyMessageViewModel(msg, DisplayLocations[nextLocation], () => DisplayMessages[nextLocation] = null); // Free the display location when the popup window is closed DisplayMessages[nextLocation] = viewModel; // Use Application.Current.MainWindow.Dispatcher to switch back to the UI Thread to create popup window dispatcher.BeginInvoke(new MethodInvoker(() => { try { var window = new NotifyMessageWindow { //Owner = Application.Current.MainWindow, Topmost = true, DataContext = viewModel, ShowInTaskbar = false }; window.Show(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }), DispatcherPriority.Background); } while (QueuedMessages.Count > 0 && !cancellationToken.IsCancellationRequested); Stop(); }); }