using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
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 ReportServer
{
    public class DateEditor : DatePicker, ITypeEditorControl
    {
        public ITypeEditorControl Create()
        {
            return new DateEditor();
        }

        public bool Supports(PropertyAttribute Property)
        {
            return Property.PropertyInfo.PropertyType == typeof(DateTime);
        }

        public void Attach(PropertyAttribute property)
        {
            var binding = new Binding(property.PropertyInfo.Name)
            {
                Mode = BindingMode.TwoWay,
                Source = property.SelectedObject,
                ValidatesOnExceptions = true
            };
            SetBinding(DatePicker.SelectedDateProperty, binding);
        }

        public void Detach(PropertyAttribute property)
        {
        }

        public event PropertyChangedEventHandler ValueChanged;
    }
}
