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;
using C1.WPF;
using C1.WPF.Theming;

namespace Themes
{
    /// <summary>
    /// Interaction logic for DemoThemes.xaml
    /// </summary>
    public partial class DemoThemes : UserControl
    {
        public DemoThemes()
        {
            InitializeComponent();

            cmbTheme.ItemsSource = typeof(C1AvailableThemes).GetEnumValues<C1AvailableThemes>();
            cmbTheme.SelectedItem = C1AvailableThemes.Office2016Colorful;

            Loaded += DemoThemes_Loaded;
        }

        void DemoThemes_Loaded(object sender, RoutedEventArgs e)
        {
            cmbTheme_SelectedItemChanged(null, null);
        }

        private void cmbTheme_SelectedItemChanged(object sender, PropertyChangedEventArgs<object> e)
        {
            var theme = C1ThemeFactory.GetTheme((C1AvailableThemes)cmbTheme.SelectedItem);
            C1Theme.ApplyTheme(LayoutRoot, theme);

            var adornerLayer = AdornerLayer.GetAdornerLayer(LayoutRoot);
            if (adornerLayer != null)
            {
                // this will aplly theme to everything displayed in adorner, including any C1Window instances
                C1Theme.ApplyTheme(adornerLayer, theme); 
            }

            gallery.CurrentTheme = theme;
        }
    }
}
