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;

namespace RichTextBoxSamples
{
    public partial class MainPage : UserControl
    {
        SolidColorBrush _whiteBrush = new SolidColorBrush(Colors.White);

        public MainPage()
        {
            InitializeComponent();

            iDemoRichTextBox.Tag = new DemoRichTextBox();
            iAsYouTypeSpellCheck.Tag = new AsYouTypeSpellCheck();
            iDemoRichTextBoxFilter.Tag = new DemoRichTextBoxFilter();
            customContextMenu.Tag = new CustomContextMenu();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            iDemoRichTextBox.IsSelected = true;
        }

        private void tv_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            UIElement child = null;
            C1TreeView tv = sender as C1TreeView;
            if (tv != null)
            {
                C1TreeViewItem tvi = tv.SelectedItem;
                if (tvi != null && tvi.Tag is UserControl)
                {
                    ((UserControl)tvi.Tag).Foreground = _whiteBrush;
                    child = (UserControl)tvi.Tag;
                }
            }
            bdr.Child = child;
        }
    }

    public class ControlNode : C1TreeViewItem
    {
        public ControlNode()
        {
            DefaultStyleKey = typeof(ControlNode);
            Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0x92, 0xc8, 0xd8));
        }
    }
}