Exemple #1
0
        public MainForm(BingImageProvider provider, Settings settings)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }
            _provider = provider;
            _settings = settings ?? throw new ArgumentNullException(nameof(settings));

            // LaunchOnStartup
            SetStartup(_settings.LaunchOnStartup);

            AddTrayIcons();

            // 定时更新
            CreateDaylyUpdateTimer();

            // Create Auto Change Task
            if (_settings.AutoChange)
            {
                CreateAutoChangeTask();
            }

            if (_settings.ShowWidget)
            {
                // open Desk Widget
                ShowDeskWidget();
            }

            LoadWallPaper();
        }
Exemple #2
0
        public BWApplicationContext(BingImageProvider provider, Settings settings)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }
            _provider = provider;

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            _settings = settings;

            // Register application with registry
            SetStartup(_settings.LaunchOnStartup);

            AddTrayIcons();

            // Set wallpaper every 24 hours
            var timer = new System.Timers.Timer();

            timer.Interval  = 1000 * 60 * 60 * 24; // 24 hours
            timer.AutoReset = true;
            timer.Enabled   = true;
            timer.Elapsed  += (s, e) => SetWallpaper(0);
            timer.Start();

            // Set wallpaper on first run
            SetWallpaper();
        }
Exemple #3
0
        public MainForm(BingImageProvider provider, Settings settings)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }
            _provider = provider;

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            _settings = settings;

            // LaunchOnStartup
            SetStartup(_settings.LaunchOnStartup);

            AddTrayIcons();

            // 定时更新
            var timer = new System.Timers.Timer();

            timer.Interval  = 1000 * 60 * 60 * 24; // 24 hours
            timer.AutoReset = true;
            timer.Enabled   = true;
            timer.Elapsed  += (s, e) => GetLatestWallpaper();
            timer.Start();

            // Create Auto Change Task
            if (_settings.AutoChange)
            {
                CreateAutoChangeTask();
            }

            this.ReloadState();

            new Thread(() =>
            {
                // Get the latest wallpaper
                GetLatestWallpaper();
            }).Start();



            // open Desk Widget
            _deskWidget = new DeskWidget(this);

            if (_settings.ShowDeskWidget)
            {
                _deskWidget.Show();
            }


            //
            new Thread(() =>
            {
                UpdateLatestDaysImage();
            }).Start();
        }
Exemple #4
0
        public MainForm(BingImageProvider provider, Settings settings)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }
            _provider = provider;

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            _settings = settings;

            SetStartup(_settings.LaunchOnStartup);

            InitializeComponent();

            this.KeyPreview = true;
            //添加热键
            HotKey.RegisterHotKey(this.Handle, 110, HotKey.KeyModifiers.Shift, Keys.F5);
            HotKey.RegisterHotKey(this.Handle, 111, HotKey.KeyModifiers.Shift, Keys.Left);
            HotKey.RegisterHotKey(this.Handle, 112, HotKey.KeyModifiers.Shift, Keys.Right);

            AddTrayIcons();

            // 定时更新
            var timer = new System.Timers.Timer();

            timer.Interval  = 1000 * 60 * 60 * 24;
            timer.AutoReset = true;
            timer.Enabled   = true;
            timer.Elapsed  += (s, e) => GetLatestWallpaper();
            timer.Start();

            if (_settings.AutoChange)
            {
                CreateAutoChangeTask();
            }

            this.ReloadState();

            new Thread(() =>
            {
                GetLatestWallpaper();
            }).Start();

            new Thread(() =>
            {
                UpdateLatestDaysImage();
            }).Start();
        }
Exemple #5
0
        public MainForm(BingImageProvider provider, Settings settings)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }
            _provider = provider;

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            _settings = settings;

            // Register application with registry
            SetStartup(_settings.LaunchOnStartup);

            AddTrayIcons();

            // Set wallpaper at local time 0:0:5
            var now             = DateTime.Now;
            var nextDay         = now.AddDays(1);
            var nextDayZeroTime = new DateTime(nextDay.Year, nextDay.Month, nextDay.Day, 0, 0, 5);

            var firstTimer = new System.Timers.Timer((nextDayZeroTime - now).TotalMilliseconds);

            firstTimer.AutoReset = false;
            firstTimer.Enabled   = true;
            firstTimer.Elapsed  += (fs, fe) => {
                var secondTimer = new System.Timers.Timer(1000 * 60 * 60 * 24); // 24 hours
                secondTimer.AutoReset = true;
                secondTimer.Enabled   = true;
                secondTimer.Elapsed  += (ss, se) => SetWallpaper();
                secondTimer.Start();

                SetWallpaper();
            };
            firstTimer.Start();

            // Set wallpaper on first run
            SetWallpaper();
        }
Exemple #6
0
        public MainForm(BingImageProvider provider, Settings settings)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }
            _provider = provider;

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            _settings = settings;

            // 开机启动注册
            SetStartup(_settings.LaunchOnStartup);

            AddTrayIcons();

            // 定时更新
            var timer = new System.Timers.Timer();

            timer.Interval  = 1000 * 60 * 60 * 24; // 24 hours
            timer.AutoReset = true;
            timer.Enabled   = true;
            timer.Elapsed  += (s, e) => SetWallpaper();
            timer.Start();

            // 自动切换
            if (_settings.AutoChange)
            {
                CreateAutoChangeTask();
            }

            // 更新壁纸
            SetWallpaper();
        }