Exemple #1
0
        private void DeleteButtonClicked(object sender, EventArgs e)
        {
            List <WallpaperItem> removed = new List <WallpaperItem>();

            foreach (WallpaperItem each in MainWrapPanel.Children)
            {
                WallpaperManifestItem wallpaperManifestItem = FindInManifest(each);
                if (each.WallpaperCheckbox.IsChecked == true)
                {
                    RemoveWallpaperItemInPlaylist(each);
                    if (wallpaperManifestItem != null)
                    {
                        AppData._wallpapersManifest.list.Remove(wallpaperManifestItem);
                    }

                    removed.Add(each);
                }
                else
                {
                    if (wallpaperManifestItem != null)
                    {
                        wallpaperManifestItem.IsInPlaylist = false;
                    }
                }
            }

            foreach (WallpaperItem each in removed)
            {
                MainWrapPanel.Children.Remove(each);
                Directory.Delete(System.IO.Path.GetDirectoryName(each.data.WallpaperPath), true);
            }
        }
Exemple #2
0
        public WallpaperManifestItem FindInManifest(WallpaperItem item)
        {
            WallpaperManifestItem removedItem = null;

            foreach (var each in AppData._wallpapersManifest.list)
            {
                if (each.WallpaperID == item.data.WallpaperID)
                {
                    removedItem = each;
                    break;
                }
            }

            return(removedItem);
        }
Exemple #3
0
 public void UpdatePlaylist()
 {
     Playlist.Children.Clear();
     foreach (WallpaperItem each in MainWrapPanel.Children)
     {
         WallpaperManifestItem wallpaperManifestItem = FindInManifest(each);
         if (each.WallpaperCheckbox.IsChecked == true)
         {
             AddWallpaperItemInPlaylist(each);
             if (wallpaperManifestItem != null)
             {
                 wallpaperManifestItem.IsInPlaylist = true;
             }
         }
         else
         {
             if (wallpaperManifestItem != null)
             {
                 wallpaperManifestItem.IsInPlaylist = false;
             }
         }
     }
 }
Exemple #4
0
        public WallpaperItem AddWallpaper(WallpaperManifestItem manifestItem)
        {
            WallpaperItem item = new WallpaperItem();

            item.data = manifestItem;
            item.SetValue(WallpaperItem.WallpaperNameProperty, manifestItem.WallpaperName);
            item.Margin = new Thickness(10, 10, 10, 10);


            string imagePath = System.IO.Path.Combine(
                System.IO.Path.GetDirectoryName(manifestItem.WallpaperPath),
                WallpaperManifest.GetWallpaper(manifestItem.WallpaperPath).WallpaperThumbnail
                );

            item.SetValue(WallpaperItem.ImagePathProperty, imagePath);
            item.WallpaperCheckbox.IsChecked = false;

            item.WallpaperCheckbox.Checked   += new RoutedEventHandler(CheckBoxChecked);
            item.WallpaperCheckbox.Unchecked += new RoutedEventHandler(CheckBoxUnchecked);
            item.ItemMask.MouseDown          += new MouseButtonEventHandler(ItemMaskClicked);
            MainWrapPanel.Children.Add(item);

            return(item);
        }
Exemple #5
0
        private void AddButtonClicked(object sender, EventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dialog =
                new Microsoft.Win32.OpenFileDialog();
            dialog.Filter = "zip压缩文件|*.zip";
            if (dialog.ShowDialog() == true)
            {
                string file            = dialog.FileName;
                string targetDirectory = System.IO.Path.Combine(System.IO.Path.GetFullPath("wallpaper"),
                                                                System.IO.Path.GetFileNameWithoutExtension(file));
                Package.PackageInstall.Install(file, System.IO.Path.GetFullPath("wallpaper"));

                WallpaperManifest manifest = WallpaperManifest.GetWallpaper(System.IO.Path.Combine(targetDirectory, "manifest.json"));

                WallpaperManifestItem manifestItem = new WallpaperManifestItem();
                manifestItem.WallpaperID = AppData._wallpapersManifest.nextID;
                AppData._wallpapersManifest.nextID++;
                manifestItem.WallpaperPath = System.IO.Path.Combine(targetDirectory, "manifest.json");
                manifestItem.WallpaperName = manifest.WallpaperName;
                manifestItem.WallpaperType = manifest.WallpaperType;

                AppData._wallpapersManifest.list.Add(manifestItem);

                WallpaperItem item = AddWallpaper(manifestItem);

                if (manifestItem.IsInPlaylist)
                {
                    AddWallpaperItemInPlaylist(item);
                }

                if (manifestItem == AppData._wallpapersManifest.list[0])
                {
                    showDetailsFromItem(item);
                }
            }
        }