public static void UpdateSystemWallpaper(string filePath) { #if DEBUG MessageBox.Show(@"set wall parpaer: " + filePath, @"Update System Wallpaper"); return; #endif if (Environment.OSVersion.Version.Major >= 8) { SetWallpaper.Apply(null, filePath, DesktopWallpaperPosition.Fill); } else { SetWallpaperLegacy.Apply(filePath, DesktopWallpaperPosition.Fill); } }
private async void SelectChannel(object sender, EventArgs e) { using (var iconAnimation = new IconAnimation(ref _trayIcon)) { var channel = (UnsplashChannel)((MenuItem)sender).Tag; // Update Settings Properties.Settings.Default.CurrentChannel = channel; Properties.Settings.Default.LastChecked = DateTime.Now.Date; Properties.Settings.Default.Save(); UpdateMenuSelection(channel); var wallpaper = await _UnsplashService.GetWallpaper(channel); string filePath = ""; try { filePath = await DownloadFile.Get(wallpaper.Url); } catch (WebException webException) { Console.WriteLine(webException); if (webException.Response is HttpWebResponse r) { if (r.StatusCode == HttpStatusCode.ServiceUnavailable) { MessageBox.Show("Unsplash service unavailable.", "SplashBot Error.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; //filePath = GetBlackPixel(); } } } if (Environment.OSVersion.Version.Major >= 8) { // Windows 10 SetWallpaper.Apply(null, filePath, DesktopWallpaperPosition.Fill); } else { SetWallpaperLegacy.Apply(filePath, DesktopWallpaperPosition.Fill); } } }
public void tText(int TimeOut) { do { try { Random r = new Random(); Bitmap bitmap = new Bitmap(Convert.ToInt32(1920), Convert.ToInt32(1080), PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(bitmap)) { LinearGradientBrush linGrBrush = new LinearGradientBrush ( new Point(0, 0), new Point(0, 1920), Color.FromArgb(r.Next(0, 256), r.Next(0, 256), r.Next(0, 256), r.Next(0, 256)), Color.FromArgb(r.Next(0, 256), r.Next(0, 256), r.Next(0, 256), r.Next(0, 256)) ); using (linGrBrush) { g.FillRectangle(linGrBrush, 0, 0, 1920, 1080); Thread.Sleep(30); bitmap.Save(path + "\\test.jpeg", ImageFormat.Jpeg); Display.BackgroundImage = bitmap; if (SetCheck.Checked) { SetWallpaper.Set(SetWallpaper.Style.Fill, path + "\\test.jpeg"); } } } System.GC.Collect(); System.GC.WaitForPendingFinalizers(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } Thread.Sleep(TimeOut); }while (staSto == 1); }
private async void SelectChannel(object sender, EventArgs e) { using (var iconAnimation = new IconAnimation(ref _trayIcon)) { if (Properties.Settings.Default.CurrentChannel != null && e != null) { await _googleAnalytics.SubmitEvent(GoogleAnalyticsCategory.channel, GoogleAnalyticsAction.channelUnsubscribed, Properties.Settings.Default.CurrentChannel.title, new[] { new DimensionTuple(GoogleAnalyticsDimension.channelId, Properties.Settings.Default.CurrentChannel.id), new DimensionTuple(GoogleAnalyticsDimension.channelTitle, Properties.Settings.Default.CurrentChannel.title) }); } var channel = (Channel)((MenuItem)sender).Tag; var wallpaper = await _wallcatService.GetWallpaper(channel.id); if (wallpaper.id == Properties.Settings.Default.CurrentWallpaper?.id) { return; } var filePath = await DownloadFile.Get(wallpaper.url.o); if (Environment.OSVersion.Version.Major >= 8) { SetWallpaper.Apply(null, filePath, DesktopWallpaperPosition.Fill); } else { SetWallpaperLegacy.Apply(filePath, DesktopWallpaperPosition.Fill); } // Update Settings Properties.Settings.Default.CurrentChannel = channel; Properties.Settings.Default.CurrentWallpaper = wallpaper; Properties.Settings.Default.LastChecked = DateTime.Now.Date; Properties.Settings.Default.Save(); // Update Menu UpdateMenuCurrentImage(wallpaper); await _googleAnalytics.SubmitEvent(GoogleAnalyticsCategory.wallpaper, GoogleAnalyticsAction.wallpaperSet, wallpaper.id, new[] { new DimensionTuple(GoogleAnalyticsDimension.wallpaperId, wallpaper.id), new DimensionTuple(GoogleAnalyticsDimension.wallpaperTitle, wallpaper.title), new DimensionTuple(GoogleAnalyticsDimension.channelId, channel.id), new DimensionTuple(GoogleAnalyticsDimension.channelTitle, channel.title), new DimensionTuple(GoogleAnalyticsDimension.partnerId, wallpaper.partner.id), new DimensionTuple(GoogleAnalyticsDimension.partnerName, wallpaper.partner.name) }); if (e != null) { await _googleAnalytics.SubmitEvent(GoogleAnalyticsCategory.channel, GoogleAnalyticsAction.channelSubscribed, channel.title, new[] { new DimensionTuple(GoogleAnalyticsDimension.channelId, channel.id), new DimensionTuple(GoogleAnalyticsDimension.channelTitle, channel.title) }); } } }