public void CreateViewer(MathNodeRoot item)
        {
            MathExpViewer mv = holder.AddMathViewer(item, 50, 50);
            ReturnIcon    ri = holder.CreateReturnIcon(item.DataType);

            LinkLineNode.JoinToEnd((LinkLineNode)mv.OutputPorts[0].NextNode, ri.InPort);
        }
 protected override void OnSave(XmlNode node)
 {
     if (_methodPointer != null)
     {
         MathNodeRoot r = this.root;
         if (r != null)
         {
             XmlObjectWriter xw = r.Writer as XmlObjectWriter;
             if (xw != null)
             {
                 XmlNode nodeMethod = node.SelectSingleNode(XmlSerialization.XML_METHOD);
                 if (nodeMethod == null)
                 {
                     nodeMethod = node.OwnerDocument.CreateElement(XmlSerialization.XML_METHOD);
                     node.AppendChild(nodeMethod);
                 }
                 xw.WriteObjectToNode(nodeMethod, _methodPointer);
                 XmlUtil.SetAttribute(nodeMethod, XmlTags.XMLATT_NodeId, ID);
             }
             else
             {
                 throw new DesignerException("Writer not available calling MathNodeMethodPointer.OnSave");
             }
         }
     }
 }
        public ReturnIcon(RaisDataType dataType)
        {
            Location = new Point(300, 300);
            SaveLocation();
            this.Size = new Size(32, 32);
            System.Drawing.ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(this.GetType())[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute;
            if (tba != null)
            {
                bmp = (System.Drawing.Bitmap)tba.GetImage(this.GetType());
            }
            MathNodeRoot root = new MathNodeRoot();

            root.IsVariableHolder = true;
            var     = new MathNodeVariableDummy(root);
            root[0] = var;
            if (dataType != null)
            {
                var.VariableType = dataType;
                var.TypeDefined  = true;
            }
            LinkLineNodeInPort port = new LinkLineNodeInPort(var);

            port.ClearLine();
            port.SetPrevious(null);
            port.Owner = this;
            port.HideLabel();
            var.InPort         = port;
            port.Owner         = this;
            port.Label.Visible = false;
            port.Location      = new Point(this.Left + this.Width / 2 - port.Width / 2, this.Top - port.Height);
            port.SaveLocation();
        }
 public static bool ActionUseInput(IAction a)
 {
     if (a != null)
     {
         List <ParameterValue> pvs = a.ParameterValues;
         if (pvs != null && pvs.Count > 0)
         {
             foreach (ParameterValue p in pvs)
             {
                 if (p.ValueType == EnumValueType.MathExpression)
                 {
                     MathNodeRoot mr = p.MathExpression as MathNodeRoot;
                     if (mr != null)
                     {
                         return(mr.UseInput);
                     }
                 }
                 else if (p.ValueType == EnumValueType.Property)
                 {
                     ActionInput ai = p.Property as ActionInput;
                     if (ai != null)
                     {
                         return(true);
                     }
                 }
             }
         }
     }
     return(false);
 }
 public static void ActionSetInputName(IAction a, string name, DataTypePointer type)
 {
     if (a != null)
     {
         if (a.ActionCondition != null)
         {
             a.ActionCondition.SetActionInputName(name, type.BaseClassType);
         }
         List <ParameterValue> pvs = a.ParameterValues;
         if (pvs != null && pvs.Count > 0)
         {
             foreach (ParameterValue p in pvs)
             {
                 if (p.ValueType == EnumValueType.MathExpression)
                 {
                     MathNodeRoot mr = p.MathExpression as MathNodeRoot;
                     if (mr != null)
                     {
                         mr.SetActionInputName(name, type.BaseClassType);
                     }
                 }
                 else if (p.ValueType == EnumValueType.Property)
                 {
                     ActionInput ai = p.Property as ActionInput;
                     if (ai != null)
                     {
                         ai.SetActionInputName(name, type);
                     }
                 }
             }
         }
     }
 }
Beispiel #6
0
        public override void OnDoubleClick(Control host)
        {
            Form f = host.FindForm();

            host.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            if (f != null)
            {
                f.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            }
            IObjectPointer pp     = _valuePointer;
            IMethod        method = null;
            MathNodeRoot   r      = this.root;

            if (r != null)
            {
                method = r.ScopeMethod;
            }
            FrmObjectExplorer dlg = DesignUtil.GetPropertySelector(pp, method, null);

            if (dlg != null)
            {
                if (dlg.ShowDialog(f) == DialogResult.OK)
                {
                    _valuePointer = dlg.SelectedObject as IObjectPointer;
                    host.Invalidate();
                }
            }
            host.Cursor = System.Windows.Forms.Cursors.Default;
            if (f != null)
            {
                f.Cursor = System.Windows.Forms.Cursors.Default;
            }
        }
 public static void ActionFindItemByType <T>(IAction a, List <T> results)
 {
     if (a != null)
     {
         List <ParameterValue> pvs = a.ParameterValues;
         if (pvs != null && pvs.Count > 0)
         {
             foreach (ParameterValue p in pvs)
             {
                 if (p.ValueType == EnumValueType.MathExpression)
                 {
                     MathNodeRoot mr = p.MathExpression as MathNodeRoot;
                     if (mr != null)
                     {
                         mr.FindItemByType <T>(results);
                     }
                 }
                 else if (p.ValueType == EnumValueType.Property)
                 {
                     object v = p.Property;
                     if (v is T)
                     {
                         results.Add((T)v);
                     }
                 }
             }
         }
     }
 }
Beispiel #8
0
 public void SetVariable(IVariable variable)
 {
     if (variable == null)
     {
         throw new MathException("variable cannot be null");
     }
     var = variable;
     if (variable is MathNode)
     {
         root = ((MathNode)variable).root;
     }
     if (root == null)
     {
         //create a root for drawing the variable
         root = new MathNodeRoot();
         if (var is MathNode)
         {
             root[0] = (MathNode)var;
             ((MathNode)var).IsFocused = false;
         }
         else
         {
         }
         root.SetFont(this.Font);
     }
 }
 public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (service != null)
         {
             IWithProject mc = context.Instance as IWithProject;
             if (mc == null)
             {
                 MathNode.Log(new DesignerException("{0} does not implement IWithProject", context.Instance.GetType()));
             }
             else
             {
                 if (mc.Project == null)
                 {
                     MathNode.Log(new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType()));
                 }
                 else
                 {
                     Rectangle       rc = new Rectangle(System.Windows.Forms.Cursor.Position, new Size(20, 60));
                     IMathExpression im = value as IMathExpression;
                     if (im == null)
                     {
                         im = new MathNodeRoot();
                     }
                 }
             }
         }
     }
     return(value);
 }
        public override void OnReadFromXmlNode(IXmlCodeReader serializer, XmlNode node)
        {
            base.OnReadFromXmlNode(serializer, node);
            XmlNode nd = node.SelectSingleNode(XML_VAR);

            if (nd != null)
            {
                MathNodeRoot root = new MathNodeRoot();
                root.IsVariableHolder = true;
                root[0] = var;
                var.Load(nd);
                if (var.InPort != null)
                {
                    var.InPort.Owner         = this;
                    var.InPort.Label.Visible = false;
                }
                if (var.OutPorts != null)
                {
                    LinkLineNodeOutPort[] o = var.OutPorts;
                    for (int i = 0; i < o.Length; i++)
                    {
                        o[i].Owner = this;
                    }
                }
            }
            this.Size = new Size(32, 32);
        }
