Example #1
0
 public void It_shouldnt_attempt_much_if_folderIco_already_exists()
 {
     File.WriteAllText(filmMock.PathTo("folder.ico"), "");
     new IconService().Process(filmMock);
     Assert.IsFalse(File.Exists(filmMock.PathTo("desktop.ini")));
     File.Delete(filmMock.PathTo("folder.ico"));
 }
Example #2
0
        private void BuildFolderIco(IFilmFromFolder film)
        {
            new PosterService().Download(film.Poster, film.PathTo("folder.jpg"), (url, path) =>
                                         MessageBox.Show("Couldn't download folder.jpg for '" + film.Title + "' from url '" + film.Poster + "' to '" + film.PathTo("folder.jpg") + "'", "Error downloading folder.jpg", MessageBoxButton.OK, MessageBoxImage.Error));

            if (!System.IO.File.Exists(film.PathTo("folder.jpg")))
            {
                return;
            }

            Task <Bitmap> task = StaTask.Start <Bitmap>(() => new IconLayout(new IconLayoutViewModel(film.PathTo("folder.jpg"), film.Rating)).RenderToBitmap());

            task.Wait();
            Bitmap icon = task.Result;

            new PngToIcoService().Convert(icon, film.PathTo("folder.ico"));
        }
Example #3
0
 public override void Process(IFilmFromFolder film)
 {
     if (System.IO.File.Exists(film.PathTo("folder.ico")) || String.IsNullOrWhiteSpace(film.Rating))
     {
         return;
     }
     BuildFolderIco(film);
     SetupFolderIcon(film.Path);
 }
Example #4
0
 public void It_shouldnt_attempt_much_if_folder_has_no_rating()
 {
     filmMock = new NotAFilmMock(@"C:\Temp");
     new IconService().Process(filmMock);
     Assert.IsFalse(File.Exists(filmMock.PathTo("desktop.ini")));
 }
Example #5
0
 public void It_shouldnt_attempt_much_if_folder_has_no_rating()
 {
     filmMock = new NotAFilmMock(@"C:\Temp");
     new IconService().Process(filmMock);
     Assert.IsFalse(File.Exists(filmMock.PathTo("desktop.ini")));
 }
Example #6
0
        private void BuildFolderIco(IFilmFromFolder film)
        {
            new PosterService().Download(film.Poster, film.PathTo("folder.jpg"), (url, path) =>
                MessageBox.Show("Couldn't download folder.jpg for '" + film.Title + "' from url '" + film.Poster + "' to '" + film.PathTo("folder.jpg") + "'", "Error downloading folder.jpg", MessageBoxButton.OK, MessageBoxImage.Error));

            if(!System.IO.File.Exists(film.PathTo("folder.jpg")))
            {
                return;
            }

            Task<Bitmap> task = StaTask.Start<Bitmap>(() => new IconLayout(new IconLayoutViewModel(film.PathTo("folder.jpg"), film.Rating)).RenderToBitmap());
            task.Wait();
            Bitmap icon = task.Result;
            new PngToIcoService().Convert(icon, film.PathTo("folder.ico"));
        }
Example #7
0
 public override void Process(IFilmFromFolder film)
 {
     if (System.IO.File.Exists(film.PathTo("folder.ico")) || String.IsNullOrWhiteSpace(film.Rating)) { return; }
     BuildFolderIco(film);
     SetupFolderIcon(film.Path);
 }