private void ItemMaskClicked(object sender, EventArgs e) { Rectangle obj = (Rectangle)sender; WallpaperItem parent = (WallpaperItem)((Grid)obj.Parent).Parent; // parent.WallpaperCheckbox.IsChecked = !parent.WallpaperCheckbox.IsChecked; string indexAbsolutePath = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(parent.data.WallpaperPath), WallpaperManifest.GetWallpaper(parent.data.WallpaperPath).WallpaperMainPath ); _showPage(indexAbsolutePath); }
private void RandomWallpaper() { // random wallpaper AppData._wallpapersManifest = WallpapersManifest.GetWallpapersList("wallpaperManifest.json"); Wallpapers.WallpaperManifestItem randomWallpaper = AppData._wallpapersManifest.RandomWallpaperInPlaylist(); WallpaperManifest manifest = WallpaperManifest.GetWallpaper(randomWallpaper.WallpaperPath); // get index.html path string wallpaperDirectory = System.IO.Path.GetFullPath(System.IO.Path.GetDirectoryName(randomWallpaper.WallpaperPath)); string indexPath = System.IO.Path.Combine(wallpaperDirectory, manifest.WallpaperMainPath); // create browser _chromiumWebBrowser.SetValue(ChromiumWebBrowser.AddressProperty, "file:///" + indexPath); }
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); }
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); } } }