Beispiel #1
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (null != context && null != context.Instance && null != context.Container)
            {
                IElement element = context.Instance as IElement;
                if (null != element)
                {
                    if (element is IExpression || element is IVisibleExpression)
                    {
                        SourceField sf = GetSourceField(element);
                        string      ep = null;
                        if (element is IExpression)
                        {
                            ep = ((IExpression)element).Expression;
                        }
                        else
                        {
                            ep = ((IVisibleExpression)element).VisibleExpression;
                        }

                        using (MES.Report.MESReportExpressionEditor expEditor = new MES.Report.MESReportExpressionEditor(ep))
                        {
                            expEditor.ControlName = element.Name;
                            if (expEditor.ShowDialog() == DialogResult.OK)
                            {
                                return(expEditor.ExpressionText);
                            }
                        }
                    }
                }
            }
            return(base.EditValue(context, provider, value));
        }
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            if (null == context || null == context.Instance)
            {
                try
                {
                    return(Convert.ToString(value));
                }
                catch
                {
                    return("");
                }
            }
            string str = string.Empty;

            str = Convert.ToString(value);
            MES.Report.MESReportExpressionEditor expEditor = new MES.Report.MESReportExpressionEditor();
            if (expEditor.CheckExpr(str))
            {
                //异常直接抛出,谈MessageBox会导致
                //被执行两次
                return(str);
            }
            else
            {
                throw new Exception("表达式非法");
            }
        }
Beispiel #3
0
 private void FunctionAction()
 {
     using (MES.Report.MESReportExpressionEditor expEditor = new MES.Report.MESReportExpressionEditor(VisibleExpression))
     {
         expEditor.ControlName = Name;
         if (expEditor.ShowDialog() == DialogResult.OK)
         {
             VisibleExpression = expEditor.ExpressionText;
             NotifyDesignSurfaceChange();
         }
     }
 }