]> O.S.I.I.S - jp/crow.git/commitdiff
listbox update
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 2 Jun 2015 10:28:36 +0000 (12:28 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 2 Jun 2015 10:28:36 +0000 (12:28 +0200)
Templates/Listbox.goml
Tests/GOLIBTest_4.cs
Tests/GOLIBTest_Listbox.cs [new file with mode: 0644]
Tests/Interfaces/test_Listbox.goml [new file with mode: 0755]
Tests/Tests.csproj
src/CompilerServices/CompilerServices.cs
src/Interface.cs

index 0746d24e36a4cd6cb51e61b72abaed16a86cfc72..43f8425b5928132abf33e1c9fe6287e878bce0f8 100755 (executable)
@@ -1,3 +1,5 @@
 <?xml version="1.0"?>\r
-<VerticalStack Name="List">\r
-</VerticalStack>
\ No newline at end of file
+<Border  Fit="True" Background="Gray">\r
+       <VerticalStack Name="List" Margin="5">\r
+       </VerticalStack>\r
+</Border>
\ No newline at end of file
index 9b189a92f3c5b23e20d70bd3319392cde6bba6e2..096d249edaee7988c6bef3941b93ec313e4dd892 100644 (file)
@@ -17,15 +17,7 @@ using System.Collections.Generic;
 \r
 namespace test\r
 {\r
-       public class ClsItem\r
-       {\r
-               public string Field;\r
-               public ClsItem(){\r
-               }\r
-               public ClsItem(string str){\r
-                       Field = str;\r
-               }\r
-       }\r
+\r
        class GOLIBTest_4 : OpenTKGameWindow, IValueChange\r
        {\r
                #region IValueChange implementation\r
diff --git a/Tests/GOLIBTest_Listbox.cs b/Tests/GOLIBTest_Listbox.cs
new file mode 100644 (file)
index 0000000..cd7cd83
--- /dev/null
@@ -0,0 +1,97 @@
+#define MONO_CAIRO_DEBUG_DISPOSE\r
+\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+using OpenTK;\r
+using OpenTK.Graphics.OpenGL;\r
+using OpenTK.Input;\r
+\r
+using System.Diagnostics;\r
+\r
+//using GGL;\r
+using go;\r
+using System.Threading;\r
+using System.Collections.Generic;\r
+\r
+\r
+namespace test\r
+{\r
+       public class ClsItem : IValueChange\r
+       {\r
+               #region IValueChange implementation\r
+\r
+               public event EventHandler<ValueChangeEventArgs> ValueChanged;\r
+\r
+               #endregion\r
+\r
+               public string field;\r
+\r
+               public string Field {\r
+                       get {\r
+                               return field;\r
+                       }\r
+                       set {\r
+                               field = value;\r
+                               ValueChanged.Raise(this, new ValueChangeEventArgs ("Field", null, field));\r
+                       }\r
+               }\r
+\r
+               public ClsItem(){\r
+               }\r
+               public ClsItem(string str){\r
+                       Field = str;\r
+               }\r
+       }\r
+       \r
+       class GOLIBTest_Listbox : OpenTKGameWindow, IValueChange\r
+       {\r
+               #region IValueChange implementation\r
+\r
+               public event EventHandler<ValueChangeEventArgs> ValueChanged;\r
+\r
+               #endregion\r
+       \r
+               public GOLIBTest_Listbox ()\r
+                       : base(1024, 600,"test")\r
+               {}\r
+\r
+               public List<ClsItem> TestList = new List<ClsItem>(new ClsItem[] \r
+                       {\r
+                               new ClsItem("string 1"),\r
+                               new ClsItem("string 2"),\r
+                               new ClsItem("string 3")\r
+                       });\r
+               ListBox g;\r
+\r
+               protected override void OnLoad (EventArgs e)\r
+               {\r
+                       base.OnLoad (e);\r
+                       LoadInterface("Interfaces/test_Listbox.goml", out g);\r
+\r
+                       ValueChanged.Raise(this, new ValueChangeEventArgs ("TestList", null, TestList));\r
+                       TestList [1].Field = "test string";\r
+               }\r
+               protected override void OnRenderFrame (FrameEventArgs e)\r
+               {\r
+                       GL.Clear (ClearBufferMask.ColorBufferBit);\r
+                       base.OnRenderFrame (e);\r
+                       SwapBuffers ();\r
+               }\r
+\r
+               protected override void OnUpdateFrame (FrameEventArgs e)\r
+               {\r
+                       base.OnUpdateFrame (e);\r
+               }\r
+\r
+               [STAThread]\r
+               static void Main ()\r
+               {\r
+                       Console.WriteLine ("starting example");\r
+\r
+                       using (GOLIBTest_Listbox win = new GOLIBTest_Listbox( )) {\r
+                               win.Run (30.0);\r
+                       }\r
+               }\r
+       }\r
+}
\ No newline at end of file
diff --git a/Tests/Interfaces/test_Listbox.goml b/Tests/Interfaces/test_Listbox.goml
new file mode 100755 (executable)
index 0000000..d336ae3
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>\r
+       <ListBox Data="{TestList}">\r
+       </ListBox>\r
index 2efca8efdc89c93ea85eb4b1aed74c1a30f72b3b..d19fb844c2346a0474e09927611186dc15b38663 100644 (file)
@@ -8,7 +8,7 @@
     <OutputType>Exe</OutputType>
     <RootNamespace>Tests</RootNamespace>
     <AssemblyName>Tests</AssemblyName>
-    <StartupObject>test.GOLIBTest_4</StartupObject>
+    <StartupObject>test.GOLIBTest_Listbox</StartupObject>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <OutputPath>..\bin\$(configuration)</OutputPath>
     <IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
       <LogicalName>
       </LogicalName>
     </Compile>
+    <Compile Include="GOLIBTest_Listbox.cs">
+      <LogicalName>
+      </LogicalName>
+    </Compile>
   </ItemGroup>
   <ItemGroup>
     <None Include="image\u.svg">
       </LogicalName>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="Interfaces\test_Listbox.goml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+      <LogicalName>
+      </LogicalName>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Interfaces\">
index 36c88030b2eef36edf1be79807845cf95bc1ef5e..f8bbcdf01de18798a37d425f9ed3e4e854d676c5 100644 (file)
@@ -237,8 +237,18 @@ namespace go
 
                                if (!srcValueType.IsValueType)
                                        il.Emit(OpCodes.Castclass, srcValueType);
-                               il.Emit(OpCodes.Callvirt, miToStr);
+                               if (piTarget.PropertyType == typeof(string))
+                                       il.Emit(OpCodes.Callvirt, miToStr);
                                il.Emit(OpCodes.Callvirt, piTarget.GetSetMethod());
+
+                               //initialize target with actual value
+                               if (miSrc.MemberType == MemberTypes.Property)
+                                       piTarget.GetSetMethod().Invoke(binding.Source, new object[] { (miSrc as PropertyInfo).GetGetMethod().Invoke(_source,null)});
+                               else if (miSrc.MemberType == MemberTypes.Field){ 
+                                       MethodInfo miSetTarget = piTarget.GetSetMethod();
+                                       FieldInfo fiSource = miSrc as FieldInfo;
+                                       miSetTarget.Invoke(binding.Source, new object[] { fiSource.GetValue(_source)});
+                               }
                        }
                        il.MarkLabel(labFailed);
                        il.Emit(OpCodes.Ret);
index a9da051a67000a07df2a5964788df305500957f9..0d0425ed4f4e704a5d49000df19ad31e0a317962 100644 (file)
@@ -139,16 +139,21 @@ namespace go
                                        fi.SetValue(es.Source, del);
                                }
                        }
