public MainForm(BingImageProvider provider, Settings settings) { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } _provider = provider; if (settings == null) { throw new ArgumentNullException(nameof(settings)); } _settings = settings; // LaunchOnStartup SetStartup(_settings.LaunchOnStartup); AddTrayIcons(); // 定时更新 var timer = new System.Timers.Timer(); timer.Interval = 1000 * 60 * 60 * 24; // 24 hours timer.AutoReset = true; timer.Enabled = true; timer.Elapsed += (s, e) => GetLatestWallpaper(); timer.Start(); // Create Auto Change Task if (_settings.AutoChange) { CreateAutoChangeTask(); } this.ReloadState(); new Thread(() => { // Get the latest wallpaper GetLatestWallpaper(); }).Start(); // open Desk Widget _deskWidget = new DeskWidget(this); if (_settings.ShowDeskWidget) { _deskWidget.Show(); } // new Thread(() => { UpdateLatestDaysImage(); }).Start(); }
private void ShowDeskWidget() { if (deskWidget == null) { deskWidget = new DeskWidget(this); } deskWidget.Show(); }