]> O.S.I.I.S - jp/crow.git/commitdiff
* ListBox.cs:
authorjpbruyere <jp.bruyere@hotmail.com>
Fri, 5 Aug 2016 05:05:13 +0000 (07:05 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Fri, 5 Aug 2016 05:05:13 +0000 (07:05 +0200)
* 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

Templates/TreeView.crow
Tests/Interfaces/Unsorted/testTreeView.crow
Tests/Interfaces/treeList.crow [new file with mode: 0755]
Tests/Tests.csproj
src/GraphicObjects/ListBox.cs
src/GraphicObjects/TemplatedControl.cs
src/IMLStream.cs

index 8915e15484dd04d258ae416e20b264b2a1812fdc..5bad322dfc33ddb9622b5eeda2eac6cdcca74ef4 100644 (file)
@@ -1,7 +1,9 @@
-<Border Background="DimGray" BorderWidth="1" Margin="1" MinimumSize="100,100"
-               Width="{../WidthPolicy}" Height="{../HeightPolicy}">
-       <VerticalStack Width="{../../WidthPolicy}" Height="{../../HeightPolicy}"
-                        Name="List" Margin="0" VerticalAlignment="Top"/>
-
+<Border BorderWidth="1" Margin="1" MinimumSize="10,10" Height="{../HeightPolicy}" Width="{../WidthPolicy}" >
+       <Scroller  Name="scroller1" Margin="1" VerticalScrolling="true"
+               Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"
+               ValueChanged="../../_scroller_ValueChanged">
+               <VerticalStack LayoutChanged="../../../_list_LayoutChanged"
+                       Height="Fit" Width="{../../../WidthPolicy}" Name="List" Margin="0" VerticalAlignment="Top"/>
+       </Scroller>
 </Border>
 
index c3bfabc6df3bb81bdde0f2caa092643c90ddcd85..ca5ae138c7d673d1d411059598c236fef00b0d15 100755 (executable)
@@ -1,27 +1,13 @@
 <?xml version="1.0"?>
 <TreeView Height="90%" Width="90%" Data="{CurDirectory}">
        <ItemTemplate DataType="System.IO.FileInfo">
-               <Label Background="Mantis" Text="{Name}" Width="Stretched"/>
-<!--           <Expandable Caption="{}">
-                       <Template>
-                               <Border BorderWidth="1" Foreground="LightGray" Height="{../HeightPolicy}" Width="{../WidthPolicy}" 
-                                       MouseClick="../onMouseClick">
-                                       <VerticalStack Height="{../../HeightPolicy}" Width="{../../WidthPolicy}">
-                                               <HorizontalStack Spacing="1" Height="Fit" Width="{../../../WidthPolicy}">
-                                                       <Image Margin="2" Width="12" Height="12" Path="{../../../../Image}" SvgSub="{../../../../SvgSub}"/>
-                                                       <Label Text="{../../../../Caption}" Width="{../../../../WidthPolicy}"/>
-                                               </HorizontalStack>
-                                               <Container Name="Content" Visible="false" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"/>
-                                       </VerticalStack>
-                               </Border>
-                       </Template>
-               </Expandable>-->
+               <Label Text="{Name}" Width="Stretched"/>
        </ItemTemplate>
        <ItemTemplate DataType="System.IO.DirectoryInfo" Data="GetFileSystemInfos">             
                <Expandable Caption="{Name}" >
                        <Template>
                                <VerticalStack Height="{../HeightPolicy}" Width="{../WidthPolicy}">
-                                       <HorizontalStack Spacing="1" Height="-1" Width="{../../WidthPolicy}">
+                                       <HorizontalStack Spacing="1" Height="Fit" Width="{../../WidthPolicy}">
                                                <Image Margin="2" Width="12" Height="12"
                                                        Visible="{../../../HasContent}"
                                                        Path="{../../../Image}" 
                                                <Label Text="{../../../Caption}" Width="{../../../WidthPolicy}"/>
                                        </HorizontalStack>
                                        <Container Name="Content" Visible="false"
-                                               Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"/>
+                                                       Height="{../../HeightPolicy}" Width="{../../WidthPolicy}"/>
                                </VerticalStack>
                        </Template>
-                       <ListBox Name="List" Height="Fit" Width="{../WidthPolicy}" />
+                       <HorizontalStack Height="Fit" Width="{../WidthPolicy}">
+                               <GraphicObject Width="12" Height="10"/>
+                               <ListBox Name="List" Height="Fit" Width="{../../WidthPolicy}"
+                                       Template="#Tests.Interfaces.treeList.crow" />
+                       </HorizontalStack>
                </Expandable>
        </ItemTemplate>
 </TreeView>
\ No newline at end of file
diff --git a/Tests/Interfaces/treeList.crow b/Tests/Interfaces/treeList.crow
new file mode 100755 (executable)
index 0000000..61ee12a
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<VerticalStack
+       Height="Fit" Width="{../WidthPolicy}" Name="List"/>
\ No newline at end of file
index 56e6a1ec2cf9fa907143a8e757b26ff8e2ef10cd..e60faad5ee390af35a63661a76479ad5f2b34e20 100644 (file)
     <EmbeddedResource Include="ui\Popper.template" />
     <EmbeddedResource Include="ui\MenuItem.style" />
     <EmbeddedResource Include="test.style" />
+    <EmbeddedResource Include="Interfaces\treeList.crow" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\Crow.csproj">
index c4f9e0e19382ad72899b8145e2a0ecf2b821772e..24ceb618b9d260fd78fdd33c972b56ab59f56e1a 100644 (file)
@@ -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);
index b04fe204db78a6d552fa02a00b83be753fc56950..744cd329d72510e0d77d2f050b92f384a9ae2d3d 100644 (file)
@@ -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;
                                                        }
index c7e26d5d4a1d3d08d8757900fa5a05cdee4ad301..ccc09f45b543241d0bb25f941eb9efb46bc1002f 100644 (file)
@@ -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);
                }
        }
 }