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);
 }
コード例 #2
0
 /// <summary>
 /// edit this action
 /// </summary>
 /// <param name="exp"></param>
 private void showEditor(IMathExpression exp)
 {
     try
     {
         Rectangle     rc  = this.Parent.RectangleToScreen(this.Bounds);
         IMathEditor   dlg = exp.CreateEditor(rc);
         IMathDesigner md  = this.Parent as IMathDesigner;
         if (md.TestDisabled)
         {
             dlg.DisableTest();
         }
         if (((Form)dlg).ShowDialog(this.FindForm()) == DialogResult.OK)
         {
             setChanged();
         }
     }
     catch (Exception err)
     {
         MathNode.Log(this.FindForm(), err);
     }
 }
コード例 #3
0
        public bool Edit(XmlObjectWriter writer, IMethod context, Form caller, bool isNewAction)
        {
            IMathExpression mathExp = MathExp;

            if (mathExp != null)
            {
                ActionExecMath       a2       = (ActionExecMath)this.Clone();
                Rectangle            rc       = new Rectangle(0, 0, 100, 30);
                System.Drawing.Point curPoint = System.Windows.Forms.Cursor.Position;
                rc.X = curPoint.X;
                rc.Y = curPoint.Y;
                a2.MathExp.ScopeMethod = context;
                IMathEditor dlg = a2.MathExp.CreateEditor(rc);
                if (((Form)dlg).ShowDialog(caller) == DialogResult.OK)
                {
                    MathExpMethod mem = new MathExpMethod();
                    mem.Action         = this;
                    mem.MathExpression = dlg.MathExpression;
                    ActionMethod       = mem;
                    if (_class != null)
                    {
                        LimnorProject     project = _class.Project;
                        ILimnorDesignPane pane    = project.GetTypedData <ILimnorDesignPane>(_class.ClassId);
                        if (pane != null)
                        {
                            pane.OnActionChanged(_class.ClassId, this, isNewAction);
                            pane.OnNotifyChanges();
                        }
                        else
                        {
                            DesignUtil.WriteToOutputWindowAndLog("Error Editng ActionExecMath. ClassPointer [{0}] is not in design mode when creating an action. Please close the design pane and re-open it.", _class.ClassId);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
コード例 #4
0
 private void showEditor(IMathExpression exp)
 {
     try
     {
         Rectangle   rc  = this.Parent.RectangleToScreen(this.Bounds);
         IMathEditor dlg = exp.CreateEditor(rc);
         if (((Form)dlg).ShowDialog(this.FindForm()) == DialogResult.OK)
         {
             LoadData(dlg.MathExpression);
             //
             Refresh();
             if (this.Parent != null)
             {
                 ActiveDrawing.RefreshControl(this.Parent);
             }
             setChanged();
         }
     }
     catch (Exception err)
     {
         MathNode.Log(this.FindForm(), err);
     }
 }
 public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         ParameterValue pv = context.Instance as ParameterValue;
         if (pv == null)
         {
             MapItem item = context.Instance as MapItem;
             if (item != null)
             {
                 pv = item.Item.Value as ParameterValue;
             }
         }
         if (pv == null)
         {
             pv = value as ParameterValue;
         }
         if (pv != null)
         {
             IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
             if (edSvc != null)
             {
                 IMathExpression mew = value as IMathExpression;
                 if (mew == null)
                 {
                     mew = pv.MathExpression;
                     if (mew == null)
                     {
                         MathNodeRoot r = new MathNodeRoot();
                         r.Name = pv.Name;
                         mew    = r;
                     }
                 }
                 System.Drawing.Point curPoint = System.Windows.Forms.Cursor.Position;
                 rc.X = curPoint.X;
                 rc.Y = curPoint.Y;
                 IMathEditor dlg = mew.CreateEditor(rc);
                 //
                 MathPropertyGrid pg   = null;
                 Type             t    = edSvc.GetType();
                 PropertyInfo     pif0 = t.GetProperty("OwnerGrid");
                 if (pif0 != null)
                 {
                     object g = pif0.GetValue(edSvc, null);
                     pg = g as MathPropertyGrid;
                 }
                 IMethod imScope = pv.ScopeMethod;
                 if (imScope == null)
                 {
                     imScope = mew.ScopeMethod;
                     if (imScope == null)
                     {
                         if (pg != null)
                         {
                             imScope = pg.ScopeMethod;
                         }
                     }
                 }
                 //
                 dlg.ActionContext = pv.ActionContext;
                 dlg.SetScopeMethod(imScope);
                 dlg.VariableMapTargetType      = typeof(ParameterValue);
                 dlg.MathExpression             = (IMathExpression)mew.Clone();
                 dlg.MathExpression.ScopeMethod = imScope;
                 dlg.MathExpression.EnableUndo  = true;
                 if (edSvc.ShowDialog((Form)dlg) == DialogResult.OK)
                 {
                     mew = dlg.MathExpression;
                     if (value != pv)
                     {
                         value = mew;
                         pv.SetValue(value);
                     }
                     else
                     {
                         pv.SetValue(mew);
                     }
                     if (pg != null)
                     {
                         pg.OnValueChanged(mew, EventArgs.Empty);
                     }
                 }
             }
         }
     }
     return(value);
 }
コード例 #6
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && provider != null && context.Instance != null)
     {
         MathematicExpression me = context.Instance as MathematicExpression;
         if (me != null)
         {
             IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
             if (edSvc != null)
             {
                 Point curPoint = System.Windows.Forms.Cursor.Position;
                 rc.X = curPoint.X;
                 rc.Y = curPoint.Y;
                 MathExpEditor.ExcludeProjectItem = true;
                 IMathEditor dlg = me.CreateEditor(rc);
                 MathExpEditor.ExcludeProjectItem = false;
                 MathNodeRoot r = new MathNodeRoot();
                 r.SetWriter(me.GetWriter());
                 r.SetReader(me.GetReader());
                 try
                 {
                     XmlDocument doc = new XmlDocument();
                     doc.LoadXml(me.Formula.Xml);
                     if (doc.DocumentElement != null)
                     {
                         r.Load(doc.DocumentElement);
                     }
                 }
                 catch
                 {
                 }
                 dlg.MathExpression            = r;
                 dlg.MathExpression.EnableUndo = true;
                 try
                 {
                     if (edSvc.ShowDialog((Form)dlg) == DialogResult.OK)
                     {
                         r = (MathNodeRoot)dlg.MathExpression;
                         r.FindAllInputVariables();
                         XmlDocument doc      = new XmlDocument();
                         XmlNode     rootNode = doc.CreateElement(MathematicExpression.XML_Root);
                         doc.AppendChild(rootNode);
                         r.SetWriter(me.GetWriter());
                         r.SetReader(me.GetReader());
                         r.Save(rootNode);
                         value = new FormulaProperty(doc.OuterXml);
                         PropertyGrid pg   = null;
                         Type         t    = edSvc.GetType();
                         PropertyInfo pif0 = t.GetProperty("OwnerGrid");
                         if (pif0 != null)
                         {
                             object g = pif0.GetValue(edSvc, null);
                             pg = g as PropertyGrid;
                             if (pg != null)
                             {
                                 me.SetPropertyGrid(pg);
                             }
                         }
                     }
                 }
                 catch (Exception err2)
                 {
                     MessageBox.Show(MathException.FormExceptionText(null, err2), "Math Expression Editor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
     }
     return(value);
 }
 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)
         {
             PropertiesWrapper pw = context.Instance as PropertiesWrapper;
             AB_SingleAction   sa = null;
             if (pw != null)
             {
                 sa = pw.Owner as AB_SingleAction;
             }
             ActionClass a = context.Instance as ActionClass;
             if (a == null)
             {
                 if (sa != null)
                 {
                     a = sa.ActionData as ActionClass;
                 }
             }
             ExpressionValue ev = (ExpressionValue)value;
             if (ev == null)
             {
                 ev = new ExpressionValue();
             }
             MathNodeRoot root = ev.GetExpression();
             if (root == null)
             {
                 root = new MathNodeRoot();
                 ev.SetExpression(root);
             }
             if (root.ScopeMethod == null)
             {
                 if (a != null)
                 {
                     if (a.ScopeMethod == null && sa != null)
                     {
                         a.ScopeMethod = sa.Method;
                     }
                     root.ScopeMethod = a.ScopeMethod;
                 }
                 else if (sa != null)
                 {
                     if (sa.ActionData != null && sa.ActionData.ScopeMethod != null)
                     {
                         root.ScopeMethod = sa.ActionData.ScopeMethod;
                     }
                 }
             }
             if (root.ActionContext == null)
             {
                 if (a != null)
                 {
                     root.ActionContext = a;
                 }
                 else if (sa != null)
                 {
                     root.ActionContext = sa;
                 }
             }
             System.Drawing.Point curPoint = System.Windows.Forms.Cursor.Position;
             rc.X = curPoint.X;
             rc.Y = curPoint.Y;
             IMathEditor dlg = root.CreateEditor(rc);
             if (a != null)
             {
                 dlg.ActionContext = a;
             }
             dlg.SetScopeMethod(root.ScopeMethod);
             dlg.VariableMapTargetType      = typeof(ParameterValue);
             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 ExpressionValue();
                 ev.SetExpression(root);
                 value = ev;
             }
         }
     }
     return(value);
 }