Beispiel #1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            object retvalue = value;

            try
            {
                IDesignerHost host             = (IDesignerHost)context.GetService(typeof(IDesignerHost));
                IWindowsFormsEditorService srv = (IWindowsFormsEditorService)context.GetService(typeof(IWindowsFormsEditorService));

                if (srv != null && host != null)
                {
                    DataUIMapper dm       = (DataUIMapper)context.Instance;
                    IDesigner    designer = host.GetDesigner(dm);

                    MappingsEditorForm form = new MappingsEditorForm(designer);
                    //form.SetMappings(dm.Mappings);

                    form.Host         = host;
                    form.DataUIMapper = dm;

                    //Show form.
                    if (srv.ShowDialog(form) == DialogResult.OK)
                    {
                        MapperInfoList mappings = form.GetMappings();
                        context.PropertyDescriptor.SetValue(context.Instance, mappings);

                        //if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        //{
                        //    MapperInfoList mappings = form.GetMappings();
                        //    context.PropertyDescriptor.SetValue(context.Instance, mappings);
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(
                    "��������ʱ�쳣: " + ex.ToString());
            }

            return(retvalue);
        }
Beispiel #2
0
        void OnEditMappings(object sender, EventArgs e)
        {
            try
            {
                MappingsEditorForm form = new MappingsEditorForm(this);
                form.SetMappings(CurrentMapper.Mappings);

                if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    MapperInfoList     mappings = form.GetMappings();
                    PropertyDescriptor prop     = TypeDescriptor.GetProperties(Component)["Mappings"];
                    prop.SetValue(Component, mappings);
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(
                    "´íÎó: " + ex.ToString());
            }
        }