Beispiel #11
0
 public DrawingVariable(Control owner)
     : base(owner)
 {
     root             = new MathNodeRoot();
     var              = (IVariable)root[0];
     this.Size        = new Size(20, 20);
     RelativePosition = new RelativePosition(this, -20, -20, true, true);
 }
 public void Add(MathNodeRoot condition, ActionList act)
 {
     if (_decisionTable == null)
     {
         _decisionTable = new List <DecisionItem>();
     }
     _decisionTable.Add(new DecisionItem(condition, act));
 }
Beispiel #13
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            MathNodeRoot r = new MathNodeRoot();

            r.Project     = _prj;
            r.ScopeMethod = _method;
            _dataTable.Rows.Add(r, null);
        }
            public override void SetValue(object component, object value)
            {
                MathNodeRoot r = value as MathNodeRoot;

                if (r != null)
                {
                    _owner.Condition = r;
                }
            }
 public virtual void OnReadFromXmlNode(IXmlCodeReader reader, XmlNode node)
 {
     _exp     = new MathNodeRoot();
     _hasData = XmlUtil.GetAttributeBoolDefFalse(node, XMLATT_HasData);
     if (_hasData)
     {
         _exp.OnReadFromXmlNode(reader, node);
     }
 }
        public override void FindItemByType <T>(List <T> results)
        {
            MathNodeRoot r = RepeatCount.MathExpression as MathNodeRoot;

            if (r != null)
            {
                r.FindItemByType <T>(results);
            }
            base.FindItemByType <T>(results);
        }
 /// <summary>
 /// set the input variable name to all input variables
 /// </summary>
 /// <param name="name"></param>
 public override void SetInputName(string name, DataTypePointer type)
 {
     if (RepeatCount.MathExpression != null)
     {
         MathNodeRoot r = RepeatCount.MathExpression as MathNodeRoot;
         if (r != null)
         {
             r.SetActionInputName(name, type.BaseClassType);
         }
     }
     base.SetInputName(name, type);
 }
