Example #1
0
        private void CheckBoxUnchecked(object sender, EventArgs e)
        {
            CheckBox      obj    = (CheckBox)sender;
            WallpaperItem parent = (WallpaperItem)((Grid)obj.Parent).Parent;

            showDetailsFromItem(parent);
        }
Example #2
0
        public WallpapersWindow(MainWindow.ShowPageEventHandler showPage)
        {
            InitializeComponent();
            AppData._wallpapersManifest = WallpapersManifest.GetWallpapersList("wallpaperManifest.json");
            foreach (var each in AppData._wallpapersManifest.list)
            {
                WallpaperItem item = AddWallpaper(each);

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

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

            _showPage = showPage;

            ButtonAdd.Click    += new RoutedEventHandler(AddButtonClicked);
            ButtonDelete.Click += new RoutedEventHandler(DeleteButtonClicked);
            ButtonPlay.Click   += new RoutedEventHandler(PlayButtonClicked);

            SearchButton.Click += new RoutedEventHandler(SearchWallpaper);
        }
Example #3
0
 public void showDetailsFromItem(WallpaperItem item)
 {
     DetailImage.Source   = item.WallpaperImage.Source;
     DetailName.Content   = item.WallpaperName.Content;
     DetailAuthor.Content = "";
     DetailBrief.Content  = "";
     DetailType.Content   = item.data.WallpaperType;
 }
Example #4
0
 private static void WallpaperNamePropertyChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs arg)
 {
     if (sender != null)
     {
         WallpaperItem obj = (WallpaperItem)sender;
         obj.WallpaperName.Content = (string)arg.NewValue;
     }
 }
Example #5
0
 private static void ImagePathPropertyChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs arg)
 {
     if (sender != null)
     {
         WallpaperItem obj = (WallpaperItem)sender;
         obj.WallpaperImage.Source = Settings.SettingsUtil.ReadImage(System.IO.Path.GetFullPath((string)arg.NewValue));
     }
 }
Example #6
0
        public void AddWallpaperItemInPlaylist(WallpaperItem item)
        {
            WallpaperItem newChildren = new WallpaperItem();

            newChildren.data = item.data;
            newChildren.SetValue(WallpaperItem.WallpaperNameProperty, item.WallpaperName.Content);
            newChildren.Margin = new Thickness(10, 10, 10, 10);
            newChildren.SetValue(WallpaperItem.ImagePathProperty, item.GetValue(WallpaperItem.ImagePathProperty));
            newChildren.WallpaperCheckbox.Visibility = Visibility.Hidden;
            this.Playlist.Children.Add(newChildren);
        }
Example #7
0
        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);
        }
Example #8
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);
        }
Example #9
0
        public void RemoveWallpaperItemInPlaylist(WallpaperItem item)
        {
            WallpaperItem removedItem = null;

            foreach (WallpaperItem each in Playlist.Children)
            {
                if (each.data.WallpaperID == item.data.WallpaperID)
                {
                    removedItem = each;
                    break;
                }
            }

            if (removedItem != null)
            {
                Playlist.Children.Remove(removedItem);
            }
        }
Example #10
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);
        }
Example #11
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);
                }
            }
        }