Beispiel #1
0
 private void addFolderBtn_Click(object sender, EventArgs e)
 {
     if (Directory.Exists(folderTxtbx.Text))
     {
         if (_settings.Resolutions.Contains(ConvertRes()))
         {
             Settings.Resolution resolution = ConvertRes();
             _settings.Resolutions
             .Single(res => res.Width == resolution.Width && res.Height == resolution.Height)
             .Folders.Add(folderTxtbx.Text);
             UpdateUi(_settings);
         }
         else
         {
             MessageBox.Show(Resources.Invalid_Resolution_Message, Resources.Invalid_Resolution_Caption,
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show(Resources.Folder_Input_Message, Resources.Folder_Input_Caption, MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
Beispiel #2
0
        public static void SetSlideShow(Settings settings, Settings.Resolution resolution)
        {
            DesktopWallpaper.IDesktopWallpaper wallpaper = DesktopWallpaper.WallpaperWrapper.GetWallpaper();

            try
            {
                IShellItemArray pictures =
                    FoldersToShellItemArray(settings.Resolutions.Find(res => res.Equals(resolution))?.Folders
                                            .ToArray());
                if (pictures == null)
                {
                    throw new Exception("No resolution found");
                }
                wallpaper.SetSlideshow(pictures);
            }
            catch (Exception)
            {
                // ignored
            }
            finally
            {
                Marshal.ReleaseComObject(wallpaper);
            }
        }