예제 #1
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();
            }
        }
예제 #2
0
 public FunctionSearchPhotos(ILogger <FunctionSearchPhotos> logger,
                             UnsplashService service)
 {
     _logger  = logger;
     _service = service;
 }