using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Threading;
using System.Windows.Media;
using Telerik.Windows.Controls;

namespace AgApp
{
	public partial class PageTestCombo : UserControl
	{
		public PageTestCombo()
		{
			StyleManager.ApplicationTheme = null;
			//LocalizationManager.Manager = null;
			//=================================================================
			//Theme cutomTheme = new Theme(new Uri("/MyCustomThemeAssembly;component/Themes/generic.xaml", UriKind.Relative));
			//cutomTheme.IsApplicationTheme = true; 
			switch (PageIndex.theme)
			{
				case PageIndex.ChosenTheme.Vista:
					StyleManager.ApplicationTheme = ThemeManager.FromName("Vista"); 
					break;
				case PageIndex.ChosenTheme.Summer:
					StyleManager.ApplicationTheme = ThemeManager.FromName("Summer");
					break;
				default:
				case PageIndex.ChosenTheme.OfficeBlack:
					StyleManager.ApplicationTheme = ThemeManager.FromName("Office_Black");
					break;
			}
			//=================================================================
			//switch (PageIndex.localizationManager)
			//{
			//    case PageIndex.ChosenLocalizationManager.ResourceDef:
			//        LocalizationManager.Manager = new LocalizationManager()
			//            {
			//                ResourceManager = AgApp.Properties.Resources.ResourceManager,
			//                Culture = null
			//            };
			//        break;
			//    case PageIndex.ChosenLocalizationManager.ResourceDE:
			//        LocalizationManager.Manager = new LocalizationManager()
			//            {
			//                ResourceManager = AgApp.Properties.Resources.ResourceManager,
			//                Culture = new CultureInfo("de")
			//            };
			//        break;
			//    case PageIndex.ChosenLocalizationManager.ResourceJP:
			//        LocalizationManager.Manager = new LocalizationManager()
			//            {
			//                ResourceManager = AgApp.Properties.JapaneseMe.ResourceManager,
			//                Culture = null
			//            };
			//        break;
			//    case PageIndex.ChosenLocalizationManager.GetStringOverride:
			//        LocalizationManager.Manager = new MyLocalizationManager();
			//        break;
			//}
			//=================================================================
			InitializeComponent();
		}

		private void breakMe_Click(object sender, System.Windows.RoutedEventArgs e)
		{
		}

		private void NavigateToIndex(object sender, EventArgs e)
		{
			NavigationHelper.LoadPageIndex();
		}

		private void MyPanel_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
		{
			MyPanel panel = sender as MyPanel;
			if (panel != null && panel.Children.Count > 0)
			{
				Control control = panel.Children[0] as Control;
				if (control != null)
				{
					control.Width = panel.ActualWidth;
					control.Height = panel.ActualHeight;
				}
			}
		}

		private void RadColorPicker_SelectedColorChanged(object sender, EventArgs e)
		{
			if (this.textBox != null)
			{
				this.textBox.Foreground = new SolidColorBrush((sender as RadColorPicker).SelectedColor);
			}
		}

		private void RadColorPicker_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
		{
			if (this.textBox != null)
			{
				this.textBox.Foreground = new SolidColorBrush((sender as RadColorPicker).SelectedColor);
			}
		}

		private void RadColorPicker_Click(object sender, EventArgs e)
		{
			if (this.textBox != null)
			{
				this.textBox.Foreground = new SolidColorBrush((sender as RadColorPicker).SelectedColor);
			}
		}

		private void ColorSelector_SelectedColorChanged(object sender, EventArgs e)
		{
			this.textBox.Foreground = new SolidColorBrush((sender as RadColorSelector).SelectedColor);
		}

		private void ModifySelector(RadColorSelector selector, string content, Visibility state)
		{
			if (selector != null)
			{
				switch (content)
				{
					case "Standard Palette":
						selector.StandardPaletteVisibility = state;
						break;
					case "Header Palette":
						selector.HeaderPaletteVisibility = state;
						break;
					case "Show Empty Color":
						selector.NoColorVisibility = state;
						break;
					default:
						selector.NoColorVisibility = state;
						break;
				}
			}
		}

		private void CheckBox_Checked(object sender, RoutedEventArgs e)
		{
			CheckBox checkBox = sender as CheckBox;
			string content = checkBox.Content.ToString();
			//this.ModifySelector(this.colorSelector1, content, Visibility.Visible);
			this.ModifySelector(this.colorSelector2, content, Visibility.Visible);
		}

		private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
		{
			CheckBox checkBox = sender as CheckBox;
			string content = checkBox.Content.ToString();
			//this.ModifySelector(this.colorSelector1, content, Visibility.Collapsed);
			this.ModifySelector(this.colorSelector2, content, Visibility.Collapsed);
		}
	}
}
