示例#1
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;
        }
示例#2
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();
                    }
                }
            }
        }
示例#3
0
        public MainPage()
        {
            BingObject bingObject = BingUtils.GetWallpaperFromBing("ES-es");

            this.InitializeComponent();

            var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            Window.Current.SetTitleBar(AppTitle);
            coreTitleBar.ExtendViewIntoTitleBar = true;

            //remove the solid-colored backgrounds behind the caption controls and system back button
            var viewTitleBar = ApplicationView.GetForCurrentView().TitleBar;

            viewTitleBar.ButtonBackgroundColor         = Colors.Transparent;
            viewTitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
            viewTitleBar.ButtonForegroundColor         = (Color)Resources["SystemBaseHighColor"];

            UpdateAppTitle();
            Window.Current.CoreWindow.SizeChanged += (s, e) => UpdateAppTitle();
            coreTitleBar.LayoutMetricsChanged     += (s, e) => UpdateAppTitle();

            ContentFrame.Navigate(typeof(BingPage));
        }