]> O.S.I.I.S - jp/crow.git/commitdiff
Item template property for listbox, added ItemTemplate for testTypeViewer
authorjpbruyere <jp.bruyere@hotmail.com>
Fri, 21 Aug 2015 14:13:12 +0000 (16:13 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Fri, 21 Aug 2015 14:13:12 +0000 (16:13 +0200)
Tests/GOLIBTest_TypeViewer.cs
Tests/Interfaces/itemTmp.goml [new file with mode: 0755]
Tests/Interfaces/testTypeViewer.goml
Tests/Interfaces/tmpMembers.goml [new file with mode: 0755]
Tests/Tests.csproj
src/GraphicObjects/ListBox.cs
src/GraphicObjects/TemplatedControl.cs

index 26f8c7cfaadd02c50b33f517d37f8ef9e3083026..347e06dc15481826e767f28f5272ca3f2582fd18 100644 (file)
@@ -12,6 +12,7 @@ using System.Diagnostics;
 //using GGL;\r
 using go;\r
 using System.Threading;\r
+using System.Reflection;\r
 \r
 \r
 namespace test\r
@@ -22,13 +23,13 @@ namespace test
                        : base(1024, 600,"test")\r
                {}\r
 \r
-               Border g;\r
-               Type type;\r
+               VerticalStack g;\r
+               TypeContainer type;\r
 \r
                protected override void OnLoad (EventArgs e)\r
                {\r
                        base.OnLoad (e);\r
-                       type = typeof (GraphicObject);\r
+                       type = new TypeContainer(typeof (GraphicObject));\r
 \r
                        this.AddWidget(Interface.Load ("Interfaces/testTypeViewer.goml", type));\r
                        //LoadInterface("Interfaces/testTypeViewer.goml", out g);\r
@@ -39,6 +40,9 @@ namespace test
                        GL.Clear (ClearBufferMask.ColorBufferBit);\r
                        base.OnRenderFrame (e);\r
                        SwapBuffers ();\r
+\r
+                       MemberInfo mi;\r
+\r
                }\r
 \r
                [STAThread]\r
@@ -51,4 +55,17 @@ namespace test
                        }\r
                }\r
        }\r
+       public class TypeContainer\r
+       {\r
+               public Type Type;\r
+               public TypeContainer(Type _type){\r
+                       Type = _type;\r
+               }\r
+               public string Name {\r
+                       get { return Type.Name; }\r
+               }\r
+               public MemberInfo[] Members {\r
+                       get { return Type.GetProperties (BindingFlags.Public | BindingFlags.Instance); }\r
+               }\r
+       }\r
 }
\ No newline at end of file
diff --git a/Tests/Interfaces/itemTmp.goml b/Tests/Interfaces/itemTmp.goml
new file mode 100755 (executable)
index 0000000..5e064e2
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>\r
+<Border BorderWidth="3">\r
+       <Label Text="{Name}" Focusable="true" Width="0" Height="-1" Margin="0"\r
+                       MouseEnter="{Background=Red}"\r
+                       MouseLeave="{Background=Transparent}"\r
+       />\r
+</Border>\r
+\r
index c4438c4802dc4e0b464eaaaf9209838566298538..7cec728627f745f46c9f682070624bc90c28cea6 100755 (executable)
@@ -1,12 +1,17 @@
 <?xml version="1.0"?>
 
-<Border  Background="SteelBlue"
-       Width="150" Height="250" BorderWidth="2">
-       <VerticalStack Height="0" Width="0" Name="hstack" Margin="0" Spacing="5">
-               <Border Height="-1" Width="0" >
+       <VerticalStack Height="-1" Width="200" Name="hstack" Margin="0" Spacing="0">
+               <Border Height="-1" Width="0" BorderWidth="2" CornerRadius="10">
                        <Label Name="labName" Text="{Name}" Width="0" Height="-1"/>
                </Border>
-               <ListBox Data="{GetMembers ()}" Width="0" Height="-1">
+               <ListBox Data="{Members}" Width="0" Height="0" ItemTemplate="Interfaces/tmpMembers.goml">
+                       <Template>
+                               <Border Width="0" Height="0" BorderWidth="1" Margin="1" MinimumSize="0;100" >
+                                       <Scroller  Name="scroller1" Height="0" Width="0"  
+                                        Margin="5" VerticalScrolling="true"  >
+                                               <VerticalStack Width="0" Height="-1" Name="List" Margin="1" VerticalAlignment="Top"/>
+                                       </Scroller>
+                               </Border>
+                       </Template>
                </ListBox>
        </VerticalStack>
