/// <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(); })); } }
public static void AddImage(HistoryImage image) { if (!historyImages.ContainsKey(image.Date)) { historyImages.Add(image.Date, image); Save(); } }
private void WallpaperControl_OnWallpaperChange(HistoryImage paper) { if (wallpaperControl.CurrentWallpaper != null) { var locate = wallpaperControl.CurrentWallpaper.Locate.Split(',').ToList().Last(); this.lblLocate.Text = locate; } }
public async void SetRandomWallpaper() { try { CurrentWallpaper = HistoryImageProvider.getRandom(); await UpdateWallpaper(); } catch { } }
private void ReloadState() { var image = HistoryImage.LoadFromFile(CURRENT_FILE_CACHE); if (image != null) { this.CurrentWallpaper = image; } }
private void btnNext_Click(object sender, EventArgs e) { var pre = HistoryImageProvider.Next(image.Date); if (pre != null) { image = pre; WallpaperStoryForm_Load(sender, e); } }
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; }
/// <summary> /// Fetch a random Wallpaper from history /// </summary> public async void SetRandomWallpaper() { try { CurrentWallpaper = HistoryImageProvider.getRandom(); await UpdateWallpaper(); } catch (Exception ex) { ShowErrorNotification(); } }
public async void PreWallpaper() { if (CurrentWallpaper != null) { var newImage = HistoryImageProvider.Previous(this.CurrentWallpaper.Date); if (newImage != null) { this.CurrentWallpaper = newImage; await UpdateWallpaper(); } } }
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; } }
private void JumpNext() { var next = HistoryImageProvider.Next(image.Date); if (next != null) { image = next; } else { image = HistoryImageProvider.First(); } LoadImageAsync(); }
private void JumpPre() { var pre = HistoryImageProvider.Previous(image.Date); if (pre != null) { image = pre; } else { image = HistoryImageProvider.Last(); } LoadImageAsync(); }
/// <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(); } }
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"); } } }
/// <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(); } }
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(); } }
public void WallpaperChange(HistoryImage paper) { OnWallpaperChange?.Invoke(paper); }