/// </summary>
public class Container : PrivateContainer
{
+ #if DESIGN_MODE
+ public override void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem)
+ {
+ if (this.design_isTGItem)
+ return;
+ base.getIML (doc, parentElem);
+ if (child == null)
+ return;
+ child.getIML (doc, parentElem.LastChild);
+ }
+ #endif
+
#region CTOR
protected Container() : base(){}
public Container (Interface iface) : base(iface){}
using Crow.IML;
using System.Threading;
+
+#if DESIGN_MODE
+using System.Xml;
+using System.IO;
+#endif
+
namespace Crow
{
/// <summary>
public int design_column;
public string design_imlPath;
public Dictionary<string,string> design_members = new Dictionary<string, string>();
+ public bool design_isTGItem = false;
+
+ public string GetIML(){
+ XmlDocument doc = new XmlDocument( );
+
+ using (StringWriter sw = new StringWriter ()) {
+ XmlWriterSettings settings = new XmlWriterSettings {
+ Indent = true,
+ IndentChars = "\t",
+ };
+ using (XmlWriter xtw = XmlWriter.Create (sw, settings)) {
+ //(1) the xml declaration is recommended, but not mandatory
+ XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration ("1.0", "UTF-8", null);
+ doc.InsertBefore (xmlDeclaration, null);
+ getIML (doc, (XmlNode)doc);
+ doc.WriteTo (xtw);
+ }
+ return sw.ToString ();
+ }
+ }
+
+ public virtual void getIML(XmlDocument doc, XmlNode parentElem) {
+ if (this.design_isTGItem)
+ return;
+
+ XmlElement xe = doc.CreateElement(this.GetType().Name);
+
+ foreach (KeyValuePair<string,string> kv in design_members) {
+ XmlAttribute xa = doc.CreateAttribute (kv.Key);
+ xa.Value = kv.Value;
+ xe.Attributes.Append (xa);
+ }
+
+ parentElem.AppendChild (xe);
+ }
+
#endif
#region IDisposable implementation
{
public class Group : GraphicObject
{
+ #if DESIGN_MODE
+ public override void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem)
+ {
+ if (this.design_isTGItem)
+ return;
+ base.getIML (doc, parentElem);
+ foreach (GraphicObject g in Children) {
+ g.getIML (doc, parentElem.LastChild);
+ }
+ }
+ #endif
+
protected ReaderWriterLockSlim childrenRWLock = new ReaderWriterLockSlim();
#region CTOR
/// </summary>
public class TemplatedContainer : TemplatedControl
{
+ #if DESIGN_MODE
+ public override void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem)
+ {
+ if (this.design_isTGItem)
+ return;
+ base.getIML (doc, parentElem);
+ if (!HasContent)
+ return;
+ Content.getIML (doc, parentElem.LastChild);
+ }
+ #endif
+
#region CTOR
protected TemplatedContainer() : base(){}
public TemplatedContainer (Interface iface) : base(iface){}
/// </summary>
public abstract class TemplatedControl : PrivateContainer
{
+ #if DESIGN_MODE
+ public bool design_inlineTemplate = false;
+ public override void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem)
+ {
+ if (this.design_isTGItem)
+ return;
+ base.getIML (doc, parentElem);
+ if (child == null || !design_inlineTemplate)
+ return;
+ XmlElement xe = doc.CreateElement("Template");
+ child.getIML (doc, xe);
+ parentElem.LastChild.AppendChild (xe);
+ }
+ #endif
#region CTOR
protected TemplatedControl() : base(){}
public TemplatedControl (Interface iface) : base(iface){}
{
public abstract class TemplatedGroup : TemplatedControl
{
+ #if DESIGN_MODE
+ public override void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem)
+ {
+ if (this.design_isTGItem)
+ return;
+ base.getIML (doc, parentElem);
+
+ if (string.IsNullOrEmpty(_itemTemplate)) {
+ foreach (ItemTemplate it in ItemTemplates.Values)
+ it.getIML (doc, parentElem.LastChild);
+ }
+
+ foreach (GraphicObject g in Items) {
+ g.getIML (doc, parentElem.LastChild);
+ }
+ }
+ #endif
+
#region CTOR
protected TemplatedGroup() : base(){}
public TemplatedGroup (Interface iface) : base(iface){}
lock (IFace.LayoutMutex) {
g = iTemp.CreateInstance();
+ #if DESIGN_MODE
+ g.design_isTGItem = true;
+ #endif
page.AddChild (g);
// if (isPaged)
g.LogicalParent = this;
itemTmpID += path+dataType+datas;
if (!iface.Instantiators.ContainsKey (itemTmpID))
iface.Instantiators [itemTmpID] =
- new ItemTemplate (iface, Interface.GetStreamFromPath (path), dataTest, dataType, datas);
+ new ItemTemplate (iface, path, dataTest, dataType, datas);
}
return new string [] { dataType, itemTmpID, datas, dataTest };
}
continue;
if (reader.Name == "Template") {
inlineTemplate = true;
+ #if DESIGN_MODE
+ ctx.il.Emit (OpCodes.Ldloc_0);
+ ctx.il.Emit (OpCodes.Ldc_I4_1);
+ ctx.il.Emit (OpCodes.Stfld, typeof(TemplatedControl).GetField("design_inlineTemplate"));
+ #endif
reader.Read ();
readChildren (reader, ctx, -1);
} else if (reader.Name == "ItemTemplate")
///
/// </summary>
public class ItemTemplate : Instantiator {
+ #if DESIGN_MODE
+ public void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem){
+ if (sourcePath == "#Crow.DefaultItem.template")
+ return;
+
+ XmlElement xe = doc.CreateElement("ItemTemplate");
+ XmlAttribute xa = null;
+
+ if (string.IsNullOrEmpty (sourcePath)) {
+ //inline item template
+ using (GraphicObject go = this.CreateInstance())
+ go.getIML (doc, xe);
+ } else {
+ xa = doc.CreateAttribute ("Path");
+ xa.Value = sourcePath;
+ xe.Attributes.Append (xa);
+ }
+
+ if (strDataType != "default") {
+ xa = doc.CreateAttribute ("DataType");
+ xa.Value = strDataType;
+ xe.Attributes.Append (xa);
+
+ if (dataTest != "TypeOf"){
+ xa = doc.CreateAttribute ("DataTest");
+ xa.Value = dataTest;
+ xe.Attributes.Append (xa);
+ }
+ }
+
+ if (!string.IsNullOrEmpty(fetchMethodName)){
+ xa = doc.CreateAttribute ("Data");
+ xa.Value = fetchMethodName;
+ xe.Attributes.Append (xa);
+ }
+
+ parentElem.AppendChild (xe);
+
+
+ }
+ #endif
+
public EventHandler Expand;
public BooleanTestOnInstance HasSubItems;
string strDataType;
/// <param name="path">IML file to parse</param>
/// <param name="_dataType">type this item will be choosen for, or member of the data item</param>
/// <param name="_fetchDataMethod">for hierarchical data, method to call for children fetching</param>
- public ItemTemplate(Interface _iface, string path, string _dataTest = "TypeOf", string _dataType = null, string _fetchDataMethod = null)
+ public ItemTemplate(Interface _iface, string path, string _dataTest = "TypeOf", string _dataType = "default", string _fetchDataMethod = null)
: base(_iface, path) {
strDataType = _dataType;
fetchMethodName = _fetchDataMethod;
il.Emit (OpCodes.Callvirt, miGetDatas);
}
+
+
+
}
}