/// <summary> /// 初始化 /// </summary> public void init() { string url = ""; if ((url = WallpaperProcess.getURL()) != "0") { setStatusLabel.Text = "正在设置壁纸"; setStatusLabel.ForeColor = Color.Green; statusProgressBar.Value += 30; setProgramImage(url);//设置背景图片 } else { statusProgressBar.Value = 0; setStatusLabel.Text = "获取失败"; setStatusLabel.ForeColor = Color.Red; return; } initBackground(); statusProgressBar.Value += 30; WallpaperProcess.setWallpaper();//设置墙纸 setStatusLabel.Text = "设置成功"; statusProgressBar.Value = 100; setStatusLabel.ForeColor = Color.Blue; changeDefaultSetting(int.Parse(ConfigOperation.getXmlValue(Application.StartupPath, "WallpaperSize")), int.Parse(ConfigOperation.getXmlValue(Application.StartupPath, "WallpaperStyle"))); }
/// <summary> /// Fires when a user has clicked the retrieve button. Calls a new thread to retrieve a wallpaper /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The event</param> private void GetNewItem_Click(object sender, EventArgs e) { getNewMenuItem.Text = retrieveButtonDisabledText; getNewMenuItem.Enabled = false; var wallpaperTask = Task.Factory.StartNew(() => { WallpaperProcess.Run(); }); wallpaperTask.ContinueWith(task => { getNewMenuItem.Text = retrieveButtonEnabledText; getNewMenuItem.Enabled = true; getNewMenuItem.Image = null; UpdateAuthor(); }, TaskScheduler.FromCurrentSynchronizationContext()); wallpaperTask.ContinueWith(task => { MessageBox.Show(task.Exception.InnerException.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); getNewMenuItem.Text = retrieveButtonEnabledText; getNewMenuItem.Enabled = true; getNewMenuItem.Image = null; }, TaskContinuationOptions.OnlyOnFaulted); }
/// <summary> /// Initialises a new instance of the application context /// </summary> public FlockContext() { Initialise(); if (WallpaperProcess.IsDesktopSetByFlock()) { UpdateAuthor(); } }
private void UpdateAuthor() { photoByMenuItem.Visible = true; authorSeperator.Visible = true; authorMenuItem.Text = WallpaperProcess.GetAuthorFromSavedFile(); authorMenuItem.Visible = true; unsplashMenuItem.Visible = true; }
/// <summary> /// Fires when a user has clicked the author button. Opens Unsplash /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The event</param> private void AuthorItem_Click(object sender, EventArgs e) { var currentWallpaper = WallpaperProcess.GetAuthorURLFromSavedFile(); System.Diagnostics.Process.Start(string.Format("{0}{1}", currentWallpaper, Config.UnsplashReferral)); }
static void Main(string[] args) { WallpaperProcess.setWallpaper(); //Console.WriteLine(dir); //Console.ReadLine(); }