void timer_Tick(object sender, object e)
 {
     try
     {
         //Get time for this tick
         int hour   = System.DateTime.Now.Hour;
         int minute = System.DateTime.Now.Minute;
         int second = System.DateTime.Now.Second;
         //Ensure that the hex value has 6 digits by padding with zeroes.
         //TODO: do this more efficiently
         StringBuilder sb = new StringBuilder("#");
         if (hour < 10)
         {
             sb.Append("0" + hour.ToString());
         }
         else
         {
             sb.Append(hour.ToString());
         }
         if (minute < 10)
         {
             sb.Append("0" + minute.ToString());
         }
         else
         {
             sb.Append(minute.ToString());
         }
         if (second < 10)
         {
             sb.Append("0" + second.ToString());
         }
         else
         {
             sb.Append(second.ToString());
         }
         string hexTime = sb.ToString();
         sb.Remove(0, 1);                            //remove # character for displayed time
         for (int i = sb.Length - 2; i > 0; i -= 2)  //22:41:10 formatting
         {
             sb.Insert(i, ":");
         }
         string currentTime = sb.ToString();
         //Update lblClock
         //clocktime.Text = currentTime;
         //Update background color according to time value
         HexColour       color   = new HexColour(hexTime);
         SolidColorBrush bgBrush = new SolidColorBrush(Color.FromArgb(color.A, color.R, color.G, color.B));
         LayoutRoot.Background = bgBrush;
     }
     catch { }
 }
 void timer_Tick(object sender, object e)
 {
     try
     {
         //Get time for this tick
         int hour = System.DateTime.Now.Hour;
         int minute = System.DateTime.Now.Minute;
         int second = System.DateTime.Now.Second;
         //Ensure that the hex value has 6 digits by padding with zeroes.
         //TODO: do this more efficiently
         StringBuilder sb = new StringBuilder("#");
         if (hour < 10)
         {
             sb.Append("0" + hour.ToString());
         }
         else
         {
             sb.Append(hour.ToString());
         }
         if (minute < 10)
         {
             sb.Append("0" + minute.ToString());
         }
         else
         {
             sb.Append(minute.ToString());
         }
         if (second < 10)
         {
             sb.Append("0" + second.ToString());
         }
         else
         {
             sb.Append(second.ToString());
         }
         string hexTime = sb.ToString();
         sb.Remove(0, 1);                            //remove # character for displayed time
         for (int i = sb.Length - 2; i > 0; i -= 2)     //22:41:10 formatting
             sb.Insert(i, ":");
         string currentTime = sb.ToString();
         //Update lblClock
         //clocktime.Text = currentTime;
         //Update background color according to time value
         HexColour color = new HexColour(hexTime);
         SolidColorBrush bgBrush = new SolidColorBrush(Color.FromArgb(color.A, color.R, color.G, color.B));
         LayoutRoot.Background = bgBrush;
     }
     catch { }
 }