public void CloseWallpaper(params uint[] screenIndexs) { foreach (var index in screenIndexs) { if (CurrentWalpapers.ContainsKey(index)) { CurrentWalpapers.Remove(index); } } InnerCloseWallpaper(screenIndexs); }
public void Resum(params uint[] screenIndexs) { foreach (var index in screenIndexs) { if (CurrentWalpapers.ContainsKey(index)) { var wallpaper = CurrentWalpapers[index]; var currentRender = RenderFactory.GetOrCreateRender(wallpaper.Type); currentRender.Resum(screenIndexs); } } }
private void ApplyAudioSource() { //设置音源 for (uint screenIndex = 0; screenIndex < Screen.AllScreens.Length; screenIndex++) { if (CurrentWalpapers.ContainsKey(screenIndex)) { var wallpaper = CurrentWalpapers[screenIndex]; var currentRender = RenderFactory.GetOrCreateRender(wallpaper.Type); currentRender.SetVolume(screenIndex == Options.AudioScreenIndex ? 100 : 0, screenIndex); } } }
private void MaximizedMonitor_AppMaximized(object sender, AppMaximizedEvent e) { var maximizedScreenIndexs = e.MaximizedScreens.Select((m, i) => (uint)i).ToList(); bool anyScreenMaximized = maximizedScreenIndexs.Count > 0; foreach (var item in Options.ScreenOptions) { uint currentScreenIndex = (uint)item.ScreenIndex; bool currentScreenMaximized = maximizedScreenIndexs.Contains(currentScreenIndex) || Options.AppMaximizedEffectAllScreen && anyScreenMaximized; switch (item.WhenAppMaximized) { case ActionWhenMaximized.Pause: if (currentScreenMaximized) { Pause(currentScreenIndex); } else { Resum(currentScreenIndex); } break; case ActionWhenMaximized.Stop: if (currentScreenMaximized) { InnerCloseWallpaper(currentScreenIndex); } else if (CurrentWalpapers.ContainsKey(currentScreenIndex)) { _ = ShowWallpaper(CurrentWalpapers[currentScreenIndex], currentScreenIndex); } break; case ActionWhenMaximized.Play: break; } } }
public 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(); }