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.Extended;
using System.ComponentModel;
using System.Windows.Data;

namespace C1Extended_Demo
{
    public partial class HexColorEditor : UserControl, ITypeEditorControl
    {
        public HexColorEditor()
        {
            InitializeComponent();
        }

        #region ITypeEditorControl Members

        bool ITypeEditorControl.Supports(PropertyAttribute Property)
        {
            return Property.PropertyInfo.PropertyType == typeof(Color);
        }

        ITypeEditorControl ITypeEditorControl.Create()
        {
            return new HexColorEditor();
        }

          void ITypeEditorControl.Attach(PropertyAttribute property)
        {
            var binding = new Binding(property.PropertyInfo.Name)
            {
                Mode = BindingMode.TwoWay,
                Source = property.SelectedObject,
                ValidatesOnExceptions = true
            };
            hexBox.SetBinding(C1HexColorBox.ColorProperty, binding);
        }

        void ITypeEditorControl.Detach(PropertyAttribute property)
        {
        }

        public event PropertyChangedEventHandler ValueChanged;

        #endregion


    }
}
