台式电脑

怎么样退出电脑动态壁纸(Windows 增加开关桌面动态壁纸)

接着上一篇

Windows 增加开关桌面动态壁纸

1)基于原有功能ConfigHelper增加代码如下:

publicstaticboolOpenWallpaper{get;set;}

boolopenWallpaper;

if(!bool.TryParse(string.IsOrWhiteSpace(ConfigurationManager.AppSettings["OpenWallpaper"])?"false":ConfigurationManager.AppSettings["OpenWallpaper"],outopenWallpaper))

OpenWallpaper=false;

else

OpenWallpaper=Convert.ToBoolean(string.IsOrWhiteSpace(ConfigurationManager.AppSettings["OpenWallpaper"])?"false":ConfigurationManager.AppSettings["OpenWallpaper"]);

publicstaticvoidSaveOpenWallpaper(boolopenWallpaper)

{

OpenWallpaper=openWallpaper;

SaveConfig("OpenWallpaper",openWallpaper.ToString());

}

2)基于原有功能WallpaperItem增加代码如下:

//publicstringItemName{get;set;}

privatestring_itemName;

publicstringItemName

{

get=>_itemName;

set

{

_itemName=value;

NotifyPropertyChange("ItemName");

}

}

3)基于原有功能app.config增加配置代码如下:

4)基于原有功能MainVM.cs增加代码如下:

voidWallpaersFilePlay()

{

WallpaperArray=;

#regionWallpaper

varwallpaersPath=Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"Video");

if(Directory.Exists(wallpaersPath))

{

varnames=newList();

怎么样退出电脑动态壁纸(Windows 增加开关桌面动态壁纸)

varfiles=Directory.GetFiles(wallpaersPath);

foreach(varfilePathinfiles)

{

varfileName=Path.GetFileNameWithoutExtension(filePath);

names.Add(newWallpaperItem{ItemName=fileName,VideoPath=filePath,IsSelected=ConfigHelper.WallpaperPath==filePath?true:false});

}

if(names.Count>0)

names.Add(newWallpaperItem{ItemName=ConfigHelper.OpenWallpaper==true?"壁纸已开启":"壁纸已关闭",VideoPath=_exitWallpaper,IsSelected=ConfigHelper.OpenWallpaper});

names.Add(newWallpaperItem{ItemName="更多壁纸请加QQ群:929469013"});

WallpaperArray=names;

if(WallpaperArray.Count>0)

ShowWallpaper(ConfigHelper.WallpaperPath);

}

#endregion

}

voidShowWallpaper(stringwallpaperPath)

{

if(string.IsOrWhiteSpace(wallpaperPath))

{

if(WallpaperArray.Count>=3&&ConfigHelper.OpenWallpaper)

{

WallpaperArray.First().IsSelected=true;

wallpaperPath=WallpaperArray[0].VideoPath;

}

}

if(!File.Exists(wallpaperPath)||!ConfigHelper.OpenWallpaper)return;

StopFFplayProcess();

WallpaperArray.Where(x=>x.VideoPath!=wallpaperPath&&x.VideoPath!=_exitWallpaper).ToList().ForEach(x=>

{

x.IsSelected=false;

});

if(ConfigHelper.OpenWallpaper)

{

varwallpaper=WallpaperArray.FirstOrDefault(x=>x.VideoPath==_exitWallpaper);

if(wallpaper!=)

{

wallpaper.ItemName="壁纸已开启";

wallpaper.IsSelected=true;

}

}

StartFFplayProcess(wallpaperPath);

if(ffplayWindowHandle!=IntPtr.Zero)

{

SendMsgToProgman();

Win32Api.SetParent(ffplayWindowHandle,desktopHandle);

if(ConfigHelper.WallpaperPath!=wallpaperPath)

ConfigHelper.SaveWallpaperPath(wallpaperPath);

}

}

publicICommandWallpaperSelectedCommand=>newRelayCommand(obj=>

{

if(objisWallpaperItemwallpaper)

{

if(wallpaper.VideoPath==_exitWallpaper)

{

if(!wallpaper.IsSelected)

{

StopFFplayProcess();

wallpaper.ItemName="壁纸已关闭";

wallpaper.IsSelected=false;

}

else

{

WallpaersFilePlay();

wallpaper.ItemName="壁纸已开启";

wallpaper.IsSelected=true;

}

}

else

{

if(string.IsOrWhiteSpace(wallpaper.VideoPath))return;

if(File.Exists(wallpaper.VideoPath))

{

ShowWallpaper(wallpaper.VideoPath);

}

}

}

});

参考资料

<

相关新闻

返回顶部