protected override void OnSave(XmlNode node) { if (_valuePointer != null) { XmlObjectWriter xw = this.root.Serializer as XmlObjectWriter; if (xw != null) { // try // { // ObjectIDmap map = (ObjectIDmap)MathNode.GetService(typeof(ObjectIDmap)); // XmlObjectWriter xw = new XmlObjectWriter(map); XmlNode nd = node.OwnerDocument.CreateElement(XmlTags.XML_Property); node.AppendChild(nd); xw.WriteObjectToNode(nd, _valuePointer); // if (xw.HasErrors) // { // MathNode.Log(xw.ErrorCollection); // } // } // catch (Exception e) // { // MathNode.Log(e); } } }
public void OnBeforeWrite(XmlObjectWriter writer, XmlNode node) { _writer = writer; if (_xmlNodeChanged != node) { _xmlNode = node; } }
protected override void OnSave(XmlNode node) { XmlObjectWriter xw = this.root.Writer as XmlObjectWriter; if (xw != null) { OnWriteToXmlNode(xw, node); } }
private void saveCustomPropertyValue(XmlObjectWriter writer, PropertyClassDescriptor p, XmlNode rootNode) { XmlNode node = getClassRefNode(rootNode); XmlNode nodeProp = getPropertyNode(node, p.Name); if (p.CustomProperty.PropertyType.IsLibType) { DesignerSerializationVisibilityAttribute visibility = (DesignerSerializationVisibilityAttribute)p.Attributes[typeof(DesignerSerializationVisibilityAttribute)]; writer.WriteProperty(p, nodeProp, this, visibility.Visibility, XmlTags.XML_PROPERTY); } }
public void OnWriteToXmlNode(IXmlCodeWriter writer0, XmlNode node) { XmlObjectWriter writer = (XmlObjectWriter)writer0; UInt32 methodClassId = _method.Owner.RootPointer.ClassId; XmlUtil.SetAttribute(node, XmlTags.XMLATT_MethodID, MemberId); if (methodClassId != writer.ObjectList.ClassId) { XmlUtil.SetAttribute(node, XmlTags.XMLATT_ownerClassID, methodClassId); } //_holder:LocalVariable -- inside a methd:MemberId = variable id //_holder:ClassPointer -- on the top level //_holder:ClassInstancePointer -- member of the parent level, identified by MemberId LocalVariable var = Holder as LocalVariable; if (var != null) { XmlUtil.SetAttribute(node, XmlTags.XMLATT_varId, Holder.MemberId); } else { ClassInstancePointer cp = _holder as ClassInstancePointer; if (cp != null) { XmlNode nd = XmlUtil.CreateSingleNewElement(node, XmlTags.XML_ClassInstance); cp.OnPostSerialize(writer.ObjectList, nd, true, writer); } else { MemberComponentIdCustomInstance mcci = this.Holder as MemberComponentIdCustomInstance; if (mcci != null) { XmlUtil.SetAttribute(node, XmlTags.XMLATT_instanceId, mcci.Pointer.MemberId); cp = (ClassInstancePointer)(mcci.Owner); XmlNode nd = XmlUtil.CreateSingleNewElement(node, XmlTags.XML_ClassInstance); cp.OnPostSerialize(writer.ObjectList, nd, true, writer); } else { MemberComponentIdCustom mcc = this.Holder as MemberComponentIdCustom; if (mcc != null) { XmlUtil.SetAttribute(node, XmlTags.XMLATT_instanceId, mcc.Pointer.MemberId); } else { } } } } }
public void UpdateXmlNode(XmlObjectWriter writer) { if (_xmlNode != null) { if (writer != null) { writer.WriteObjectToNode(_xmlNode, this); } else if (Writer != null) { _writer.WriteObjectToNode(_xmlNode, this); } } }
protected override void OnSave(XmlNode node) { XmlUtil.SetAttribute(node, XmlTags.XMLATT_NAME, _value); XmlUtil.SetAttribute(node, XMLATT_Subcript, _subscript); XmlUtil.SetAttribute(node, XmlTags.XMLATT_VARID, ID); XmlObjectWriter xw = this.root.Serializer as XmlObjectWriter; if (xw != null) { XmlNode nd = node.OwnerDocument.CreateElement(XML_ValueType); node.AppendChild(nd); xw.WriteObjectToNode(nd, VariableType); } }
public override void OnWriteToXmlNode(IXmlCodeWriter serializer, XmlNode node) { XmlUtil.SetLibTypeAttribute(node, this.GetType()); base.OnWriteToXmlNode(serializer, node); XmlNode eNode = XmlUtil.CreateSingleNewElement(node, XML_Event); XmlObjectWriter writer = (XmlObjectWriter)serializer; writer.WriteObjectToNode(eNode, _event); if (_relativeLocation != Point.Empty) { XmlUtil.SetAttribute(node, XMLATTR_RELX, _relativeLocation.X); XmlUtil.SetAttribute(node, XMLATTR_RELY, _relativeLocation.Y); } }
public virtual void UpdateXmlNode(XmlObjectWriter writer) { if (_xmlNode != null) { if (writer != null) { writer.WriteObjectToNode(_xmlNode, this); Changed = false; } else if (_writer != null) { _writer.WriteObjectToNode(_xmlNode, this); Changed = false; } } }
public void OnBeforeWrite(XmlObjectWriter writer, XmlNode node) { _writer = writer; if (_xmlNodeChanged != node) { _xmlNode = node; } if (ScopeMethodId != 0) { XmlUtil.SetAttribute(node, XmlTags.XMLATT_ScopeId, ScopeMethodId); } if (SubScopeId != 0) { XmlUtil.SetAttribute(node, XmlTags.XMLATT_SubScopeId, SubScopeId); } }
public void OnBeforeWrite(XmlSerializer.XmlObjectWriter writer, System.Xml.XmlNode node) { _writer = writer; if (_xmlNodeChanged != node) { _xmlNode = node; } XmlUtil.SetAttribute(node, XmlTags.XMLATT_ComponentID, _varId); if (ScopeMethodId != 0) { XmlUtil.SetAttribute(node, XmlTags.XMLATT_ScopeId, ScopeMethodId); } if (SubScopeId != 0) { XmlUtil.SetAttribute(node, XmlTags.XMLATT_SubScopeId, SubScopeId); } }
public void OnChangeWithinMethod(bool withinMethod) { if (_xmlNode != null) { if (_writer == null) { if (_reader != null) { _writer = new XmlObjectWriter(_reader.ObjectList); } } if (_writer != null) { _writer.WriteObjectToNode(_xmlNode, this); } } }
protected override void OnWrite(IXmlCodeWriter writer, XmlNode node) { XmlUtil.SetAttribute(node, XmlTags.XMLATT_MethodID, _methodId); string s = this.Name; if (!string.IsNullOrEmpty(s)) { XmlUtil.SetNameAttribute(node, s); } if (_prj == null) { XmlObjectWriter w = writer as XmlObjectWriter; if (w != null && w.ObjectList != null) { _prj = w.ObjectList.Project; } } }
public void OnChangeWithinMethod(bool withinmethod) { if (this.XmlData != null) { XmlObjectWriter writer = GetWriter(); if (writer != null) { if (withinmethod) { _xmlNodeChanged = XmlData.OwnerDocument.CreateElement(XmlData.Name); writer.WriteObjectToNode(_xmlNodeChanged, this); } else { writer.WriteObjectToNode(XmlData, this); } } } }
public void OnChangeWithinMethod(bool withinmethod) { if (_writer == null) { _writer = XmlSerializerUtility.GetWriter(_reader) as XmlObjectWriter; } if (_writer != null && _xmlNode != null) { if (withinmethod) { _xmlNodeChanged = _xmlNode.OwnerDocument.CreateElement(_xmlNode.Name); _writer.WriteObjectToNode(_xmlNodeChanged, this); } else { _writer.WriteObjectToNode(_xmlNode, this); } } }
public void WriteToXmlNode(XmlObjectWriter writer, XmlNode node) { if (_valuePointer != null) { //try //{ XmlNode nd = node.OwnerDocument.CreateElement(XmlTags.XML_Property); node.AppendChild(nd); writer.WriteObjectToNode(nd, _valuePointer); // if (xw.HasErrors) // { // MathNode.Log(xw.ErrorCollection); // } //} //catch (Exception e) //{ // MathNode.Log(e); //} } }
public void WriteToXmlNode(XmlObjectWriter writer, XmlNode node) { // XmlSerialization.WriteValueToChildNode(node, XML_RelativePosition, _label.RelativePosition.Location); XmlNode nd = node.SelectSingleNode(XML_RelativePosition); XmlSerialization.SetAttribute(nd, "xTo0", _label.RelativePosition.IsXto0); XmlSerialization.SetAttribute(nd, "yTo0", _label.RelativePosition.IsYto0); // XmlNode eNode = XmlUtil.CreateSingleNewElement(node, XML_Event); writer.WriteObjectToNode(eNode, _event); // XmlNode ndPos = XmlUtil.CreateSingleNewElement(node, XML_Position); XmlSerialization.WriteValueToChildNode(ndPos, XML_RelativePosition, RelativePosition.Location); nd = ndPos.SelectSingleNode(XML_RelativePosition); XmlSerialization.SetAttribute(nd, "xTo0", RelativePosition.IsXto0); XmlSerialization.SetAttribute(nd, "yTo0", RelativePosition.IsYto0); // if (_outPortList != null && _outPortList.Count > 0) { XmlNode portsNode = XmlUtil.CreateSingleNewElement(node, XML_OutPorts); foreach (EventPortOut port in _outPortList) { XmlNode pNode = portsNode.OwnerDocument.CreateElement(XmlTags.XML_Item); portsNode.AppendChild(pNode); port.OnWriteToXmlNode(writer, pNode); } } if (_inPortList != null && _inPortList.Count > 0) { XmlNode portsNode = XmlUtil.CreateSingleNewElement(node, XML_InPorts); foreach (EventPortIn port in _inPortList) { XmlNode pNode = portsNode.OwnerDocument.CreateElement(XmlTags.XML_Item); portsNode.AppendChild(pNode); port.OnWriteToXmlNode(writer, pNode); } } }
public void UpdateXmlNode(XmlObjectWriter writer) { if (_xmlNode != null) { if (writer != null) { writer.WriteObjectToNode(_xmlNode, this); } else { if (_writer == null) { _writer = XmlSerializerUtility.GetWriter(_reader) as XmlObjectWriter; } if (_writer != null) { _writer.WriteObjectToNode(_xmlNode, this); } } } }
public static ActionClass createAction(IClass holder, IProperty ei, XmlObjectWriter writer, XmlNode node, IMethod scopeMethod, IActionsHolder actsHolder, Form caller) { if (ei != null) { IPropertyEx pp = ei as IPropertyEx; if (pp != null) { ActionClass act = new ActionClass(pp.RootPointer); act.ActionMethod = pp.CreateSetterMethodPointer(act); act.ActionName = act.ActionMethod.DefaultActionName; act.ActionHolder = actsHolder; if (pp.RootPointer.CreateNewAction(act, writer, scopeMethod, caller)) { return(act); } } else { PropertyClass pc = ei as PropertyClass; if (pc != null) { PropertyClass pc2 = (PropertyClass)pc.Clone(); pc2.SetHolder(holder); ActionClass act = new ActionClass(holder.RootPointer); act.ActionMethod = pc2.CreateSetterMethodPointer(act); act.ActionName = act.ActionMethod.DefaultActionName; // pc.Holder.CodeName + ".Set" + pc.Name; act.ActionHolder = actsHolder; if (holder.RootPointer.CreateNewAction(act, writer, scopeMethod, caller)) { return(act); } } else { } } } return(null); }
public void SaveCustomPropertyValue(XmlObjectWriter writer, string name, XmlNode rootNode) { PropertyClassDescriptor p = null; if (_properties == null) { throw new DesignerException("Saving property {0} for class [{1},{2}]: custom properties not loaded", name, ClassId, MemberId); } foreach (PropertyClassDescriptor pr in _properties) { if (pr.Name == name) { p = pr; break; } } if (p == null) { throw new DesignerException("Saving property {0} for class [{1},{2}]: custom property not found", name, ClassId, MemberId); } saveCustomPropertyValue(writer, p, rootNode); }
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); }
public virtual void OnWriteToXmlNode(IXmlCodeWriter writer0, XmlNode node) { XmlObjectWriter writer = writer0 as XmlObjectWriter; if (writer == null) { throw new DesignerException("Error writing CustomPropertyPointer. writer0 is not a XmlObjectWriter"); } if (writer.ObjectList == null) { throw new DesignerException("Error writing CustomPropertyPointer. writer0 does not contain object map"); } if (node == null) { throw new DesignerException("Error writing CustomPropertyPointer. Target XmlNode is null."); } XmlUtil.SetAttribute(node, XmlTags.XMLATT_PropId, MemberId); if (ClassId != writer.ObjectList.ClassId) { XmlUtil.SetAttribute(node, XmlTags.XMLATT_ownerClassID, ClassId); } LocalVariable var = _holder as LocalVariable; if (var != null) { XmlUtil.SetAttribute(node, XmlTags.XMLATT_varId, _holder.MemberId); } else { ClassInstancePointer cp = _holder as ClassInstancePointer; if (cp != null) { XmlNode nd = XmlUtil.CreateSingleNewElement(node, XmlTags.XML_ClassInstance); cp.OnPostSerialize(writer.ObjectList, nd, true, writer); } } }
/// <summary> /// update the action XML /// </summary> /// <param name="name"></param> /// <param name="rootNode"></param> /// <param name="writer"></param> public override void OnPropertyChanged(string name, object property, XmlNode rootNode, XmlObjectWriter writer) { base.OnPropertyChanged(name, property, rootNode, writer); if (XmlData != null) { if (string.CompareOrdinal(name, "ActionName") == 0) { XmlUtility.XmlUtil.SetNameAttribute(XmlData, this.ActionName); } else if (string.CompareOrdinal(name, "BreakBeforeExecute") == 0) { XmlNode propNode = SerializeUtil.CreatePropertyNode(XmlData, name); propNode.InnerText = this.BreakBeforeExecute.ToString(); } else if (string.CompareOrdinal(name, "BreakAfterExecute") == 0) { XmlNode propNode = SerializeUtil.CreatePropertyNode(XmlData, name); propNode.InnerText = this.BreakAfterExecute.ToString(); } else if (string.CompareOrdinal(name, "ActionMethod") == 0) { writer.ClearErrors(); ((ClassPointer)(Owner)).SaveAction(this, writer); } } }
public void WriteToXmlNode(XmlObjectWriter writer, XmlNode node) { throw new NotImplementedException(); }
/// <summary> /// update the action XML /// </summary> /// <param name="name"></param> /// <param name="rootNode"></param> /// <param name="writer"></param> public void OnPropertyChanged(string name, object property, XmlNode rootNode, XmlObjectWriter writer) { if (string.CompareOrdinal(name, "parameter") == 0) { return; } XmlNode actNode = SerializeUtil.GetActionNode(rootNode, this.ActionId); if (actNode != null) { if (string.CompareOrdinal(name, "ActionName") == 0) { XmlUtility.XmlUtil.SetNameAttribute(actNode, this.ActionName); } else if (string.CompareOrdinal(name, "Description") == 0) { XmlNode propNode = SerializeUtil.CreatePropertyNode(actNode, name); propNode.InnerText = this.Description; } else if (string.CompareOrdinal(name, "BreakBeforeExecute") == 0) { XmlNode propNode = SerializeUtil.CreatePropertyNode(actNode, name); propNode.InnerText = this.BreakBeforeExecute.ToString(); } else if (string.CompareOrdinal(name, "BreakAfterExecute") == 0) { XmlNode propNode = SerializeUtil.CreatePropertyNode(actNode, name); propNode.InnerText = this.BreakAfterExecute.ToString(); } else if (string.CompareOrdinal(name, "ActionMethod") == 0) { writer.ClearErrors(); _class.SaveAction(this, writer); } } }
public bool Edit(XmlObjectWriter writer, IMethod context, Form caller, bool isNewAction) { return(false); }
public virtual void OnBeforeWrite(XmlObjectWriter writer, XmlNode node) { _xmlNode = node; _writer = writer; XmlUtil.SetAttribute(node, XmlTags.XMLATT_ActionID, ActionId); }
public override void OnBeforeWrite(XmlObjectWriter writer, XmlNode node) { base.OnBeforeWrite(writer, node); XmlUtil.SetAttribute(node, XMLATT_attachId, _attachedActionId); }
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) { MethodClass scopeMethod = context.Instance as MethodClass; if (scopeMethod != null) { //this version only edit FinalActions ILimnorDesignPane dp = scopeMethod.Project.GetTypedData <ILimnorDesignPane>(scopeMethod.RootPointer.ClassId); if (dp != null) { //save the method contents BranchList bl = scopeMethod.ActionList; string methodName = scopeMethod.MethodName; ParameterClass returnType = scopeMethod.ReturnValue; List <ComponentIcon> icons = scopeMethod.ComponentIconList; //switch method contents scopeMethod.ActionList = scopeMethod.FinalActions.Actions; scopeMethod.SetName("FinalActions"); List <ComponentIcon> icons2 = new List <ComponentIcon>(); foreach (ComponentIcon ic in icons) { icons2.Add((ComponentIcon)ic.Clone()); } foreach (ComponentIconSubscopeVariable ic in scopeMethod.FinalActions.ComponentIconList) { icons2.Add((ComponentIcon)ic.Clone()); } scopeMethod.SetComponentIcons(icons2); // Rectangle rc = new Rectangle(Cursor.Position, new Size(32, 232)); if (scopeMethod.Owner == null) { scopeMethod.Owner = dp.Loader.GetRootId(); } DlgMethod dlg = scopeMethod.CreateBlockScopeMethodEditor(rc, 1); try { dlg.LoadMethod(scopeMethod, EnumParameterEditType.ReadOnly); dlg.Text = string.Format(CultureInfo.InvariantCulture, "Specify final actionsfor {0}", methodName); if (edSvc.ShowDialog(dlg) == DialogResult.OK) { scopeMethod.FinalActions.Actions = scopeMethod.ActionList; List <ComponentIconSubscopeVariable> lst = new List <ComponentIconSubscopeVariable>(); foreach (ComponentIcon ic in scopeMethod.ComponentIconList) { ComponentIconSubscopeVariable sv = ic as ComponentIconSubscopeVariable; if (sv != null) { lst.Add(sv); } } scopeMethod.FinalActions.ComponentIconList = lst; XmlObjectWriter xw = dp.Loader.Writer; xw.WriteObject(scopeMethod.FinalActions.DataXmlNode, scopeMethod.FinalActions, null); value = scopeMethod.FinalActions; } } catch (Exception err) { MathNode.LogError(DesignerException.FormExceptionText(err)); } finally { //restore method contents scopeMethod.SetName(methodName); scopeMethod.ActionList = bl; scopeMethod.SetComponentIcons(icons); scopeMethod.ExitEditor(); } } } } } return(value); }
public bool Edit(XmlObjectWriter writer, IMethod context, Form caller, bool isNewAction) { _class.SaveAction(this, writer); return(true); }