Example #1
0
        /// <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")));
        }
Example #2
0
        /// <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);
        }
Example #3
0
 /// <summary>
 /// Initialises a new instance of the application context
 /// </summary>
 public FlockContext()
 {
     Initialise();
     if (WallpaperProcess.IsDesktopSetByFlock())
     {
         UpdateAuthor();
     }
 }
Example #4
0
 private void UpdateAuthor()
 {
     photoByMenuItem.Visible  = true;
     authorSeperator.Visible  = true;
     authorMenuItem.Text      = WallpaperProcess.GetAuthorFromSavedFile();
     authorMenuItem.Visible   = true;
     unsplashMenuItem.Visible = true;
 }
Example #5
0
        /// <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));
        }
Example #6
0
 static void Main(string[] args)
 {
     WallpaperProcess.setWallpaper();
     //Console.WriteLine(dir);
     //Console.ReadLine();
 }