public override object GetValue(object component)
            {
                FieldCalculatorCollection fieldEditors = component as FieldCalculatorCollection;

                if (fieldEditors != null && fieldEditors.Fields != null)
                {
                    EPField fld = fieldEditors.Fields[Name];
                    if (fld != null)
                    {
                        return(fld.calculator);
                    }
                }
                return(null);
            }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (edSvc != null)
         {
             FieldCalculatorCollection calculators = context.Instance as FieldCalculatorCollection;
             if (calculators != null)
             {
                 FieldCalculator ev = (FieldCalculator)value;
                 if (ev == null)
                 {
                     ev           = new FieldCalculator();
                     ev.FieldName = context.PropertyDescriptor.Name;
                 }
                 MathNodeRoot root = ev.GetExpression();
                 if (root == null)
                 {
                     root = new MathNodeRoot();
                     ev.SetExpression(root);
                 }
                 System.Drawing.Point curPoint = System.Windows.Forms.Cursor.Position;
                 rc.X = curPoint.X;
                 rc.Y = curPoint.Y;
                 IMathEditor dlg = root.CreateEditor(rc);
                 dlg.SetScopeMethod(root.ScopeMethod);
                 dlg.MathExpression             = (IMathExpression)root.Clone();
                 dlg.MathExpression.ScopeMethod = root.ScopeMethod;
                 dlg.MathExpression.EnableUndo  = true;
                 if (edSvc.ShowDialog((Form)dlg) == DialogResult.OK)
                 {
                     root = (MathNodeRoot)dlg.MathExpression;
                     ev   = new FieldCalculator();
                     ev.SetExpression(root);
                     ev.FieldName = context.PropertyDescriptor.Name;
                     value        = ev;
                     calculators.SetItem(ev);
                 }
             }
         }
     }
     return(value);
 }