-
-                       foreach (DynAttribute binding in Bindings) {
-//                             Type tSource = binding.Source.GetType ();
-//                             if (!tSource.GetInterfaces ().Any (i => i.Name == "IValueChange")){
-//                                     Debug.WriteLine ("Binding source does not implement IValueChange.");
-//                                     continue;
-//                             }
-                               //MemberInfo mi = binding.Source.GetType ().GetMember (binding.MemberName);
+                       while (Bindings.Count > 0) {
+                               DynAttribute binding = Bindings [0];
+                               Bindings.RemoveAt (0);
                                CompilerServices.CreateBinding (binding, hostClass);
                        }
+//                     foreach (DynAttribute binding in Bindings) {
+////                           Type tSource = binding.Source.GetType ();
+////                           if (!tSource.GetInterfaces ().Any (i => i.Name == "IValueChange")){
+////                                   Debug.WriteLine ("Binding source does not implement IValueChange.");
+////                                   continue;
+////                           }
+//                             //MemberInfo mi = binding.Source.GetType ().GetMember (binding.MemberName);
+//                             CompilerServices.CreateBinding (binding, hostClass);
+//                     }
+//                     Bindings.Clear ();
                }
                public static GraphicObject Load(Stream stream, Type type, object hostClass = null)
                {
@@ -185,17 +190,22 @@ namespace go
                                        fi.SetValue(es.Source, del);
                                }
                        }
-
-                       foreach (DynAttribute binding in Bindings) {
-                               //                              Type tSource = binding.Source.GetType ();
-                               //                              if (!tSource.GetInterfaces ().Any (i => i.Name == "IValueChange")){
-                               //                                      Debug.WriteLine ("Binding source does not implement IValueChange.");
-                               //                                      continue;
-                               //                              }
-                               //MemberInfo mi = binding.Source.GetType ().GetMember (binding.MemberName);
+                       while (Bindings.Count > 0) {
+                               DynAttribute binding = Bindings [0];
+                               Bindings.RemoveAt (0);
                                CompilerServices.CreateBinding (binding, hostClass);
                        }
 
+//                     foreach (DynAttribute binding in Bindings) {
+//                             //                              Type tSource = binding.Source.GetType ();
+//                             //                              if (!tSource.GetInterfaces ().Any (i => i.Name == "IValueChange")){
+//                             //                                      Debug.WriteLine ("Binding source does not implement IValueChange.");
+//                             //                                      continue;
+//                             //                              }
+//                             //MemberInfo mi = binding.Source.GetType ().GetMember (binding.MemberName);
+//                             CompilerServices.CreateBinding (binding, hostClass);
+//                     }
+//                     Bindings.Clear ();
                        return result;
                }