public override string CreatePhpScript(StringCollection method) { if (!string.IsNullOrEmpty(_passinPhp)) { MathNode.Trace("MathNodeVariable.CreatePhpScript returns _passinPhp"); return(_passinPhp); } string code = this.MathExpression.GetMappedPhpScriptCode(this, method); if (code != null) { return(code); } //if this variable links to a method parameter then the code is a reference to that parameter if (this.InPort != null) { MathExpItem item = this.root.RootContainer.GetItemByID(this.InPort.LinkedPortID); if (item != null) { MathNode.Trace("variable:{0} linked to MathExpItem: {1}", this.TraceInfo, item.MathExpression.TraceInfo); return(item.CreatePhpScript(method)); } } if (!NoAutoDeclare) { DeclarePhpScriptVariable(method, this); } MathNode.Trace("MathNodeVariable.CreateJavaScript returns variable reference to {0}", this.CodeVariableName); return(this.CodeVariableName); }
public override CodeExpression ExportCode(IMethodCompile method) { CodeStatementCollection supprtStatements = method.MethodCode.Statements; if (_passin != null) { MathNode.Trace("MathNodeVariable.ExportCode returns _passin"); return(_passin); } CodeExpression code = this.MathExpression.GetMappedCode(this, method, supprtStatements, true); if (code != null) { return(code); } //if this variable links to a method parameter then the code is a reference to that parameter if (this.InPort != null) { MathExpItem item = this.root.RootContainer.GetItemByID(this.InPort.LinkedPortID); if (item != null) { MathNode.Trace("variable:{0} linked to MathExpItem: {1}", this.TraceInfo, item.MathExpression.TraceInfo); return(item.ReturnCodeExpression(method)); } } if (!NoAutoDeclare) { DeclareVariable(supprtStatements, this); } MathNode.Trace("MathNodeVariable.ExportCode returns variable reference to {0}", this.CodeVariableName); return(new CodeVariableReferenceExpression(this.CodeVariableName)); }
/// <summary> /// find linked node and use that node's code. /// if not found then use default value /// </summary> /// <returns></returns> public override System.CodeDom.CodeExpression ExportCode(IMethodCompile method) { MathNode.Trace("{0}.ExportCode", this.GetType().Name); if (this.InPort != null) { if (this.InPort.LinkedPortID != 0) { MathExpItem mathParent = root.ContainerMathItem; if (mathParent == null) { throw new MathException(XmlSerialization.FormatString("ExportCode for Default value: Linked port ID {0}. MathNodeRoot missing container.", this.InPort.LinkedPortID)); } if (mathParent.Parent == null) { throw new MathException(XmlSerialization.FormatString("ExportCode for Default value: Linked port ID {0}. MathExpItem missing container.", this.InPort.LinkedPortID)); } MathExpItem item = mathParent.Parent.GetItemByID(this.InPort.LinkedPortID); if (item == null) { throw new MathException(XmlSerialization.FormatString("ExportCode for Default value: Linked port ID {0} does not point to a valid port", this.InPort.LinkedPortID)); } return(item.ReturnCodeExpression(method)); } } return(ValueTypeUtil.GetDefaultValueByType(this.DataType.Type)); }
/// <summary> /// called when loading the group /// </summary> /// <param name="item"></param> public void ImportMathItem(MathExpItem item) { bLoading = true; this.Name = item.Name; this.Location = item.Location; this.Size = item.Size; this.mathExp = item.MathExpression; if (Site != null) { Site.Name = item.Name; } mathExp.GenerateInputVariables(); mathExp.PrepareDrawInDiagram(); if (OutputPorts != null) { for (int i = 0; i < OutputPorts.Length; i++) { OutputPorts[i].Owner = this; OutputPorts[i].Label.Visible = false; OutputPorts[i].RestoreLocation(); } } createImage(); bLoading = false; }
public override MathExpItem ExportMathItem(MathExpGroup group) { MathExpItem item = base.ExportMathItem(group); Parameter.Location = this.Location; item.MathExpression = this.Parameter; return(item); }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <returns></returns> public MathExpViewer LoadMathItem(MathExpItem item) { if (string.IsNullOrEmpty(item.Name)) { item.Name = this.CreateName("item"); } MathExpViewer v = AddEmptyMathExpViewer(); // v.ImportMathItem(item); return(v); }
public virtual MathExpItem ExportMathItem(MathExpGroup group) { MathExpItem item = new MathExpItem(group); if (Site != null) { item.Name = Site.Name; } else { item.Name = this.Name; } item.Location = this.Location; item.Size = this.Size; return(item); }
public MathExpItem ExportMathItem(MathExpGroup group) { MathExpItem item = new MathExpItem(group); if (Site != null) { item.Name = Site.Name; } else { item.Name = this.Name; } item.Location = this.Location; item.Size = this.Size; item.MathExpression = (IMathExpression)this.mathExp.Clone(); return(item); }
private void copyToClipboard() { if (selectionService.PrimarySelection != null) { MathExpViewer mv = selectionService.PrimarySelection as MathExpViewer; if (mv != null) { MathExpGroup mg = new MathExpGroup(); MathExpItem mi = mv.ExportMathItem(mg); XmlDocument doc = new XmlDocument(); XmlNode node = doc.CreateElement("MathExpression"); doc.AppendChild(node); mi.SaveToXmlNode(_writer, node); Clipboard.SetData("MathItem", doc.OuterXml); enablePaste(); } } }
public override CodeExpression ExportCode(IMethodCompile method) //) { CodeStatementCollection supprtStatements = method.MethodCode.Statements; if (this.UseDefaultValue) { if (_default == null) { MathNode.Trace("MathNodeParameter.ExportCode: Use default case 0:null"); return(ValueTypeUtil.GetDefaultCodeByType(this.DataType.Type)); } else { MathNode.Trace("MathNodeParameter.ExportCode: Use default case 1:{0}", _default); return(ObjectCreationCodeGen.ObjectCreationCode(_default)); } } else { if (this.InPort != null && this.InPort.LinkedPortID != 0) { MathNode.Trace("MathNodeParameter.ExportCode: call linked item"); IMathExpression rootContainer = this.root.RootContainer; if (rootContainer == null) { throw new MathException(XmlSerialization.FormatString("Parameter {0} not associated with a root container", this.TraceInfo)); } MathExpItem LinkedItem = rootContainer.GetItemByID(this.InPort.LinkedPortID); if (LinkedItem == null) { throw new MathException(string.Format("Linked Port ID {0} from ({1}) does not match an item", InPort.LinkedPortID, this.TraceInfo)); } CodeExpression ce = LinkedItem.ReturnCodeExpression(method); return(RaisDataType.GetConversionCode(LinkedItem.MathExpression.DataType, ce, this.DataType, supprtStatements)); } // MathNode.Trace("MathNodeParameter.ExportCode: call MathNodeVariable.ExportCode"); return(base.ExportCode(method)); } }
public override string CreateJavaScript(StringCollection method) { if (!string.IsNullOrEmpty(_passinJS)) { MathNode.Trace("MathNodeVariable.CreateJavaScript returns _passinJS"); return(_passinJS); } string code = this.MathExpression.GetMappedJavaScriptCode(this, method); if (code != null) { return(code); } //if this variable links to a method parameter then the code is a reference to that parameter if (this.InPort != null) { MathExpItem item = this.root.RootContainer.GetItemByID(this.InPort.LinkedPortID); if (item != null) { MathNode.Trace("variable:{0} linked to MathExpItem: {1}", this.TraceInfo, item.MathExpression.TraceInfo); return(item.CreatejavaScript(method)); } } if (!NoAutoDeclare) { if (string.IsNullOrEmpty(_value)) { DeclareJavaScriptVariable(method, this, null); } else { DeclareJavaScriptVariable(method, this, string.Format(CultureInfo.InvariantCulture, "'{0}'", _value.Replace("'", "\\'"))); } } MathNode.Trace("MathNodeVariable.CreateJavaScript returns variable reference to {0}", this.CodeVariableName); return(this.CodeVariableName); }
public void PasteFromClipboard() { if (Clipboard.ContainsData("MathItem")) { object data = Clipboard.GetData("MathItem"); if (data != null) { string s = data.ToString(); XmlDocument doc = new XmlDocument(); doc.LoadXml(s); if (doc.DocumentElement != null) { try { CreateUndoTransaction("PasteFromClipboard"); MathExpGroup mg = new MathExpGroup(); MathExpItem mi = new MathExpItem(mg); mi.ReadFromXmlNode(_reader, doc.DocumentElement); mi.Name = CreateName(XmlSerialization.XML_Math); mi.Location = new Point(mi.Location.X + 5, mi.Location.Y + 5); //re-arrange the ports mi.ReCreateDefaultPorts(); this.LoadMathItem(mi); //create controls, same as DiagramViewer.LoadGroup root.Controls.AddRange(mi.GetPortControls()); mi.CreateLinkLines(); CommitUndoTransaction("PasteFromClipboard"); } catch (Exception err) { MessageBox.Show(err.Message); RollbackUndoTransaction("PasteFromClipboard"); } } } } }