Beispiel #1
0
        private async void SelectChannel(Channel channel)
        {
            using (new IconAnimation(ref _icon))
            {
                var wallpaper = await _server.GetWallpaper(channel.id);

                if (wallpaper.id == _state.CurrentWallpaper?.id)
                {
                    return;
                }

                var filePath = await DownloadFile.Get(wallpaper.url.o, _state.SavePath + "/" + wallpaper.title);

                SystemService.UpdateSystemWallpaper(filePath);

                // Update Settings
                Settings.Default.CurrentChannel   = channel;
                Settings.Default.CurrentWallpaper = wallpaper;
                Settings.Default.LastChecked      = DateTime.Now.Date;
                Settings.Default.Save();
                _state = Settings.Default;

                LoadState();
                RefreshMenu();
            }
        }
Beispiel #2
0
        public void DownloadFile(string columnName, string path, int versionId)
        {
            var    index    = GetColumnIndex(columnName);
            var    field    = this._fields[this._fields.IndexOf(new QField(Columns[index].ColumnId))];
            string fileName = (string)field.Value;

            var fileToDownload = new DownloadFile(Application.Client.Ticket, Application.Client.AccountDomain, path, fileName, Table.TableId, RecordId,
                                                  field.FieldId, versionId);

            fileToDownload.Get();
        }
Beispiel #3
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 #4
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)
                    });
                }
            }
        }