public NotificationItem(AppDisplayInfo displayInfo, string title, string text, DateTime time) { this.InitializeComponent(); //var appLogo = new BitmapImage(); //var appLogoStream = displayInfo.GetLogo(new Size(44, 44)); //var thread = new Thread(async () => //{ // try // { // await appLogo.SetSourceAsync(await appLogoStream.OpenReadAsync()); // await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => // { // Image_Icon.Source = appLogo; // }); // } // catch { } //}); //thread.Start(); TextBlock_AppName.Text = title; TextBlock_NotificationContent.Text = text; if (time.Date == DateTime.Today) { TextBlock_Time.Text = time.ToShortTimeString(); } else { TextBlock_Time.Text = time.ToLongTimeString(); } }
public static async Task <BitmapImage> ConvertToImageAsync(AppDisplayInfo appDisplayInfo) { try { using (var ras = await appDisplayInfo.GetLogo(new Size(DefaultAppLogoSize, DefaultAppLogoSize)).OpenReadAsync()) { var bitmapImage = new BitmapImage(); await bitmapImage.SetSourceAsync(ras); return(bitmapImage); } } catch { var fallbackLogo = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Square44x44Logo.png")); using (var ras = await fallbackLogo.OpenReadAsync()) { var bitmapImage = new BitmapImage(); await bitmapImage.SetSourceAsync(ras); return(bitmapImage); } } }
} // AppDisplayInfoにはないが AppxManifest.xmlから取得 internal AppDisplayInfoEx(AppDisplayInfo displayInfo) { Description = displayInfo.Description; DisplayName = displayInfo.DisplayName; }