-</Border>
\ No newline at end of file
diff --git a/Tests/Interfaces/tmpMembers.goml b/Tests/Interfaces/tmpMembers.goml
new file mode 100755 (executable)
index 0000000..c86f157
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>\r
+       <HorizontalStack Width="0" Height="-1" Focusable="true" \r
+                       MouseEnter="{Background=Red}"\r
+                       MouseLeave="{Background=Transparent}">\r
+               <Label Text="{Name}" Width="0" Height="-1" Margin="2"/>\r
+               <Label Text="{MemberType}" Width="-1" Height="-1" Margin="2"/>\r
+       </HorizontalStack>\r
+\r
index 17d12993995dbbbd899c02b498a5dc51bfaed46e..8fa16474d53646657a9322ba858fe4085ff266f4 100644 (file)
@@ -8,7 +8,7 @@
     <OutputType>Exe</OutputType>
     <RootNamespace>Tests</RootNamespace>
     <AssemblyName>Tests</AssemblyName>
-    <StartupObject>test.GOLIBTest_TypeViewer</StartupObject>
+    <StartupObject>test.GOLIBTest_4</StartupObject>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <OutputPath>..\bin\$(configuration)</OutputPath>
     <IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
     <None Include="Interfaces\testTypeViewer.goml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="Interfaces\tmpMembers.goml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Interfaces\itemTmp.goml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Interfaces\" />
index a66fe7d4efd5e2b7ff18584abcdf6b24c07fa325..117dd626ec3e733d1e932cb4ec97b968d4311d49 100644 (file)
@@ -26,6 +26,7 @@ using System.ComponentModel;
 namespace go
 {
        [DefaultTemplate("#go.Templates.Listbox.goml")]
+       //[DefaultTemplate("#go.Templates.ItemTemplate.goml")]
        public class ListBox : TemplatedControl
        {
                Group _list;
@@ -44,13 +45,19 @@ namespace go
 
                ICollection data;
                int _selectedIndex;
+               string _itemTemplate;
 
+               [XmlAttributeAttribute][DefaultValue("#go.Templates.ItemTemplate.goml")]
+               public string ItemTemplate {
+                       get { return _itemTemplate; }
+                       set { _itemTemplate = value; }
+               }
                public int SelectedIndex{
                        get { return _selectedIndex; }
                        set { _selectedIndex = value; }
                }
 
-               [XmlAttributeAttribute()][DefaultValue(null)]
+               [XmlAttributeAttribute][DefaultValue(null)]
                public ICollection Data {
                        get {
                                return data;
@@ -62,7 +69,8 @@ namespace go
                                if (data == null)
                                        return;
                                foreach (var item in data) {
-                                       GraphicObject g = Interface.Load ("#go.Templates.ItemTemplate.goml", item);
+                                       GraphicObject g = Interface.Load (ItemTemplate, item);
+                                       //GraphicObject g = Interface.Load ("#go.Templates.Listbox.goml", item);
 //                                     g.Tag = item;
 //                                     g.MouseClick += (object sender, OpenTK.Input.MouseButtonEventArgs e) => {
 //                                             
index 7c50a2ea8c67725f002900684443c2239c4e43cd..d8af0bdf53ffd2579aa25fab47d9b3c881b2b761 100644 (file)
@@ -37,6 +37,15 @@ namespace go
                        Path = path;
                }
        }
+       [AttributeUsage(AttributeTargets.Class)]
+       public class DefaultItemTemplate : Attribute
+       {
+               public string Path = "";
+               public DefaultItemTemplate(string path)
+               {
+                       Path = path;
+               }
+       }
 
        public abstract class TemplatedControl : PrivateContainer, IXmlSerializable
        {
@@ -77,10 +86,7 @@ namespace go
 
                #region IXmlSerializable
 
-               public override System.Xml.Schema.XmlSchema GetSchema()
-               {
-                       return null;
-               }
+               public override System.Xml.Schema.XmlSchema GetSchema(){ return null; }
                public override void ReadXml(System.Xml.XmlReader reader)
                {
                        //Template could be either an attribute containing path or expressed inlined