using PCHMI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing.Design;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms.Design;

namespace CowainHmi.UIEditor
{
    public class UIPlcDataEdit : UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService windowsFormsEditorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (windowsFormsEditorService != null)
            {
                FrmPlcDataTable frmPlcDataTable = new FrmPlcDataTable((string)value);
                frmPlcDataTable.ShowDialog();
                if (frmPlcDataTable.IsSaved)
                {
                    return frmPlcDataTable.SaveData;
                }
            }
            return value;
        }
    }
}
