Пример #1
0
        /// <summary>
        /// Get Latest Wallpaper
        /// </summary>
        public async void GetLatestWallpaper()
        {
            HistoryImage historyImage = null;

            try
            {
                historyImage = await _provider.GetLatestImage();

                // 保存到历史记录
                HistoryImageProvider.AddImage(historyImage);
            }
            catch
            {
                historyImage = HistoryImageProvider.getRandom();
            }

            if (historyImage != null)
            {
                Invoke(new Action(async() =>
                {
                    this.CurrentWallpaper = historyImage;
                    await UpdateWallpaper();
                }));
            }
        }
Пример #2
0
 public static void AddImage(HistoryImage image)
 {
     if (!historyImages.ContainsKey(image.Date))
     {
         historyImages.Add(image.Date, image);
         Save();
     }
 }
Пример #3
0
 private void WallpaperControl_OnWallpaperChange(HistoryImage paper)
 {
     if (wallpaperControl.CurrentWallpaper != null)
     {
         var locate = wallpaperControl.CurrentWallpaper.Locate.Split(',').ToList().Last();
         this.lblLocate.Text = locate;
     }
 }
Пример #4
0
 public async void SetRandomWallpaper()
 {
     try
     {
         CurrentWallpaper = HistoryImageProvider.getRandom();
         await UpdateWallpaper();
     }
     catch { }
 }
Пример #5
0
        private void ReloadState()
        {
            var image = HistoryImage.LoadFromFile(CURRENT_FILE_CACHE);

            if (image != null)
            {
                this.CurrentWallpaper = image;
            }
        }
Пример #6
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            var pre = HistoryImageProvider.Next(image.Date);

            if (pre != null)
            {
                image = pre;
                WallpaperStoryForm_Load(sender, e);
            }
        }
Пример #7
0
 public WallpaperStoryForm(HistoryImage image)
 {
     InitializeComponent();
     this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
     this.panel1.BackColor = Color.FromArgb(100, 100, 100, 100);
     this.panel1.Parent    = this.pictureBox1;
     this.btnNext.Parent   = this.pictureBox1;
     this.btnPre.Parent    = this.pictureBox1;
     this.btnPre.Top       = this.btnNext.Top = this.Height / 2 - 20;
     this.image            = image;
 }
Пример #8
0
 /// <summary>
 /// Fetch a random Wallpaper from history
 /// </summary>
 public async void SetRandomWallpaper()
 {
     try
     {
         CurrentWallpaper = HistoryImageProvider.getRandom();
         await UpdateWallpaper();
     }
     catch (Exception ex)
     {
         ShowErrorNotification();
     }
 }
Пример #9
0
 public async void PreWallpaper()
 {
     if (CurrentWallpaper != null)
     {
         var newImage = HistoryImageProvider.Previous(this.CurrentWallpaper.Date);
         if (newImage != null)
         {
             this.CurrentWallpaper = newImage;
             await UpdateWallpaper();
         }
     }
 }
Пример #10
0
 private void WallpaperControl_OnWallpaperChange(HistoryImage paper)
 {
     if (wallpaperControl.CurrentWallpaper != null)
     {
         // 远眺格斯韦因斯泰因村和格斯韦因斯泰因城堡
         var locate = wallpaperControl.CurrentWallpaper.Locate.Split(',').ToList().Last();
         if (locate.Length == 0)
         {
             locate = wallpaperControl.CurrentWallpaper.Title.GetBefore("(");
         }
         this.lblLocate.Text = locate;
     }
 }
Пример #11
0
        private void JumpNext()
        {
            var next = HistoryImageProvider.Next(image.Date);

            if (next != null)
            {
                image = next;
            }
            else
            {
                image = HistoryImageProvider.First();
            }
            LoadImageAsync();
        }
Пример #12
0
        private void JumpPre()
        {
            var pre = HistoryImageProvider.Previous(image.Date);

            if (pre != null)
            {
                image = pre;
            }
            else
            {
                image = HistoryImageProvider.Last();
            }
            LoadImageAsync();
        }
Пример #13
0
        /// <summary>
        /// 随机壁纸
        /// </summary>
        public async void SetRandomWallpaper()
        {
            try
            {
                var bingImg = HistoryImageProvider.getRandom();
                var img     = await bingImg.getImage();

                Wallpaper.Set(img, Wallpaper.Style.Stretched);
                _currentWallpaper = bingImg;
                ShowSetWallpaperNotification();
            }
            catch (Exception ex)
            {
                ShowErrorNotification();
            }
        }
Пример #14
0
 public async void PreWallpaper()
 {
     if (CurrentWallpaper != null)
     {
         var newImage = HistoryImageProvider.Previous(CurrentWallpaper.Date);
         if (newImage != null)
         {
             this.CurrentWallpaper = newImage;
             await UpdateWallpaper();
         }
         else
         {
             MessageBox.Show("已经是第一张了\nAlready the first image");
         }
     }
 }
Пример #15
0
        /// <summary>
        /// 获取最新壁纸
        /// </summary>
        public async void SetWallpaper()
        {
            try
            {
                var bingImg = await _provider.GetLatestImage();

                var img = await bingImg.getImage();

                Wallpaper.Set(img, Wallpaper.Style.Stretched);
                _currentWallpaper = bingImg;
                ShowSetWallpaperNotification();

                // 保存到历史记录
                HistoryImageProvider.AddImage(bingImg);
            }
            catch
            {
                ShowErrorNotification();
            }
        }
Пример #16
0
 public async void NextWallpaper()
 {
     if (CurrentWallpaper != null)
     {
         var newImage = HistoryImageProvider.Next(this.CurrentWallpaper.Date);
         if (newImage != null)
         {
             this.CurrentWallpaper = newImage;
             await UpdateWallpaper();
         }
         else
         {
             this.CurrentWallpaper = HistoryImageProvider.First();
             await UpdateWallpaper();
         }
     }
     else
     {
         RandomWallpaper();
     }
 }
Пример #17
0
 public void WallpaperChange(HistoryImage paper)
 {
     OnWallpaperChange?.Invoke(paper);
 }