Inheritance: MonoBehaviour
示例#1
0
        private Icon(Texture texture)
        {
            _texture = texture;
            uint frameCount = _texture.ArrayLayers;
            var  duration   = TimeSpan.FromMilliseconds(frameCount * 120);

            _animation = new IconAnimation(this, 0, frameCount - 1, duration);
        }
示例#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);
                }
            }
        }
示例#3
0
        public MyCustomApplicationContext()
        {
            Application.ApplicationExit   += OnApplicationExit;
            SystemEvents.PowerModeChanged += OnPowerChange;
            SystemEvents.SessionSwitch    += OnSessionSwitch;

            _UnsplashService = new UnsplashService();
            _contextMenu     = new ContextMenu();
            _trayIcon        = new NotifyIcon
            {
                Icon        = Resources.logo,
                ContextMenu = _contextMenu,
                Visible     = true
            };

            using (var iconAnimation = new IconAnimation(ref _trayIcon))
            {
                _contextMenu.MenuItems.AddRange(
                    new[]
                {
                    new MenuItem("SplashBot", (_, __) => GoToSplashBot()),
                    new MenuItem("Unsplash.com", (_, __) => GotoUnsplash()),
                    new MenuItem("-")
                    {
                        Enabled = false
                    },
                    new MenuItem("Random", SelectChannel)
                    {
                        Tag     = ChannelFactory.RandomChannel(),
                        Checked = false
                    },
                    new MenuItem("-")
                    {
                        Enabled = false
                    },
                    new MenuItem("Collections")
                    {
                        Enabled = false
                    }
                });

                _contextMenu.MenuItems.AddRange(
                    ChannelFactory.CollectionChannels()
                    .Select(
                        c => new MenuItem(c.Name, SelectChannel)
                {
                    Tag = c, Checked = false
                })
                    .ToArray());

                _contextMenu.MenuItems.AddRange(new[]
                {
                    new MenuItem("-")
                    {
                        Enabled = false
                    },
                    new MenuItem("Searches")
                    {
                        Enabled = false
                    }
                });

                _contextMenu.MenuItems.AddRange(
                    ChannelFactory.SearchChannels()
                    .Select(c => new MenuItem(c.Name, SelectChannel)
                {
                    Tag = c, Checked = false
                })
                    .ToArray());

                _contextMenu.MenuItems.AddRange(
                    new[]
                {
                    new MenuItem("-")
                    {
                        Enabled = false
                    },
                    new MenuItem("Start at login", (sender, args) => CreateStartupShortcut())
                    {
                        Checked = IsEnabledAtStartup()
                    },
                    new MenuItem("-")
                    {
                        Enabled = false
                    },
                    new MenuItem("Quit Splashbot", (sender, args) => Application.Exit())
                });

                if (Properties.Settings.Default.CurrentChannel != null)
                {
                    UpdateMenuSelection(Properties.Settings.Default.CurrentChannel);
                }

                // Onboarding
                if (Properties.Settings.Default.CurrentChannel == null)
                {
                    var channel = ChannelFactory.CollectionChannels().FirstOrDefault();
                    if (channel != null)
                    {
                        Properties.Settings.Default.CurrentChannel = channel;
                        Properties.Settings.Default.Save();
                    }
                }

                UpdateWallpaper();
                MidnightUpdate();
            }
        }
示例#4
0
 void Awake()
 {
     paintIcon = transform.FindChild("PaintBucket").GetComponent <IconAnimation> ();
     cubeIcon  = transform.FindChild("CubeExplode").GetComponent <IconAnimation> ();
 }
示例#5
0
        public MyCustomApplicationContext()
        {
            Application.ApplicationExit   += OnApplicationExit;
            SystemEvents.PowerModeChanged += OnPowerChange;

            _wallcatService  = new WallcatService();
            _googleAnalytics = new GoogleAnalytics();
            _contextMenu     = new ContextMenu();
            _trayIcon        = new NotifyIcon
            {
                Icon        = Resources.AppIcon,
                ContextMenu = _contextMenu,
                Visible     = true
            };

            using (var iconAnimation = new IconAnimation(ref _trayIcon))
            {
                // Add Menu items
                var channels = _wallcatService.GetChannels().Result;
                _contextMenu.MenuItems.Add(new MenuItem("Featured Channels")
                {
                    Enabled = false
                });
                _contextMenu.MenuItems.AddRange(channels.Select(channel => new MenuItem(channel.title, SelectChannel)
                {
                    Tag = channel, Checked = IsCurrentChannel(channel)
                }).ToArray());
                _contextMenu.MenuItems.AddRange(new[]
                {
                    new MenuItem("-")
                    {
                        Enabled = false
                    },
                    new MenuItem("Create Channel...", (sender, args) => ChannelCreateWebpage()),
                    new MenuItem("Start at login", (sender, args) => CreateStartupShortcut())
                    {
                        Checked = IsEnabledAtStartup()
                    },
                    new MenuItem("-")
                    {
                        Enabled = false
                    },
                    new MenuItem("Quit Wallcat", (sender, args) => Application.Exit())
                });

                // Set Current Image Info
                if (Properties.Settings.Default.CurrentWallpaper != null)
                {
                    UpdateMenuCurrentImage(Properties.Settings.Default.CurrentWallpaper);
                }

                // Onboarding
                if (Properties.Settings.Default.CurrentChannel == null)
                {
                    var channel = channels.FirstOrDefault(x => x.isDefault);
                    if (channel != null)
                    {
                        Properties.Settings.Default.CurrentChannel = channel;
                        Properties.Settings.Default.Save();

                        _trayIcon.ShowBalloonTip(10 * 1000, "Welcome to Wallcat", $"Enjoy the {channel.title} channel!", ToolTipIcon.Info);
                    }

                    Properties.Settings.Default.UniqueIdentifier = Guid.NewGuid();
                    _googleAnalytics.SubmitEvent(GoogleAnalyticsCategory.system, GoogleAnalyticsAction.appInstalled).Wait();
                }

                _googleAnalytics.SubmitEvent(GoogleAnalyticsCategory.system, GoogleAnalyticsAction.appLaunched).Wait();

                UpdateWallpaper();
                MidnightUpdate();
            }
        }
示例#6
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)
                    });
                }
            }
        }
示例#7
0
 void Awake()
 {
     paintIcon = transform.FindChild ("PaintBucket").GetComponent<IconAnimation> ();
     cubeIcon = transform.FindChild ("CubeExplode").GetComponent<IconAnimation> ();
 }