public void RecordButtonClicked() { if (ClearNotificationOnClick) { ShowNotificationImage = false; NotificationText = String.Empty; // fire notification events BlogProviderButtonNotificationSink.FireNotificationEvent(BlogId, Id); } }
public void CheckForNotification() { try { if ((DateTimeHelper.UtcNow >= NotificationPollingTime) && WinInet.InternetConnectionAvailable) { // poll for notification IBlogProviderButtonNotification buttonNotification = null; using (new BlogClientUIContextSilentMode()) buttonNotification = GetButtonNotification(); // update notification text under control of the apply updates lock (the lock along // with the check for a valid blog-id immediately below ensures that we a background // notification never creates a "crufty" blog-id by writing to a BlogSettings key // that has already been deleted). using (BlogSettings.ApplyUpdatesLock(BlogId)) { if (BlogSettings.BlogIdIsValid(BlogId)) { NotificationText = buttonNotification.NotificationText; // update notification image ShowNotificationImage = SafeUpdateNotificationImage(buttonNotification.NotificationImage); // update clear notification flag ClearNotificationOnClick = buttonNotification.ClearNotificationOnClick; // set next polling time UpdateNotificationPollingTime(buttonNotification.PollingInterval); } else { throw new InvalidOperationException("Attempted update notification data for invalid blog-id"); } } // fire notification events BlogProviderButtonNotificationSink.FireNotificationEvent(BlogId, Id); } } catch (Exception ex) { Trace.WriteLine("Error occurred polling for button notification: " + ex.ToString()); } }
public void Initialize(Control synchronizeInvokeControl, BlogPostEditingManager editingManager) { // initialize notification sink _notificationSink = new BlogProviderButtonNotificationSink(synchronizeInvokeControl); _notificationSink.BlogProviderButtonNotificationReceived += new BlogProviderButtonNotificationReceivedHandler(_notificationSink_BlogProviderButtonNotificationReceived); _notificationSink.CheckForNotifications(); // save a reference to the editing manager and subscribe to change notifications _editingManager = editingManager; _editingManager.BlogChanged += new EventHandler(_editingManager_BlogChanged); _editingManager.BlogSettingsChanged += new WeblogSettingsChangedHandler(_editingManager_BlogSettingsChanged); // connect to the current weblog if (editingManager.BlogId != String.Empty) { ConnectToBlog(editingManager.BlogId); } }