Beispiel #18
0
        public override object Clone()
        {
            DrawingVariable clone = (DrawingVariable)base.Clone();

            clone.LabelVisible = _labelVisible;
            if (root != null)
            {
                MathNodeRoot r = (MathNodeRoot)root.Clone();
                clone.SetDrawingAttributes(r);
            }
            return(clone);
        }
Beispiel #19
0
 // Overrides the ConvertFrom method of TypeConverter.
 public override object ConvertFrom(ITypeDescriptorContext context,
                                    CultureInfo culture, object value)
 {
     if (value is string)
     {
         MathNodeRoot        r  = new MathNodeRoot();
         MathNodeStringValue mv = new MathNodeStringValue(r);
         mv.Value = (string)value;
         r[1]     = mv;
         return(r);
     }
     return(base.ConvertFrom(context, culture, value));
 }
        public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection ps = TypeDescriptor.GetProperties(this, attributes, true);

            if (VPLUtil.GetBrowseableProperties(attributes))
            {
                MathNodeRoot mr = MathExp as MathNodeRoot;
                if (mr != null)
                {
                }
            }
            return(ps);
        }
 public override void SetOwnerMethod(List <UInt32> used, MethodClass m)
 {
     base.SetOwnerMethod(used, m);
     RepeatCount.ScopeMethod = m;
     if (RepeatCount.MathExpression != null)
     {
         MathNodeRoot r = RepeatCount.MathExpression as MathNodeRoot;
         if (r != null)
         {
             r.Project = m.Project;
         }
     }
 }
