I use "Go.Xml" to save the objects in my diagram. I need to change an object field ("ObjPhase") in an object list field in one of my object ("MyObj") like the code below:
internal class MyObj : GoGroup { public Phase ObjPhase { get; set; } //Old code //public List ObjPhase { get; set; } //New code ... }
[Serializable] public class Phase { public int PhaseMinimum { get; set; } public int PhaseMaximum { get; set; } public Color PhaseColor { get; set; }
public Phase() { PhaseMinimum = 0; PhaseMaximum = 100; PhaseColor = Color.Black; } }
I can't figure how to save the new object list, is it possible to save it with your xml function?
The code to save "MyObj" in saving function of GoDocument (working ok with my single object): private static void InitReaderWriter(GoXmlReaderWriterBase rw, ...) { GoXmlBindingTransformer t; ...
MyObj myobj = new MyObj(); t = new GoXmlBindingTransformer("MyObj", myobj); ... t.AddBinding("PhaseMin", "ObjPhase.PhaseMinimum"); t.AddBinding("PhaseMax", "ObjPhase.PhaseMaximum"); t.AddBinding("PhaseColor", "ObjPhase.PhaseColor"); rw.AddTransformer(t); }
This works great, your support team is very helpful.
I still have a small question, in my "custom transformer class inheriting from GoXmlBindingTransformer" a need to pass a "proto" object in the constructor. My main class ("MyObj") have many others class which was derived from it and this class do not have default constructor. So, my custom transformer look like this:
public class XmlTransformMyObj : GoXmlBindingTransformer { public XmlTransformMyObj :base(new MyObj(... , ...)) { ...
}
My question, even if i use specific (default) parameter in this constructor, the class seems to works with every parameter i can use, is my "proto" object ok or i need to make a default constructor for "MyObj" to be clean?
I have another question related to this development:
I use undomanager in my program and i do not want my subobject to use the undo/redo functionnality but i want them to set the Dirty flag if some subobject was modified in my document.
I try "Document.IsModified = true;" in my main object containing subobject but this not works (seems the value cannot be set to true cause nothing was modified for him and no record for undo/redo). So, what i need to do to set the Dirty flag of document without messing with my current undo/redo which works great.
Maybe using a new bool value in my GoDocument class which indicates the Dirty status of subobject (like IsSubObjectModified) and check the status of both IsModified and IsSubObjectModified to check if the document have modification. It is correct or do you have better option?