Ejemplo n.º 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();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public SettingsPage()
        {
            BingObject bingObject = BingUtils.ReadConfig();

            this.InitializeComponent();
            this.DataContext = this;

            if (bingObject?.config != null)
            {
                defaultLanguage      = bingObject.config.languageOptions.Name;
                defaultPeriod        = bingObject.config.period;
                defaultRunAtStartup  = bingObject.config.runAtStartup;
                defaultSetWallpaper  = bingObject.config.setWallpaper;
                defaultSetLockScreen = bingObject.config.setLockScreen;
            }
            else
            {
                defaultLanguage      = CultureInfo.CurrentCulture.Name;
                defaultPeriod        = "Every Day";
                defaultRunAtStartup  = true;
                defaultSetWallpaper  = true;
                defaultSetLockScreen = true;
            }

            cmbLocation.ItemsSource  = LanguageOptions;
            cmbExecution.ItemsSource = ExecutionPeriods;

            cmbLocation.SelectedIndex  = LanguageOptions.IndexOf(LanguageOptions.Where(p => p.Name == defaultLanguage).ToList().FirstOrDefault());
            cmbExecution.SelectedIndex = executionPeriods.IndexOf(defaultPeriod);

            RunAtStartup_Box.IsChecked  = defaultRunAtStartup;
            SetWallpaper_Box.IsChecked  = defaultSetWallpaper;
            SetLockScreen_Box.IsChecked = defaultSetLockScreen;
        }