Beispiel #22
0
        public override void SetFunction(object func)
        {
            MathNodeRoot math = func as MathNodeRoot;

            if (math != null)
            {
                MathNodeMethodInvoke mi = math[1] as MathNodeMethodInvoke;
                if (mi != null)
                {
                    this.MethodReference = mi.MethodReference;
                }
            }
        }
        public override void Execute(List <ParameterClass> eventParameters)
        {
            CompileResult cr = null;
            int           i  = 0;

            while (true)
            {
                if (RepeatCount.ValueType == EnumValueType.ConstantValue)
                {
                    if (i < (int)RepeatCount.ConstantValue.GetValue(ConstObjectPointer.VALUE_Value))
                    {
                        break;
                    }
                }
                else if (RepeatCount.ValueType == EnumValueType.MathExpression)
                {
                    MathNodeRoot r = RepeatCount.MathExpression as MathNodeRoot;
                    if (r == null)
                    {
                        break;
                    }
                    else
                    {
                        cr = r.DebugCompileUnit;
                        cr.Execute();
                        if (!Convert.ToBoolean(cr.ReturnValue))
                        {
                            break;
                        }
                    }
                }
                else
                {
                    IObjectPointer p = RepeatCount.Property;
                    if (p == null)
                    {
                        break;
                    }
                    if (p.ObjectInstance == null)
                    {
                        break;
                    }
                    if (i < (int)(p.ObjectInstance))
                    {
                        break;
                    }
                }
                ExecuteActions(eventParameters);
                i++;
            }
        }
        public override object Clone()
        {
            ReturnIcon obj = (ReturnIcon)base.Clone();

            if (bmp != null)
            {
                obj.SetBmp((Bitmap)bmp.Clone());
            }
            MathNodeRoot root = (MathNodeRoot)var.root.Clone();

            obj.SetVar((MathNodeVariableDummy)root[0]);
            obj.TypeDefined = this.TypeDefined;
            return(obj);
        }
 public MathExpCtrl()
 {
     pen           = new Pen(Color.Black, 1);
     pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
     InitializeComponent();
     _lblForScroll = new Label();
     this.Controls.Add(_lblForScroll);
     _lblForScroll.BorderStyle = BorderStyle.None;
     _lblForScroll.Text        = "";
     _lblForScroll.Size        = new Size(1, 1);
     _lblForScroll.Location    = new Point(0, 0);
     mathExp          = new MathNodeRoot();
     mathExp.Position = new Point(8, 8);
     initMathExp();
     //
 }
 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);
 }
Beispiel #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="MathExpression"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public MathExpViewer AddMathViewer(MathNodeRoot MathExpression, int x, int y)
        {
            string        name = CreateName(XmlSerialization.XML_Math);
            IDesignerHost host = (IDesignerHost)dsf.GetService(typeof(IDesignerHost));
            MathExpViewer v    = (MathExpViewer)host.CreateComponent(typeof(MathExpViewer));

            root.Controls.Add(v);
            v.Visible  = true;
            v.Location = new Point(x, y);
            //
            v.LoadData((MathNodeRoot)MathExpression.Clone());
            //
            v.Name      = name;
            v.Site.Name = v.Name;
            propertyGrid1.SelectedObject = v;
            root.Refresh();
            root.Changed = true;
            return(v);
        }
        protected void SaveVariable(XmlNode node)
        {
            MathNodeVariable v = Variable as MathNodeVariable;
            MathNodeRoot     r = v.Parent as MathNodeRoot;

            XmlSerialization.WriteValueToChildNode(node, "Font", r.TextFont);
            XmlNode nd = node.SelectSingleNode("Var");

            if (nd == null)
            {
                nd = node.OwnerDocument.CreateElement("Var");
                node.AppendChild(nd);
            }
            else
            {
                nd.RemoveAll();
            }
            v.Save(nd);
        }
        public VariableMap CloneExp(MathNodeRoot root)
        {
            VariableList vlist = root.FindAllInputVariables();
            VariableMap  obj   = new VariableMap();

            foreach (KeyValuePair <IVariable, ICompileableItem> kv in this)
            {
                IVariable v = vlist.FindMatchingPublicVariable(kv.Key);
                if (v == null)
                {
                    throw new MathException("Variable not found for {0}", kv.Key);
                }
                //at this time, assume the root alread get the right clone owner
                kv.Value.SetCloneOwner(root.ActionContext);
                ICompileableItem item = (ICompileableItem)kv.Value.Clone();
                obj.Add(v, item);
            }
            return(obj);
        }
        public override object Clone()
        {
            Parameter p = (Parameter)base.Clone();

            p.Method    = this.Method;
            p.Fixed     = Fixed;
            p.TextFont  = TextFont;
            p.TextColor = TextColor;
            p.Location  = Location;
            p.TransferLocalService(_localServices);
            MathNodeRoot     r  = Variable.MathExpression;
            MathNodeRoot     r0 = (MathNodeRoot)r.Clone();
            MathNodeVariable v  = r0[0] as MathNodeVariable;

            p.SetCodeVariable(v);
            if (_castTo != null)
            {
                p.ProgEntity = (ProgramEntity)_castTo.Clone();
            }
            return(p);
        }