Wide Live Tiles (and Cleanup)

After checking in the previous version, I realised that it might be nice to support wide Live Tiles as well (tile templates are here). It seems that you can wrap your square tile into a wide tile and send one notification each time. Also, our logo images didn’t look very good so I’m turning them completely transparent for now. Here’s the update for MainPage:

private void timer_Tick(object sender, object e)
{
  cellMap.NextGeneration();
  viewModel.Generation += 1;

  UpdateLiveTilesIfRequired();
}

private void UpdateLiveTilesIfRequired()
{
  if (viewModel.Generation % 50 == 0)
  {
    string line1 = string.Format("Generation: {0}", viewModel.Generation);
    string line2 = string.Format("% Alive: {0}", cellMap.PercentageOfAliveCells);

    var tileContentWide = TileContentFactory.CreateTileWideText05();
    tileContentWide.TextBody1.Text = line1;
    tileContentWide.TextBody2.Text = line2;

    var tileContentSquare =  TileContentFactory.CreateTileSquareText03();
    tileContentSquare.TextBody1.Text = line1;
    tileContentSquare.TextBody2.Text = line2;
    tileContentWide.SquareContent = tileContentSquare;

    var tileNotification = tileContentWide.CreateNotification();
 TileUpdateManager.CreateTileUpdaterForApplication()
.Update(tileNotification);
    }
}

Finally, when the app suspends or quits, we should make it apparent that we're no longer running. In App.xaml.cs add the following to OnSuspending:

TileUpdateManager.CreateTileUpdaterForApplication().Clear();

(Code so far)

comments powered by Disqus