namespace PerpetuumSoft.Widgets
{
    using System;
    using System.ComponentModel;
    using System.Drawing.Design;
    using System.Windows.Forms.Design;

    internal class AboutEditor : UITypeEditor
    {
        private IWindowsFormsEditorService edSvc = null;

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (((context != null) && (context.get_Instance() != null)) && (provider != null))
            {
                this.edSvc = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService));
                if (this.edSvc != null)
                {
                    AboutForm form = new AboutForm();
                    this.edSvc.ShowDialog(form);
                    form.Dispose();
                }
            }
            return null;
        }

        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            if ((context != null) && (context.get_Instance() != null))
            {
                return 2;
            }
            return base.GetEditStyle(context);
        }
    }
}
