Example #1
0
        public void Execute(object parameter)
        {
            var images = new ZhuokuWallpaperWebSite().GetWallpaper();
            List<ImageInfo> temp = new List<ImageInfo>();
            foreach (var image in images)
            {
                try
                {
                    Uri u = new Uri(image.Url);
                    ImageInfo item = new ImageInfo()
                    {
                        Title = image.Title,
                        Url = image.Url,
                        DownloadImage = new DownloadCommand(),
                        SetWallpaper = new SetWallpaperCommand()
                    };
                    temp.Add(item);
                }
                catch(Exception e)
                {

                }
            }
            MainWindowViewModel.GetInstance().WallpaperList = temp;
            MainWindowViewModel.GetInstance().Image = temp[0].Url.ToString();
        }
Example #2
0
        private MainWindowViewModel()
        {
            //PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);
            //LoadStorage();
            this.NextButton = new NextButton();
            this.BackButton = new BackButton();
            this.UpdateButton = new UpdateButton();
            this.Menu = Menus.GetInstance().Menu;


            //暂时这样写
            Task.Run(() =>
            {
                var images = new ZhuokuWallpaperWebSite().GetWallpaper();
                List<ImageInfo> temp = new List<ImageInfo>();
                foreach (var image in images)
                {
                    try
                    {
                        Uri u = new Uri(image.Url);
                        ImageInfo item = new ImageInfo()
                        {
                            Title = image.Title,
                            Url = image.Url,
                            DownloadImage = new DownloadCommand(),
                            SetWallpaper = new SetWallpaperCommand()
                        };
                        temp.Add(item);
                    }
                    catch (Exception e)
                    {

                    }
                }
                this.WallpaperList = temp;
            });
        }