コード例 #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Do any additional setup after loading the view.
            WallpaperService wallpaper = new WallpaperService();
            var model  = wallpaper.GetTodayWallpaperUrl();
            var stream = wallpaper.GetStream(model.Url);

            imgWallpaper.Image = NSImage.FromStream(stream);
            url = model.Url;
            lblInfo.StringValue        = model.Copyright;
            lblPictureDate.StringValue = model.Startdate;
        }
コード例 #2
0
        partial void btnApply(AppKit.NSButton sender)
        {
            string           pictureName = $"bing_wallpaper_{DateTime.Now.Year}{DateTime.Now.Month}{DateTime.Now.Day}.jpg";
            WallpaperService wallpaper   = new WallpaperService();
            var data = wallpaper.GetByte(url);
            var path = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

            File.WriteAllBytes(Path.Combine(path, pictureName), data);

            var fileName = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "/" + pictureName;
            var cmd      = $"tell application \"Finder\" to set desktop picture to \"{fileName}\" as POSIX file";

            using (var script = new NSAppleScript(cmd))
            {
                var errors = new NSDictionary();
                var result = script.ExecuteAndReturnError(out errors);
                //if (!string.IsNullOrEmpty(errors.Val))
                //{

                //}
            }
        }