TileBindingContentIconic.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // ******************************************************************
  2. // Copyright (c) Microsoft. All rights reserved.
  3. // This code is licensed under the MIT License (MIT).
  4. // THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  5. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  7. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  8. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  9. // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
  10. // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
  11. // ******************************************************************
  12. using System;
  13. namespace Microsoft.Toolkit.Uwp.Notifications
  14. {
  15. /// <summary>
  16. /// Supported on Small and Medium. Enables an iconic Tile template, where you can have an icon and badge display next to each other on the Tile, in true classic Windows Phone style. The number next to the icon is achieved through a separate badge notification.
  17. /// </summary>
  18. public sealed class TileBindingContentIconic : ITileBindingContent
  19. {
  20. /// <summary>
  21. /// At minimum, to support both Desktop and Phone, Small and Medium tiles, provide a square aspect ratio image with a resolution of 200x200, PNG format, with transparency and no color other than white. For more info see: http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/07/31/iconic-tile-template-for-windows-10.aspx
  22. /// </summary>
  23. public TileBasicImage Icon { get; set; }
  24. internal TileTemplateNameV3 GetTemplateName(TileSize size)
  25. {
  26. switch (size)
  27. {
  28. case TileSize.Small:
  29. return TileTemplateNameV3.TileSquare71x71IconWithBadge;
  30. case TileSize.Medium:
  31. return TileTemplateNameV3.TileSquare150x150IconWithBadge;
  32. default:
  33. throw new ArgumentException("The Iconic template is only supported on Small and Medium tiles.");
  34. }
  35. }
  36. internal void PopulateElement(Element_TileBinding binding, TileSize size)
  37. {
  38. if (Icon != null)
  39. {
  40. var element = Icon.ConvertToElement();
  41. element.Id = 1;
  42. binding.Children.Add(element);
  43. }
  44. }
  45. }
  46. }