예제 #1
0
 internal static IRender GetRender(WallpaperModel wallpaper)
 {
     if (wallpaper.Type != null)
     {
         return(GetRender(wallpaper.Type.Value));
     }
     else if (!string.IsNullOrEmpty(wallpaper.Path))
     {
         return(GetRenderByExtension(Path.GetExtension(wallpaper.Path)));
     }
     return(null);
 }
예제 #2
0
        public static async Task ShowWallpaper(WallpaperModel wallpaper, params uint[] screenIndexs)
        {
            if (wallpaper.Type == WallpaperType.NotSupport)
            {
                wallpaper.Type = RenderFactory.ResoveType(wallpaper.Path);
            }

            if (wallpaper.Type == WallpaperType.NotSupport)
            {
                return;
            }

            foreach (var index in screenIndexs)
            {
                //类型不一致关闭上次显示的壁纸
                if (CurrentWalpapers.ContainsKey(index) && wallpaper.Type != CurrentWalpapers[index].Type)
                {
                    CloseWallpaper(screenIndexs);
                }
            }

            var currentRender = RenderFactory.GetOrCreateRender(wallpaper.Type);
            await currentRender.ShowWallpaper(wallpaper, screenIndexs);

            foreach (var index in screenIndexs)
            {
                if (!CurrentWalpapers.ContainsKey(index))
                {
                    CurrentWalpapers.Add(index, wallpaper);
                }
                else
                {
                    CurrentWalpapers[index] = wallpaper;
                }
            }

            ApplyAudioSource();
        }