using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Design;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Globalization;

namespace DXGfxLib
{
    public class FileNameEditor : UITypeEditor
    {
        Object instance = null;
        FileNameUIEditor edtCtrl = null;

        //public override bool GetPaintValueSupported(ITypeDescriptorContext context)
        //{
        //    instance = context.Instance;

        //    edtCtrl = new FileNameUIEditor(instance as string);
        //    return true;
        //}

        //public override void PaintValue(PaintValueEventArgs e)
        //{
        //    edtCtrl.SetBounds(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height);
        //    edtCtrl.Update();
        //    base.PaintValue(e);
        //}

        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edtService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            edtCtrl = new FileNameUIEditor(value as string);

            edtCtrl.Execute();

            return edtCtrl.associatedFileName;
        }
    }
}
