Add Icon to notification area in Windows tray

September 30, 2011

During a recent conversation with a client they mentioned they wanted a Windows Forms Application to pull information from their SharePoint site. We discussed the requirements and I said yes that fine we can do that. They then said they would like the application to run in the background and to have an Icon in the Notification area, see screenshot below, which pops up telling them some new content has been added to SharePoint.

NotificationArea

My immediate reaction was it must be relatively easy but it was not something I had tried before. When I got back to the office I created a test application and I was surprised by how easy this was. I have included below some same code which hides the application when it is started, adds an item to the notification area and displays a popup every 10 seconds. If this popup is click it will open the application or if the icon in the notification area is click it will also open the application.

Hopefully you find this useful and can use this as a starting point for further developments. As always this code should always be tested before being deployed to any live environments and is used at your own risk.

Code Snippet
  1. public partial class Form1 : Form
  2.     {
  3.         NotifyIcon notify;
  4.         Timer timer;
  5.         public Form1()
  6.         {
  7.             InitializeComponent();
  8.             timer = new Timer();
  9.             timer.Interval = 10000;
  10.                 timer.Start();
  11.             timer.Tick +=new EventHandler(timer_Tick);
  12.  
  13.             notify = new NotifyIcon();
  14.             notify.Icon =
  15.    new System.Drawing.Icon(System.Environment.GetFolderPath
  16.    (System.Environment.SpecialFolder.Personal)
  17.    + @"\logo.ico");
  18.             notify.Visible = true;
  19.             notify.Text = "Test notification area icon";
  20.  
  21.             this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
  22.             this.Visible = false;
  23.             this.ShowInTaskbar = false;
  24.         }
  25.  
  26.         public void  timer_Tick(object sender, EventArgs e)
  27.         {
  28.             notify.Click += new EventHandler(notify_Click);
  29.             notify.ShowBalloonTip(3000, "Test notification area header", "Test notification area test", ToolTipIcon.Info);
  30.             notify.BalloonTipClicked += new EventHandler(notify_BalloonTipClicked);
  31.         }
  32.  
  33.         void notify_Click(object sender, EventArgs e)
  34.         {
  35.             this.WindowState = System.Windows.Forms.FormWindowState.Normal;
  36.             this.Visible = true;
  37.         }
  38.  
  39.         void notify_BalloonTipClicked(object sender, EventArgs e)
  40.         {
  41.             this.WindowState = System.Windows.Forms.FormWindowState.Normal;
  42.             this.Visible = true;
  43.         }
  44.     }


No list or site templates available in Silverlight create form

September 7, 2011

After a recent upgrade from SharePoint 2007 to SharePoint Server 2010 the client noticed when a new site was created it used the default SharePoint 2010 look and feel. This wasn’t an issue until they tried to create a list in this site when they found the Silverlight popup box was displayed but the available list templates was empty and instead the in progress icon was displayed.

I spent a considerable amount of time looking for any additional details in the event viewer and the ULS logs but there was no details on why this was happening. I suddenly remember I had a similar issue with setting the theme in a new SharePoint site after the upgrade. The error in that situation was the theme gallery hadn’t been properly created so I check and there was no solution gallery at the root of the site.

I then used the same solution as with the theme gallery error. I when to the root of the site and went to create a new list. In the create screen I then changed the URL and removed the feature section of the URL and changed the template ID, see below.

URL to create a custom list
http://sitename/_layouts/new.aspx?FeatureId={00bfea71-de22-43b2-a848-c05709900100}&ListTemplate=100

URL to create a solution gallery list
http://sitename/_layouts/new.aspx?ListTemplate=121

I set the name to be solutions and click create. This created a new solutions gallery under the catalogs section of the site. When I went back to my new SharePoint 2010 site and tried to create an new list I was presented with the available list templates.


%d bloggers like this: