Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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);
                }
            }
        }
Beispiel #3
0
        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)
                    });
                }
            }
        }