using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TwoImagesBackground
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            this.Loaded += MainWindow_Loaded;
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            this.SetImageUri();
        }

        private void RadMap1_ZoomChanged(object sender, EventArgs e)
        {
            this.SetImageUri();
        }

        private void SetImageUri()
        {
            if (this.provider != null)
            {
                Uri imageUri;
                if (this.RadMap1.ZoomLevel < 14)
                {
                    imageUri = new Uri("/TwoImagesBackground;component/Images/LowLevelImage.png", UriKind.Relative);
                }
                else
                {
                    imageUri = new Uri("/TwoImagesBackground;component/Images/HighLevelImage.png", UriKind.Relative);
                }

                if (this.provider.Uri.OriginalString != imageUri.OriginalString)
                {
                    this.provider.Uri = imageUri;
                }
            }
        }
    }
}
