void parser_NotifyIconUpdated(object sender, GoogleDocsNotifier.Events.NotifyIconUpdatedEventArgs e) { if (e.NumOfUnviewedDocuments > 0) { System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); //The original icon for the Google Docs Notifier. System.Drawing.Image originalAppIcon = System.Drawing.Icon.ExtractAssociatedIcon( System.Windows.Forms.Application.ExecutablePath).ToBitmap(); //Create a bitmap and draw the number of unviewed documents on it. System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(16, 16); System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap); graphics.DrawImage(originalAppIcon, 0, 0, 16, 16); graphics.DrawString(e.NumOfUnviewedDocuments.ToString(), new System.Drawing.Font("Helvetica", 6), brush, 3, 3); graphics.Save(); //Convert the bitmap with text to an Icon. IntPtr hIcon = bitmap.GetHicon(); System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(hIcon); trayNotifyIcon.Icon = icon; //Dispose the graphics. graphics.Dispose(); trayNotifyIcon.Text = e.NumOfUnviewedDocuments.ToString() + " unread documents"; } else { trayNotifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath); trayNotifyIcon.Text = "No unread document"; } //Show the balloon tooltip. if (e.IsDisplayTooltip) { //Title of the balloon tooltip. trayNotifyIcon.BalloonTipTitle = e.Title; trayNotifyIcon.BalloonTipText = e.Message; trayNotifyIcon.ShowBalloonTip(500); } }
void parser_ProgressChanged(object sender, GoogleDocsNotifier.Events.ProgressChangedEventArgs e) { this.Dispatcher.Invoke((Action)delegate { gb_progressbar.Visibility = Visibility.Visible; pb_downloadingProgress.Value = e.ProgressValue; lb_messageLabel.Content = "Connecting to Google Docs server..."; }); }