public NotificationControl(NotificationWindow tmpwindow, String tmpFriendName, String tmpContent, String tmpFriendPic, bool tmpIsVerify) { InitializeComponent(); this.window = tmpwindow; tbFriendName.Text = tmpFriendName; if (tmpIsVerify) { imgVerify.Visibility = Visibility.Visible; } else { imgVerify.Visibility = Visibility.Collapsed; } if (tmpContent.Length < 105) { tbMessageText.Text = tmpContent; } else { tbMessageText.Text = tmpContent.Substring(0, 105) + " ..."; } imgFriendPic.Source = new BitmapImage(new Uri(tmpFriendPic, UriKind.Absolute)); _timer.Duration = TimeSpan.FromMilliseconds(ConfigurationSettings.NotificationTimer/1000); _timer.Completed += new EventHandler(Timer_Tick); _timer.Begin(); }
public void notify(Notification notification) { filterNotification(notification); var notificationViewModel = new NotificationViewModel(notification); var notificationWindow = new NotificationWindow(notificationViewModel); var screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth; var screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight; var nHeight = notificationWindow.Height; var nWidth = notificationWindow.Width; var notificationSpot = -1; for (int i = 0; i < _maxNumNotifications; ++i) { if (_availableNotificationSpots[i]) { notificationSpot = i; break; } } if(notificationSpot == -1) { for (int i = 0; i < _maxNumNotifications; ++i) { _availableNotificationSpots[i] = true; } notificationSpot = 0; } notificationWindow.Left = screenWidth - nWidth - _rightOffset; notificationWindow.Top = _topOffset + notificationSpot * 90; notificationWindow.Opacity = 0; notificationWindow.Show(); _availableNotificationSpots[notificationSpot] = false; var showAnimation = new DoubleAnimation(0, 1, (Duration)_fadeInDuration); showAnimation.Completed += (s1, e1) => { var waitAnimation = new DoubleAnimation(1, _displayDuration); waitAnimation.Completed += (s2, e2) => { var hideAnimation = new DoubleAnimation(0, (Duration)_fadeOutDuration); hideAnimation.Completed += (s3, e3) => { notificationWindow.Hide(); notificationWindow.Close(); _availableNotificationSpots[notificationSpot] = true; }; notificationWindow.BeginAnimation(UIElement.OpacityProperty, hideAnimation); }; notificationWindow.BeginAnimation(UIElement.OpacityProperty, waitAnimation); }; notificationWindow.BeginAnimation(UIElement.OpacityProperty, showAnimation); }
private void AddNotificationToQueue(NotificationWindow notification) { if (toastWindow == null) { toastWindow = notification; notification.Show((int)ConfigurationSettings.NotificationTimer); } else { _notifyQueue.Enqueue(notification); } }
private void Notify(string message) { if (App.Current.IsRunningOutOfBrowser) { var toast = new NotificationWindow { Width = 400, Height = 100 }; var nc = new NotificationControl { NotificationText = { Text = message } }; toast.Content = nc; toast.Show(3000); } else { MessageBox.Show(message); } }
internal void ProcessMessages() { MessagingFactory factory = MessagingFactory.Create( ServiceBusEnvironment.CreateServiceUri("sb", Properties.Settings.Default.SBNamespace, String.Empty), TokenProvider.CreateSharedSecretTokenProvider("wpfsample", Properties.Settings.Default.SBListenerCredentials)); SubscriptionClient urgentMessageClient = factory.CreateSubscriptionClient("thetopic", "urgentmessages"); while (isProcessing) { BrokeredMessage message = urgentMessageClient.Receive(new TimeSpan(0, 0, 2)); if (message != null) { Dispatcher.Invoke((System.Action)(() => { try { var w = new NotificationWindow( message.Properties["Sender"].ToString(), message.GetBody<String>(), message.Properties["BackColor"].ToString(), message.Properties["ForeColor"].ToString() ); WindowRegistry.Add(w); w.Show(); } catch (Exception ex) { btnServiceControl.Content = "Start Responding"; this.Background = new SolidColorBrush(Colors.Orange); this.isProcessing = false; MessageBox.Show(ex.Message, "Processing halted", MessageBoxButton.OK, MessageBoxImage.Stop); } } )); message.Complete(); } } }
/// <summary> /// Shows a toast notification for the specified model. /// </summary> /// <param name="rootModel">The root model.</param> /// <param name="durationInMilliseconds">How long the notification should appear for.</param> /// <param name="context">The context.</param> public virtual void ShowNotification(object rootModel, int durationInMilliseconds, object context = null) { var window = new NotificationWindow(); var view = ViewLocator.LocateForModel(rootModel, window, context); ViewModelBinder.Bind(rootModel, view, null); window.Content = (FrameworkElement)view; var activator = rootModel as IActivate; if (activator != null) activator.Activate(); var deactivator = rootModel as IDeactivate; if(deactivator != null) window.Closed += delegate { deactivator.Deactivate(true); }; window.Show(durationInMilliseconds); }
private void ShowWindow(ITweetItem tweet) { if (_window == null) { _window = new NotificationWindow { Width = 400, Height = 100, Content = new NotificationControl() }; } if (_appInfo.IsNotificationsEnabled) { _window.Content.DataContext = tweet; _window.Close(); _window.Show(5000); } }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { if (IsInDesignMode) { // Code runs in Blend --> create design time data. } else { _notWindow = new NotificationWindow(); var popControl = new PopupControl { DataContext = this }; _notWindow.Content = popControl; // Code runs "for real" initTime = DateTime.Now; mainTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(timerSleep) }; mainTimer.Tick += new EventHandler(timer_Tick); mainTimer.Start(); wc = new WebClient(); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); wc.DownloadStringAsync(vocaUrl); } }
public virtual void ShowNotification(object rootModel, int durationInMilliseconds, object context = null, IDictionary<string, object> settings = null) { EventHandler handler = null; NotificationWindow window = new NotificationWindow(); UIElement element = ViewLocator.LocateForModel(rootModel, window, context); ViewModelBinder.Bind(rootModel, element, null); window.Content = (FrameworkElement) element; this.ApplySettings(window, settings); IActivate activate = rootModel as IActivate; if (activate != null) { activate.Activate(); } IDeactivate deactivator = rootModel as IDeactivate; if (deactivator != null) { if (handler == null) { handler = (, ) => deactivator.Deactivate(true); } window.Closed += handler; } window.Show(durationInMilliseconds); }
private void btNotify_Click(object sender, RoutedEventArgs e) { if (Application.Current.IsRunningOutOfBrowser) { NotificationWindow notify = new NotificationWindow(); notify.Height = 100; notify.Width = 200; StackPanel sp = new StackPanel(); TextBlock text = new TextBlock(); text.Text = "Hello"; sp.Children.Add(text); Button btClose = new Button(); btClose.Content = "chiudi"; btClose.Click += delegate(object s, RoutedEventArgs ev) { notify.Close(); }; sp.Children.Add(btClose); notify.Content = sp; notify.Show(5000); } }
/// <summary> /// /// </summary> public void InitializeNotificationSystem() { notificationWindow = new NotificationWindow(); NotificationsChanged(); notificationWindow.VM.Notifications.CollectionChanged += (s, e) => { NotificationsChanged(); }; notificationWindow.VM.Check += new NotificationEventHandler(CheckRefulfillments); notificationWindow.VM.Check += new NotificationEventHandler(CheckReAcknowledgement); notificationWindow.VM.Check += new NotificationEventHandler(CheckDuplicatedCbr); notificationWindow.VM.Check += new NotificationEventHandler(CheckKeysExpired); notificationWindow.VM.Check += new NotificationEventHandler(CheckKeyTypeConfigurations); RegisterSystemCheck(configProxy.GetIsAutoDiagnostic()); }
void OnNotificationClosed(object sender, EventArgs e) { toastWindow = null; if (_notifyQueue.Count > 0) { NotificationWindow notifyWindow = _notifyQueue.Dequeue(); toastWindow = notifyWindow; notifyWindow.Show((int)ConfigurationSettings.NotificationTimer); } }
private void client_GetFriendTimeLineCompleted(object sender, GetFriendTimelineCompletedEventArgs e) { if (IsFirstLoad) { IsFirstLoad = false; Globals.FriendTimeline = e.Result; LayoutRoot.DataContext = Globals.FriendTimeline; } else { int count = 0; if (Globals.FriendTimeline.Count > 0) { string FirstID = Globals.FriendTimeline[0].FriendTwitterID; foreach (FriendTimelineList newitem in e.Result) { if (FirstID != newitem.FriendTwitterID) { count++; } else break; } for (int i = 0; i < count; i++) { Globals.FriendTimeline.Insert(i, e.Result[i]); //if (toastWindow != null && toastWindow.Visibility == Visibility.Visible) // toastWindow.Close(); if (ConfigurationSettings.NotificationDisable) { NotificationWindow nw = new NotificationWindow(); nw.Width = 400; nw.Height = 100; nw.Closed += new EventHandler(OnNotificationClosed); nw.Content = new NotificationControl(nw, e.Result[i].UsersItem.TwitterName, e.Result[i].FriendTwitterContent, e.Result[i].UsersItem.CustomizeImageURL, e.Result[i].UsersItem.IsVerified); AddNotificationToQueue(nw); } //toastWindow = new NotificationWindow(); //toastWindow.Width = 400; //toastWindow.Height = 100; //toastWindow.Closed += new EventHandler(OnNotificationClosed); //toastWindow.Content = new NotificationControl(toastWindow, // e.Result[i].UsersItem.TwitterName, // e.Result[i].FriendTwitterContent, // e.Result[i].UsersItem.CustomizeImageURL); ////toastWindow.Show((int)ConfigurationSettings.NotificationTimer); //AddNotificationToQueue(toastWindow); } LayoutRoot.DataContext = Globals.FriendTimeline; } } }
public static void Send(string title, string description, Action action) { NotificationWindow window = new NotificationWindow(title, description, action); Display(window); }
private void btnNotify_Click(object sender , RoutedEventArgs s) { var nw = new NotificationWindow(); nw.Content = new MainPage(); nw.Show(5000); }
void NotificationClosed(object sender, System.EventArgs e) { lock (SyncLock) { _currentWindow = null; if (NotifyQueue.Count > 0) { _currentWindow = NotifyQueue.Dequeue(); _currentWindow.Show(TimeoutMs); } } }
public static void Send(string title, Action action) { NotificationWindow window = new NotificationWindow(title, string.Empty, action); Display(window); }
public override void Execute() { if (Application.Current.IsRunningOutOfBrowser) { var toast = new ToastControl { Title = {Text = Title + _counter++}, //Message = {Text = Message}, Height = 100, MaxHeight = 100, Width = 400, MaxWidth = 400 }; var notification = new NotificationWindow { Height = 100, Width = 400 }; var text = new TextBlock(); text.Text = "La la la" + _counter; notification.Content = toast; notification.Closed += NotificationClosed; lock (SyncLock) { if (_currentWindow == null) { _currentWindow = notification; _currentWindow.Show(TimeoutMs); } else { NotifyQueue.Enqueue(notification); } } } }
private static void Display(NotificationWindow window) { window.Show(); System.Media.SystemSounds.Hand.Play(); }
internal static void Add(NotificationWindow w) { Windows.Add(w); }