]> O.S.I.I.S - jp/crow.git/commitdiff
First MSIL expand in TreeView with ItemTemplate, need to share
authorjpbruyere <jp.bruyere@hotmail.com>
Fri, 5 Aug 2016 03:32:49 +0000 (05:32 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Fri, 5 Aug 2016 03:32:49 +0000 (05:32 +0200)
ItemTemplates.

modifié :         Tests/Interfaces/Unsorted/testTreeView.crow
modifié :         src/GraphicObjects/TemplatedControl.cs
modifié :         src/IMLStream.cs
modifié :         src/Interface.cs

Tests/Interfaces/Unsorted/testTreeView.crow
src/GraphicObjects/TemplatedControl.cs
src/IMLStream.cs
src/Interface.cs

index c998af3930bcd68a8c971c237d27151cc11fdc9a..c3bfabc6df3bb81bdde0f2caa092643c90ddcd85 100755 (executable)
@@ -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
index d3feb1d26e30b0f03cfc5dfb37d23149a0f5b563..b04fe204db78a6d552fa02a00b83be753fc56950 100644 (file)
@@ -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;
                                                        }
index 142625950bacd6a69c03f93fc3a078745add2a31..c7e26d5d4a1d3d08d8757900fa5a05cdee4ad301 100644 (file)
@@ -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);
                }
        }
 }
index 3233cdfeb26bdf3ce948722aea1fd8e864196d09..350ef075ee9e538f8076379ddad4af914643391b 100644 (file)
@@ -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;