diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-05 05:32:49 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-05 05:32:49 +0200 |
| commit | 47dad629d4ff744071f06a342f5f2eabaa879d71 (patch) | |
| tree | 61c6128415244f7f9751856cbbb6c248f005c515 | |
| parent | 4ca12da2740078a292600736c60c09897263ef95 (diff) | |
First MSIL expand in TreeView with ItemTemplate, need to share
ItemTemplates.
modifié : Tests/Interfaces/Unsorted/testTreeView.crow
modifié : src/GraphicObjects/TemplatedControl.cs
modifié : src/IMLStream.cs
modifié : src/Interface.cs
| -rwxr-xr-x | Tests/Interfaces/Unsorted/testTreeView.crow | 3 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedControl.cs | 3 | ||||
| -rw-r--r-- | src/IMLStream.cs | 25 | ||||
| -rw-r--r-- | src/Interface.cs | 1 |
4 files changed, 25 insertions, 7 deletions
diff --git a/Tests/Interfaces/Unsorted/testTreeView.crow b/Tests/Interfaces/Unsorted/testTreeView.crow index c998af39..c3bfabc6 100755 --- a/Tests/Interfaces/Unsorted/testTreeView.crow +++ b/Tests/Interfaces/Unsorted/testTreeView.crow @@ -1,7 +1,7 @@ <?xml version="1.0"?> <TreeView Height="90%" Width="90%" Data="{CurDirectory}"> <ItemTemplate DataType="System.IO.FileInfo"> - <Label Background="Mantis" Text="{}" Width="Stretched"/> + <Label Background="Mantis" Text="{Name}" Width="Stretched"/> <!-- <Expandable Caption="{}"> <Template> <Border BorderWidth="1" Foreground="LightGray" Height="{../HeightPolicy}" Width="{../WidthPolicy}" @@ -32,6 +32,7 @@ Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"/> </VerticalStack> </Template> + <ListBox Name="List" Height="Fit" Width="{../WidthPolicy}" /> </Expandable> </ItemTemplate> </TreeView>
\ No newline at end of file diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index d3feb1d2..b04fe204 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -154,7 +154,8 @@ namespace Crow itemTemplates = new Dictionary<string, ItemTemplate> (); //TODO:check encoding itemTemplates[dataType] = new ItemTemplate (Encoding.UTF8.GetBytes(itemTmp)); - itemTemplates [dataType].CreateExpandDelegate(dataType, datas); + if (!string.IsNullOrEmpty (datas)) + itemTemplates [dataType].CreateExpandDelegate(dataType, datas); continue; } diff --git a/src/IMLStream.cs b/src/IMLStream.cs index 14262595..c7e26d5d 100644 --- a/src/IMLStream.cs +++ b/src/IMLStream.cs @@ -48,10 +48,11 @@ namespace Crow public void CreateExpandDelegate (string strDataType, string method){ Type dataType = Type.GetType(strDataType); - Type host_type = typeof(ItemTemplate);//not sure is the best place to put the dyn method - Type evt_type = typeof(EventHandler); + Type hostType = typeof(ItemTemplate);//not sure is the best place to put the dyn method + Type evtType = typeof(EventHandler); + Type listBoxType = typeof(ListBox); - MethodInfo evtInvoke = evt_type.GetMethod ("Invoke"); + MethodInfo evtInvoke = evtType.GetMethod ("Invoke"); ParameterInfo [] evtParams = evtInvoke.GetParameters (); Type handlerArgsType = evtParams [1].ParameterType; @@ -59,17 +60,31 @@ namespace Crow DynamicMethod dm = new DynamicMethod ("dyn_expand_" + method, typeof (void), args, - host_type); + hostType); #region IL generation ILGenerator il = dm.GetILGenerator (256); + il.Emit (OpCodes.Ldarg_1); + + MethodInfo miFindByName = typeof(GraphicObject).GetMethod("FindByName"); + il.Emit(OpCodes.Ldstr, "List"); + il.Emit (OpCodes.Callvirt, miFindByName); + + il.Emit (OpCodes.Ldarg_1); + il.Emit (OpCodes.Callvirt, typeof(GraphicObject).GetProperty("DataSource").GetGetMethod ()); + + MethodInfo miGetDatas = dataType.GetMethod (method, new Type[] {}); + il.Emit (OpCodes.Callvirt, miGetDatas); + + il.Emit (OpCodes.Callvirt, listBoxType.GetProperty("Data").GetSetMethod ()); + il.Emit (OpCodes.Ret); #endregion - Expand = (EventHandler)dm.CreateDelegate (evt_type, this); + Expand = (EventHandler)dm.CreateDelegate (evtType, this); } } } diff --git a/src/Interface.cs b/src/Interface.cs index 3233cdfe..350ef075 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -84,6 +84,7 @@ namespace Crow internal bool XmlLoading = false; + public Dictionary<string,object> Ressources = new Dictionary<string, object>(); public Queue<LayoutingQueueItem> LayoutingQueue = new Queue<LayoutingQueueItem> (); public Queue<LayoutingQueueItem> DiscardQueue; public Queue<LayoutingQueueItem> ProcessedLayoutingQueue; |