Пример #1
0
        private void LoadImage(object sender, RoutedEventArgs e)
        {
            Image img = sender as Image;

            img.Stretch = Stretch.Fill;
            img.Source  = new BitmapImage(new Uri(BingUtils.LOCAL_IMAGE_FILE_JPG, UriKind.RelativeOrAbsolute));
            img.Stretch = Stretch.UniformToFill;

            BingObject bingObject = BingUtils.ReadConfig();

            if (bingObject.images != null)
            {
                string info = bingObject.images.FirstOrDefault()?.copyright;
                if (info != null)
                {
                    copyright_window.Text = Regex.Match(info, @"\(([^)]*)\)").Groups[1].Value;
                    title_window.Text     = info.Replace(Regex.Match(info, @"\(([^)]*)\)").Groups[0].Value, "");

                    System.Threading.Tasks.Task.Run(async() =>
                    {
                        await BingUtils.SetBingWallpaperAsync();
                    }).Wait();

                    if (bingObject.config != null && bingObject.config.setLockScreen)
                    {
                        System.Threading.Tasks.Task.Run(async() =>
                        {
                            await BingUtils.SetBingWallpaperLockScreenAsync();
                        }).Wait();
                    }
                }
            }
        }