diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-05 07:05:13 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-05 07:05:13 +0200 |
| commit | e9963abca14fbad8ff6c215e5c9d6b45652b38dc (patch) | |
| tree | fa1b55a3bd76257c01849e48f97b3d955012cece /src | |
| parent | 47dad629d4ff744071f06a342f5f2eabaa879d71 (diff) | |
* ListBox.cs:
* TemplatedControl.cs: set ItemTemplate as public
* IMLStream.cs: copy ItemTemplates in tree hierarchy
* TreeView.crow: add scrolling
* treeList.crow: simple list template for tree children
* testTreeView.crow: update test
* Tests.csproj: update tests
Diffstat (limited to 'src')
| -rw-r--r-- | src/GraphicObjects/ListBox.cs | 14 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedControl.cs | 10 | ||||
| -rw-r--r-- | src/IMLStream.cs | 15 |
3 files changed, 24 insertions, 15 deletions
diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs index c4f9e0e1..24ceb618 100644 --- a/src/GraphicObjects/ListBox.cs +++ b/src/GraphicObjects/ListBox.cs @@ -112,10 +112,10 @@ namespace Crow } #endregion void loading(){ - if (itemTemplates == null) - itemTemplates = new Dictionary<string, ItemTemplate> (); - if (!itemTemplates.ContainsKey ("default")) - itemTemplates["default"] = new ItemTemplate (ItemTemplate); + if (ItemTemplates == null) + ItemTemplates = new Dictionary<string, ItemTemplate> (); + if (!ItemTemplates.ContainsKey ("default")) + ItemTemplates["default"] = new ItemTemplate (ItemTemplate); for (int i = 1; i <= (data.Count / itemPerPage) + 1; i++) { if (cancelLoading) @@ -163,10 +163,10 @@ namespace Crow ItemTemplate itemStream = null; Type dataType = data [i].GetType (); - if (itemTemplates.ContainsKey (dataType.FullName)) - itemStream = itemTemplates [dataType.FullName]; + if (ItemTemplates.ContainsKey (dataType.FullName)) + itemStream = ItemTemplates [dataType.FullName]; else - itemStream = itemTemplates ["default"]; + itemStream = ItemTemplates ["default"]; lock (Interface.CurrentInterface.LayoutMutex) { g = Interface.Load (itemStream); diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index b04fe204..744cd329 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -64,7 +64,7 @@ namespace Crow string _template; string _itemTemplate; - protected Dictionary<string, ItemTemplate> itemTemplates; + public Dictionary<string, ItemTemplate> ItemTemplates; [XmlAttributeAttribute][DefaultValue(null)] public string Template { @@ -150,12 +150,12 @@ namespace Crow xr.MoveToElement (); itemTmp = xr.ReadInnerXml (); - if (itemTemplates == null) - itemTemplates = new Dictionary<string, ItemTemplate> (); + if (ItemTemplates == null) + ItemTemplates = new Dictionary<string, ItemTemplate> (); //TODO:check encoding - itemTemplates[dataType] = new ItemTemplate (Encoding.UTF8.GetBytes(itemTmp)); + ItemTemplates[dataType] = new ItemTemplate (Encoding.UTF8.GetBytes(itemTmp)); if (!string.IsNullOrEmpty (datas)) - itemTemplates [dataType].CreateExpandDelegate(dataType, datas); + ItemTemplates [dataType].CreateExpandDelegate(this, dataType, datas); continue; } diff --git a/src/IMLStream.cs b/src/IMLStream.cs index c7e26d5d..ccc09f45 100644 --- a/src/IMLStream.cs +++ b/src/IMLStream.cs @@ -46,9 +46,9 @@ namespace Crow public ItemTemplate(Byte[] b) : base(b){} - public void CreateExpandDelegate (string strDataType, string method){ + public void CreateExpandDelegate (TemplatedControl host, string strDataType, string method){ Type dataType = Type.GetType(strDataType); - Type hostType = typeof(ItemTemplate);//not sure is the best place to put the dyn method + Type hostType = typeof(TemplatedControl);//not sure is the best place to put the dyn method Type evtType = typeof(EventHandler); Type listBoxType = typeof(ListBox); @@ -65,13 +65,22 @@ namespace Crow #region IL generation ILGenerator il = dm.GetILGenerator (256); + il.DeclareLocal(typeof(GraphicObject)); il.Emit (OpCodes.Ldarg_1); MethodInfo miFindByName = typeof(GraphicObject).GetMethod("FindByName"); il.Emit(OpCodes.Ldstr, "List"); il.Emit (OpCodes.Callvirt, miFindByName); + il.Emit (OpCodes.Stloc_0); + FieldInfo fiTemplates = typeof(TemplatedControl).GetField("ItemTemplates"); + il.Emit (OpCodes.Ldloc_0); + il.Emit (OpCodes.Ldarg_0); + il.Emit (OpCodes.Ldfld, fiTemplates); + il.Emit (OpCodes.Stfld, fiTemplates); + + il.Emit (OpCodes.Ldloc_0); il.Emit (OpCodes.Ldarg_1); il.Emit (OpCodes.Callvirt, typeof(GraphicObject).GetProperty("DataSource").GetGetMethod ()); @@ -84,7 +93,7 @@ namespace Crow #endregion - Expand = (EventHandler)dm.CreateDelegate (evtType, this); + Expand = (EventHandler)dm.CreateDelegate (evtType, host); } } } |