using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using C1.Silverlight.Theming;
using C1.Silverlight.Theming.Office2010;

namespace OfficeThemes
{
    public partial class Outlook2010 : Page
    {
        public Outlook2010()
        {
            InitializeComponent();

            C1Theme.ApplyTheme(LayoutRoot, Offfice2010Themes.Default);
            btnDefault.IsChecked = true;
        }

        private void DefaultTheme_Click(object sender, RoutedEventArgs e)
        {
            C1Theme.ApplyTheme(LayoutRoot, Offfice2010Themes.Default);
        }

        private void SilverTheme_Click(object sender, RoutedEventArgs e)
        {
            C1Theme.ApplyTheme(LayoutRoot, Offfice2010Themes.Silver);
        }

        private void BlackTheme_Click(object sender, RoutedEventArgs e)
        {
            C1Theme.ApplyTheme(LayoutRoot, Offfice2010Themes.Black);
        }

        private void ClearStyleGreen_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Outlook2010ClearStyle", UriKind.Relative));
        }

        private void ClearStyleTransparent_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Outlook2010ClearStyle2", UriKind.Relative));
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Uri.OriginalString.Length > 12)
            {
                tabView.IsSelected = true;
                var theme = e.Uri.OriginalString.Substring(13);
                if (theme == "black")
                {
                    C1Theme.ApplyTheme(LayoutRoot, Offfice2010Themes.Black);
                    btnBlack.IsChecked = true;
                }
                else if (theme == "silver")
                {
                    C1Theme.ApplyTheme(LayoutRoot, Offfice2010Themes.Silver);
                    btnSilver.IsChecked = true;
                }
            }
        }
    }


    // Helper class used to have singleton instances of each theme
    public static class Offfice2010Themes
    {
        public static C1Theme Default = new C1ThemeOffice2010Blue();
        public static C1Theme Silver = new C1ThemeOffice2010Silver();
        public static C1Theme Black = new C1ThemeOffice2010Black();
    }

}
