Exemple #1
0
        public void ProcessPicture(PictureBatch pb, string config)
        {
            List <Picture> pics = pb.GetPictures(5);

            if (!pics.Any())
            {
                return;
            }

            //for starters lets use an existing image as the backdrop
            Picture pBackdrop = pics.First();
            string  savePath  = System.IO.Path.Combine(Settings.CurrentSettings.CachePath,
                                                       string.Format("{0}.jpg", Guid.NewGuid()));

            List <Rectangle> existingImages = new List <Rectangle>();

            using (Image bmpBackdrop = Image.FromFile(pBackdrop.LocalPath))
            {
                Graphics g = Graphics.FromImage(bmpBackdrop);

                //now get 4 or 5 other pics and strew them about
                foreach (Picture p in pics.Skip(1))
                {
                    Picture pPile = p;
                    using (Bitmap bmpToRotate = (Bitmap)Bitmap.FromFile(pPile.LocalPath))
                    {
                        //draw a 5px white border around the image
                        using (Bitmap bmpWithBorder = PictureManager.AppendBorder(bmpToRotate, 25, Color.White))
                        {
                            using (Bitmap bmpPile = PictureManager.RotateImage(bmpWithBorder, (float)_rand.Next(-30, 30)))
                            {
                                //pick a random x,y coordinate to draw the image, shrink to 25%
                                Rectangle r = Rectangle.Empty;

                                while (r == Rectangle.Empty)
                                {
                                    Rectangle tmp = new Rectangle(_rand.Next(50, bmpBackdrop.Width - 50),
                                                                  _rand.Next(50, bmpBackdrop.Height - 50),
                                                                  Convert.ToInt32(bmpBackdrop.Width * .1),
                                                                  Convert.ToInt32(bmpBackdrop.Height * .1));

                                    if (existingImages.Where(x => Rectangle.Intersect(x, tmp) != Rectangle.Empty).Count() == 0)
                                    {
                                        r = tmp;
                                        existingImages.Add(r);
                                    }
                                }

                                g.DrawImage(bmpPile, r);
                            }
                        }
                    }
                }

                bmpBackdrop.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
            }

            Desktop.SetWallpaperUsingActiveDesktop(savePath);
        }
Exemple #2
0
 void Runner_PictureChanged(PictureBatch obj)
 {
     this.Invoke((Action) delegate
     {
         banImageToolStripMenuItem.Enabled        = obj.CurrentPictures.Count > 0;
         previousPictureToolStripMenuItem.Enabled = (obj.PreviousBatch != null && obj.PreviousBatch.CurrentPictures.Count > 0);
     });
 }
        public void ProcessPicture(PictureBatch pb, string config)
        {
            List <Picture> lp = pb.GetPictures(1);

            if (!lp.Any())
            {
                return;
            }
            Picture p = lp.First();

            OEMBackgroundManager oembm = new OEMBackgroundManager();

            oembm.SetNewPicture(p);
        }
Exemple #4
0
        public void ProcessPicture(PictureBatch pb, string config)
        {
            List <Picture> lp = pb.GetPictures(1);

            if (!lp.Any())
            {
                return;
            }
            Picture p = lp.First();

            string applScript =
                @"set theUnixPath to POSIX file ""{0}"" as text 
tell application ""Finder"" 
set desktop picture to {{theUnixPath}} as alias 
end tell";

            MonoDevelop.MacInterop.AppleScript.Run(string.Format(applScript, p.LocalPath));
        }
Exemple #5
0
        public void ProcessPicture(PictureBatch pb, string config)
        {
            List <Picture> lp = pb.GetPictures(1);

            if (!lp.Any())
            {
                return;
            }
            Picture p = lp.First();

            //deserialize configuration
            WallpaperSetterSettings wss = null;

            if (!string.IsNullOrEmpty(config))
            {
                wss = WallpaperSetterSettings.LoadFromXML(config);
            }
            else
            {
                wss = new WallpaperSetterSettings();
            }


            //set wallpaper style (tiled, centered, etc...)
            //SetWallpaperType(wss.Position);

            //set desktop background color
            //Code came roughly form http://www.tek-tips.com/viewthread.cfm?qid=1449619
            if (wss.BackgroundColorMode == WallpaperSetterSettings.BackgroundColorModes.Specific)
            {
                int[] aiElements = { WinAPI.COLOR_DESKTOP };
                WinAPI.SetSysColors(1, aiElements, new WinAPI.COLORREF(wss.Color));
            }
            else if (wss.BackgroundColorMode == WallpaperSetterSettings.BackgroundColorModes.Computed)
            {
                using (Bitmap bmp = (Bitmap)Image.FromFile(p.LocalPath)) {
                    int[] aiElements = { WinAPI.COLOR_DESKTOP };
                    WinAPI.SetSysColors(1, aiElements, new WinAPI.COLORREF(PictureManager.CalcAverageColor(bmp)));
                }
            }

            Desktop.SetWallpaperUsingActiveDesktop(p.LocalPath);
        }
Exemple #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            PictureSearch ps = new PictureSearch();

            ps.SearchProvider = new ActiveProviderInfo(providerComboBox1.SelectedItem.ToString())
            {
                Active = true, ProviderConfig = _current.SaveConfiguration()
            };
            ps.MaxPictureCount = (int)numericUpDown1.Value;

            ps.SaveFolder = txtDownloadPath.Text;

            IInputProvider p  = ps.SearchProvider.Instance as IInputProvider;
            var            pl = p.GetPictures(ps);

            PictureBatch pb = new PictureBatch();

            pb.AllPictures.Add(pl);

            DownloadManager.Current.SaveFolder = txtDownloadPath.Text;
            DownloadManager.Current.PreFetchFiles(pb);
        }