private void checkWallpaperTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (!WallpaperChecker.Instance().IsChecking) { checkWallpaper(); } }
public static WallpaperChecker Instance() { if (instance == null) { instance = new WallpaperChecker(); } return instance; }
public static WallpaperChecker Instance() { if (instance == null) { instance = new WallpaperChecker(); } return(instance); }
public void DownloadAndApplyWallpaper(DateTime date, WallpaperChecker.WallpaperFormats format) { MotivateDesktopNotifyIcon.Instance().ShowBalloonTip("正在下载", "正在下载壁纸,完成后将自动设置为桌面壁纸."); isDownloading = true; string wallpaperUrl = getWallpaperUrl(date,format); if (wallpaperUrl != null) { downloadAndApply(wallpaperUrl); } }
private void checkWallpaper() { System.Threading.Thread checkWallpaperThread = new System.Threading.Thread(new System.Threading.ThreadStart( delegate { WallpaperChecker.Instance().BeginCheckWallpaper(); } )); checkWallpaperThread.Start(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { this.Hide(); MotivateDesktopNotifyIcon.Instance(); WallpaperChecker.Instance().GotWallpaperPreview += new WallpaperChecker.GotWallpaperPreviewEventHandler(GotWallpaperPreview); WallpaperChecker.Instance().FailedGettingWallpaperPreview += new WallpaperChecker.FailedGettingWallpaperPreviewEventHandler(FailedGettingWallpaperPreview); checkWallpaper(); System.Timers.Timer checkWallpaperTimer = new System.Timers.Timer(15 * 60 * 1000); checkWallpaperTimer.Elapsed += new System.Timers.ElapsedEventHandler(checkWallpaperTimer_Elapsed); checkWallpaperTimer.Start(); setAutoexitTimerEnabled(MotivateDesktop.Properties.Settings.Default.AutoExit); }
void latestWallpaperMenuItem_Click(object sender, EventArgs e) { BackgroundWindow.ShouldForceShowWallpaperPreviewWindow = true; ShowBalloonTip("正在检测壁纸", "稍后会有提示..."); if (!WallpaperChecker.Instance().IsChecking) { System.Threading.Thread checkWallpaperThread = new System.Threading.Thread(new System.Threading.ThreadStart( delegate { WallpaperChecker.Instance().BeginCheckWallpaper(); } )); checkWallpaperThread.Start(); } }
private void setWallpaper_MouseDown(object sender, MouseEventArgs e) { WallpaperDownloader wallpaperDownloader = WallpaperDownloader.Instance(); if (wallpaperDownloader.IsDownloading) { MotivateDesktopNotifyIcon.Instance().ShowBalloonTip("正在下载", "有一张壁纸正在下载,请等待下载完成..."); } else { System.Threading.Thread wallpaperDownloadThread = new System.Threading.Thread(new System.Threading.ThreadStart( delegate { wallpaperDownloader.DownloadAndApplyWallpaper(WallpaperChecker.Instance().WallpaperDate, WallpaperChecker.Instance().WallpaperFormat); } )); wallpaperDownloadThread.Start(); } AnimatedCloseMainWrapper(); }
private string getWallpaperUrl(DateTime date, WallpaperChecker.WallpaperFormats format) { string screenRatioString = ""; switch (MotivateDesktopUtility.MainScreenRatio) { case MotivateDesktopUtility.ScreenRatio.SixteenByTen: screenRatioString = "1920x1200"; break; case MotivateDesktopUtility.ScreenRatio.SixteenByNine: screenRatioString = "1920x1080"; break; case MotivateDesktopUtility.ScreenRatio.FourByThree: screenRatioString = "1600x1200"; break; default: screenRatioString = null; downloadAndApplyWallpaperFailed(); return null; } if (format == WallpaperChecker.WallpaperFormats.MISSING) { downloadAndApplyWallpaperFailed(); return null; } string formatString = (format == WallpaperChecker.WallpaperFormats.JPG) ? ".jpg" : ".png"; string dateString = date.ToString("yyyy.M.d"); string monthString = date.ToString("yyyy.M"); string wallpaperUrl = MotivateDesktopUtility.ImgServerUrl + monthString + "/" + dateString + "_" + screenRatioString + formatString; return wallpaperUrl; }