Пример #1
0
 protected override async Task InitializationAsync()
 {
     for (int i = 1; i < 5; i++)
     {
         BitmapImage image = new BitmapImage();
         using (var imageStream = await ResourceUtility.GetApplicationResourceStreamAsync($"Assets/new_user_guide_{i}.jpg"))
         {
             image.SetSource(imageStream);
         }
         GuideImages.Add(image);
     }
 }
Пример #2
0
        /// <summary>
        /// 获取Splash图片
        /// </summary>
        /// <returns></returns>
        private async Task <IRandomAccessStream> GetSplashImageAsync()
        {
            try
            {
                var  lastCacheSplashFileName = Global.AppConfig.LastCacheSplashFileName; //缓存的Splash文件名称
                bool isSplashExpired         = false;                                    //Splash是否已过期

                if (Global.AppConfig.CacheSplashExpire.HasValue)
                {
                    if (Global.AppConfig.CacheSplashExpire < DateTime.Now)
                    {
                        isSplashExpired = true;
                        Global.AppConfig.CacheSplashExpire = null;  //清空过期时间
                        Global.SaveAppConfig();
                    }
                }

                IRandomAccessStream splashStream = null;
                if (isSplashExpired || string.IsNullOrWhiteSpace(lastCacheSplashFileName) || !(await LocalCacheUtility.ExistsCacheFile(lastCacheSplashFileName))) //没有缓存Splash,或者缓存已过期,或者缓存图片获取失败
                {
                    await LocalCacheUtility.DeleteCacheFile(lastCacheSplashFileName);

                    splashStream = await ResourceUtility.GetApplicationResourceStreamAsync("Assets/new_splash_content.png");
                }
                else
                {
                    splashStream = await LocalCacheUtility.GetCacheAsync(lastCacheSplashFileName);
                }

                return(splashStream);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                return(null);
            }
        }