]> O.S.I.I.S - jp/crow.git/commitdiff
OpenTK as submodule \nInterface static class
authorjpbruyere <jp.bruyere@hotmail.com>
Fri, 24 Apr 2015 08:04:15 +0000 (10:04 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Fri, 24 Apr 2015 08:04:15 +0000 (10:04 +0200)
.gitmodules [new file with mode: 0644]
GOLib.csproj
GOLib.sln
OpenTK [new submodule]
Tests/Tests.csproj
src/GraphicObjects/Checkbox.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Label.cs
src/Interface.cs [new file with mode: 0644]
src/OpenTKGameWindow.cs

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..d427669
--- /dev/null
@@ -0,0 +1,6 @@
+[submodule "OpenTK"]
+       path = OpenTK
+       url = git://github.com/jpbruyere/opentk.git
+[submodule "GGL"]
+       path = GGL
+       url = git://github.com/jpbruyere/GGL.git
index e30f357348f5f941c4998de9049818076a18329e..4aad615285c994ed60662c40a4b5ffc59bb49679 100644 (file)
       <LogicalName>\r
       </LogicalName>\r
     </Compile>\r
+    <Compile Include="src\Interface.cs">\r
+      <LogicalName>\r
+      </LogicalName>\r
+    </Compile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <Reference Include="System" />\r
     </EmbeddedResource>\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <ProjectReference Include="..\..\..\data\Developpements\Magic3D\OpenTK\Source\OpenTK\OpenTK.csproj">\r
+    <ProjectReference Include="OpenTK\Source\OpenTK\OpenTK.csproj">\r
       <Project>{A37A7E14-0000-0000-0000-000000000000}</Project>\r
       <Name>OpenTK</Name>\r
     </ProjectReference>\r
index 8fc87a3994d295788c28c031205cb4a6e4654a4c..7b897639a710cc23443779d81ea5689dc52a6916 100644 (file)
--- a/GOLib.sln
+++ b/GOLib.sln
@@ -9,24 +9,52 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.GOLib", "MonoDe
 EndProject\r
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Diagram", "..\MonoDevelop.Diagram\MonoDevelop.Diagram.csproj", "{232716B4-D19D-4FD7-B310-94A98FD926F0}"\r
 EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK", "OpenTK\Source\OpenTK\OpenTK.csproj", "{A37A7E14-0000-0000-0000-000000000000}"\r
+EndProject\r
 Global\r
        GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
                Debug|Linux_x86 = Debug|Linux_x86\r
                Release|Linux_x86 = Release|Linux_x86\r
+               Documentation|Any CPU = Documentation|Any CPU\r
+               Nsis|Any CPU = Nsis|Any CPU\r
        EndGlobalSection\r
        GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
                {232716B4-D19D-4FD7-B310-94A98FD926F0}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU\r
+               {232716B4-D19D-4FD7-B310-94A98FD926F0}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {232716B4-D19D-4FD7-B310-94A98FD926F0}.Documentation|Any CPU.Build.0 = Debug|Any CPU\r
+               {232716B4-D19D-4FD7-B310-94A98FD926F0}.Nsis|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {232716B4-D19D-4FD7-B310-94A98FD926F0}.Nsis|Any CPU.Build.0 = Debug|Any CPU\r
                {232716B4-D19D-4FD7-B310-94A98FD926F0}.Release|Linux_x86.ActiveCfg = Release|Linux_x86\r
                {232716B4-D19D-4FD7-B310-94A98FD926F0}.Release|Linux_x86.Build.0 = Release|Linux_x86\r
                {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU\r
                {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Linux_x86.Build.0 = Debug|Any CPU\r
+               {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Documentation|Any CPU.Build.0 = Debug|Any CPU\r
+               {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Nsis|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Nsis|Any CPU.Build.0 = Debug|Any CPU\r
                {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.ActiveCfg = Release|Linux_x86\r
                {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.Build.0 = Release|Linux_x86\r
+               {A37A7E14-0000-0000-0000-000000000000}.Debug|Linux_x86.ActiveCfg = Release|Any CPU\r
+               {A37A7E14-0000-0000-0000-000000000000}.Debug|Linux_x86.Build.0 = Release|Any CPU\r
+               {A37A7E14-0000-0000-0000-000000000000}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU\r
+               {A37A7E14-0000-0000-0000-000000000000}.Documentation|Any CPU.Build.0 = Documentation|Any CPU\r
+               {A37A7E14-0000-0000-0000-000000000000}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU\r
+               {A37A7E14-0000-0000-0000-000000000000}.Nsis|Any CPU.Build.0 = Nsis|Any CPU\r
+               {A37A7E14-0000-0000-0000-000000000000}.Release|Linux_x86.ActiveCfg = Release|Any CPU\r
+               {A37A7E14-0000-0000-0000-000000000000}.Release|Linux_x86.Build.0 = Release|Any CPU\r
                {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU\r
                {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.Build.0 = Debug|Any CPU\r
+               {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Documentation|Any CPU.Build.0 = Debug|Any CPU\r
+               {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Nsis|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Nsis|Any CPU.Build.0 = Debug|Any CPU\r
                {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.ActiveCfg = Release|Linux_x86\r
                {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.Build.0 = Release|Linux_x86\r
                {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU\r
+               {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Documentation|Any CPU.Build.0 = Debug|Any CPU\r
+               {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Nsis|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Nsis|Any CPU.Build.0 = Debug|Any CPU\r
                {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Release|Linux_x86.ActiveCfg = Release|Any CPU\r
                {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Release|Linux_x86.Build.0 = Release|Any CPU\r
        EndGlobalSection\r
diff --git a/OpenTK b/OpenTK
new file mode 160000 (submodule)
index 0000000..271fc3f
--- /dev/null
+++ b/OpenTK
@@ -0,0 +1 @@
+Subproject commit 271fc3f235118a8298219387b8de50a2af06ca5d
index d5880c466fc3b88ff12b6347e0a190a1119206a7..b65edb44417b80dab9f4f7ee4ff35db867e9631a 100644 (file)
@@ -8,7 +8,7 @@
     <OutputType>Exe</OutputType>
     <RootNamespace>Tests</RootNamespace>
     <AssemblyName>Tests</AssemblyName>
-    <StartupObject>test.GOLIBTest_3</StartupObject>
+    <StartupObject>test.GOLIBTest_4</StartupObject>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <OutputPath>..\bin\$(configuration)</OutputPath>
     <IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
     <Reference Include="System.Xml" />
     <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Drawing" />
-    <Reference Include="OpenTK.Compatibility, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4">
-      <HintPath>..\dependencies\OpenTK.Compatibility.dll</HintPath>
-    </Reference>
-    <Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4">
-      <HintPath>..\dependencies\OpenTK.dll</HintPath>
-    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="GOLIBTest_5.cs">
       <Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project>
       <Name>GOLib</Name>
     </ProjectReference>
+    <ProjectReference Include="..\OpenTK\Source\OpenTK\OpenTK.csproj">
+      <Project>{A37A7E14-0000-0000-0000-000000000000}</Project>
+      <Name>OpenTK</Name>
+    </ProjectReference>
   </ItemGroup>
 </Project>
index 68704127a7c4c2dc1bc6322a91230a5c3084af3c..91f8e45117216c0c9e4eea95bf2c2ccdf367a666 100755 (executable)
@@ -242,7 +242,7 @@ namespace go
         public override void ReadXml(System.Xml.XmlReader reader)\r
         {\r
             string handler = reader.GetAttribute("OnClick");\r
-                       GraphicObject.EventsToResolve.Add(new EventSource \r
+                       Interface.EventsToResolve.Add(new EventSource \r
             { \r
                 Source = this, \r
                 Handler = handler,\r
index 3f6bbc85ca1ed43bee52672cc0cc52fa377f4e88..3ffda14aacb4bf58d935438ac74ff00e65d176f5 100755 (executable)
@@ -54,11 +54,6 @@ namespace go
                bool yIsValid = false;\r
                #endregion\r
 \r
-               public static int TabSize = 4;\r
-               public static string LineBreak = "\r\n";\r
-               public static bool ReplaceTabsWithSpace = false;\r
-               public static bool DesignerMode = false;\r
-\r
                #region public fields\r
                public Rectangle Bounds;\r
                public Rectangle Slot = new Rectangle ();\r
@@ -249,7 +244,7 @@ namespace go
                }\r
                [XmlAttributeAttribute()][DefaultValue(false)]\r
                public virtual bool Focusable {\r
-                       get { return _focusable | DesignerMode; }\r
+                       get { return _focusable | Interface.DesignerMode; }\r
                        set { _focusable = value; }\r
                }        \r
                [XmlAttributeAttribute()][DefaultValue("Transparent")]\r
@@ -593,122 +588,6 @@ namespace go
                }\r
                #endregion\r
 \r
-               #region Load/Save\r
-\r
-               internal static List<EventSource> EventsToResolve;\r
-\r
-               public static void Save<T>(string file, T graphicObject)\r
-               {            \r
-                       XmlSerializerNamespaces xn = new XmlSerializerNamespaces();\r
-                       xn.Add("", "");\r
-                       XmlSerializer xs = new XmlSerializer(typeof(T));\r
-\r
-                       xs = new XmlSerializer(typeof(T));\r
-                       using (Stream s = new FileStream(file, FileMode.Create))\r
-                       {\r
-                               xs.Serialize(s, graphicObject, xn);\r
-                       }\r
-               }\r
-               public static GraphicObject Load(string path)\r
-               {\r
-                       string root = "Object";\r
-                       using (Stream s = new FileStream (path, FileMode.Open)) {\r
-                               using (XmlReader reader = XmlReader.Create (s)) {\r
-                                       while (reader.Read()) {\r
-                                               // first element is the root element\r
-                                               if (reader.NodeType == XmlNodeType.Element) {\r
-                                                       root = reader.Name;\r
-                                                       break;\r
-                                               }\r
-                                       }\r
-                               }\r
-                       }\r
-                       Type t = Type.GetType("go." + root);\r
-                       var go = Activator.CreateInstance(t);\r
-                       return Load(path, t);\r
-               }\r
-               public static void Load<T>(string file, out T result, object ClassContainingHandlers = null)\r
-               {\r
-                       EventsToResolve = new List<EventSource>();\r
-\r
-                       XmlSerializerNamespaces xn = new XmlSerializerNamespaces();\r
-                       xn.Add("", "");\r
-                       XmlSerializer xs = new XmlSerializer(typeof(T));            \r
-\r
-                       using (Stream s = new FileStream(file, FileMode.Open))\r
-                       {\r
-                               result = (T)xs.Deserialize(s);\r
-                       }\r
-\r
-                       if (ClassContainingHandlers == null)\r
-                               return;\r
-\r
-                       foreach (EventSource es in EventsToResolve)\r
-                       {\r
-                               if (string.IsNullOrEmpty(es.Handler))\r
-                                       continue;\r
-\r
-                               if (es.Handler.StartsWith ("{")) {\r
-                                       CompilerServices.CompileEventSource (es);\r
-                               } else {                                        \r
-                                       MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Handler, BindingFlags.NonPublic | BindingFlags.Public\r
-                                                      | BindingFlags.Instance);\r
-\r
-                                       if (mi == null) {\r
-                                               Debug.WriteLine ("Handler Method not found: " + es.Handler);\r
-                                               continue;\r
-                                       }\r
-\r
-                                       FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.EventName);\r
-                                       Delegate del = Delegate.CreateDelegate(fi.FieldType, ClassContainingHandlers, mi);\r
-                                       fi.SetValue(es.Source, del);\r
-                               }\r
-                       }\r
-               }\r
-\r
-               public static GraphicObject Load(string file, Type type, object ClassContainingHandlers = null)\r
-               {\r
-                       GraphicObject result;\r
-                       EventsToResolve = new List<EventSource>();\r
-\r
-                       XmlSerializerNamespaces xn = new XmlSerializerNamespaces();\r
-                       xn.Add("", "");\r
-                       XmlSerializer xs = new XmlSerializer(type);            \r
-\r
-                       using (Stream s = new FileStream(file, FileMode.Open))\r
-                       {\r
-                               result = (GraphicObject)xs.Deserialize(s);\r
-                       }\r
-\r
-                       if (ClassContainingHandlers == null)\r
-                               return result;\r
-\r
-                       foreach (EventSource es in EventsToResolve)\r
-                       {\r
-                               if (string.IsNullOrEmpty(es.Handler))\r
-                                       continue;\r
-\r
-                               if (es.Handler.StartsWith ("{")) {\r
-                                       CompilerServices.CompileEventSource (es);\r
-                               } else {                                        \r
-                                       MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Handler, BindingFlags.NonPublic | BindingFlags.Public\r
-                                               | BindingFlags.Instance);\r
-\r
-                                       if (mi == null) {\r
-                                               Debug.WriteLine ("Handler Method not found: " + es.Handler);\r
-                                               continue;\r
-                                       }\r
-\r
-                                       FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.EventName);\r
-                                       Delegate del = Delegate.CreateDelegate(fi.FieldType, ClassContainingHandlers, mi);\r
-                                       fi.SetValue(es.Source, del);\r
-                               }\r
-                       }\r
-                       return result;\r
-               }\r
-\r
-               #endregion\r
-\r
                public override string ToString ()\r
                {\r
                        return Name == "unamed" ? this.GetType ().ToString() : Name;\r
@@ -732,7 +611,7 @@ namespace go
                                if (string.IsNullOrEmpty (handler))\r
                                        continue;\r
                                        \r
-                               GraphicObject.EventsToResolve.Add(new EventSource \r
+                               Interface.EventsToResolve.Add(new EventSource \r
                                        { \r
                                                Source = this, \r
                                                Handler = handler,\r
index aa93a7e9c661704ada3fbdb9869020b7760ffa06..ee62a266584054042436d610ce4e01ab46dd5251 100755 (executable)
@@ -78,7 +78,7 @@ namespace go
         {\r
             get {                              \r
                                return lines == null ? \r
-                                       _text : lines.Aggregate((i, j) => i + GraphicObject.LineBreak + j);\r
+                                       _text : lines.Aggregate((i, j) => i + Interface.LineBreak + j);\r
                        }\r
             set\r
             {\r
@@ -247,7 +247,7 @@ namespace go
                                        te = new TextExtents();\r
 \r
                                        foreach (string s in lines) {\r
-                                               string l = s.Replace("\t", new String (' ', GraphicObject.TabSize));\r
+                                               string l = s.Replace("\t", new String (' ', Interface.TabSize));\r
 \r
 #if _WIN32 || _WIN64\r
                                                TextExtents tmp = gr.TextExtents(str.ToUtf8());\r
@@ -432,7 +432,7 @@ namespace go
                        gr.FontMatrix = new Matrix(widthRatio * Font.Size, 0, 0, heightRatio * Font.Size, 0, 0);\r
 \r
                        for (int i = 0; i < lines.Count; i++) {                         \r
-                               string l = lines [i].Replace ("\t", new String (' ', GraphicObject.TabSize));\r
+                               string l = lines [i].Replace ("\t", new String (' ', Interface.TabSize));\r
                                if (selRelease >= 0 && i >= selectionStart.Y && i <= selectionEnd.Y) {                                  \r
                                        gr.Color = selColor;\r
                                        int lineLength = (int)gr.TextExtents (l).XAdvance;\r
@@ -536,11 +536,15 @@ namespace go
 \r
                        currentLine = (int)(mouseLocalPos.Y / fe.Height);\r
 \r
+                       //fix cu\r
+                       if (currentLine >= lines.Count)\r
+                               currentLine = lines.Count - 1;\r
+\r
                        for (int i = 0; i < lines[currentLine].Length; i++)\r
                        {\r
                                string c = lines [currentLine].Substring (i, 1);\r
                                if (c == "\t")\r
-                                       c = new string (' ', GraphicObject.TabSize);\r
+                                       c = new string (' ', Interface.TabSize);\r
                                \r
                                #if _WIN32 || _WIN64\r
                                byte[] c = System.Text.UTF8Encoding.UTF8.GetBytes(Text.Substring(i, 1));\r
@@ -590,7 +594,7 @@ namespace go
                                {\r
                                        string c = lines [currentLine].Substring (i, 1);\r
                                        if (c == "\t")\r
-                                               c = new string (' ', GraphicObject.TabSize);\r
+                                               c = new string (' ', Interface.TabSize);\r
                                        #if _WIN32 || _WIN64\r
                                        byte[] c = System.Text.UTF8Encoding.UTF8.GetBytes(Text.Substring(i, 1));\r
                                        te = gr.TextExtents(c);\r
diff --git a/src/Interface.cs b/src/Interface.cs
new file mode 100644 (file)
index 0000000..8f86238
--- /dev/null
@@ -0,0 +1,154 @@
+//
+//  Interface.cs
+//
+//  Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+//  Copyright (c) 2015 jp
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+using System;
+using System.Xml.Serialization;
+using System.IO;
+using System.Reflection;
+using System.Diagnostics;
+using System.Collections.Generic;
+using System.Xml;
+
+namespace go
+{
+       public static class Interface
+       {
+               public static int TabSize = 4;
+               public static string LineBreak = "\r\n";
+               public static bool ReplaceTabsWithSpace = false;
+               public static bool DesignerMode = false;
+
+               #region Load/Save
+
+               internal static List<EventSource> EventsToResolve;
+
+               public static void Save<T>(string file, T graphicObject)
+               {            
+                       XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
+                       xn.Add("", "");
+                       XmlSerializer xs = new XmlSerializer(typeof(T));
+
+                       xs = new XmlSerializer(typeof(T));
+                       using (Stream s = new FileStream(file, FileMode.Create))
+                       {
+                               xs.Serialize(s, graphicObject, xn);
+                       }
+               }
+               public static GraphicObject Load(string path)
+               {
+                       string root = "Object";
+                       using (Stream s = new FileStream (path, FileMode.Open)) {
+                               using (XmlReader reader = XmlReader.Create (s)) {
+                                       while (reader.Read()) {
+                                               // first element is the root element
+                                               if (reader.NodeType == XmlNodeType.Element) {
+                                                       root = reader.Name;
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+                       Type t = Type.GetType("go." + root);
+                       var go = Activator.CreateInstance(t);
+                       return Load(path, t);
+               }
+               public static void Load<T>(string file, out T result, object ClassContainingHandlers = null)
+               {
+                       EventsToResolve = new List<EventSource>();
+
+                       XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
+                       xn.Add("", "");
+                       XmlSerializer xs = new XmlSerializer(typeof(T));            
+
+                       using (Stream s = new FileStream(file, FileMode.Open))
+                       {
+                               result = (T)xs.Deserialize(s);
+                       }
+
+                       if (ClassContainingHandlers == null)
+                               return;
+
+                       foreach (EventSource es in EventsToResolve)
+                       {
+                               if (string.IsNullOrEmpty(es.Handler))
+                                       continue;
+
+                               if (es.Handler.StartsWith ("{")) {
+                                       CompilerServices.CompileEventSource (es);
+                               } else {                                        
+                                       MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Handler, BindingFlags.NonPublic | BindingFlags.Public
+                                               | BindingFlags.Instance);
+
+                                       if (mi == null) {
+                                               Debug.WriteLine ("Handler Method not found: " + es.Handler);
+                                               continue;
+                                       }
+
+                                       FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.EventName);
+                                       Delegate del = Delegate.CreateDelegate(fi.FieldType, ClassContainingHandlers, mi);
+                                       fi.SetValue(es.Source, del);
+                               }
+                       }
+               }
+               public static GraphicObject Load(string file, Type type, object ClassContainingHandlers = null)
+               {
+                       GraphicObject result;
+                       EventsToResolve = new List<EventSource>();
+
+                       XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
+                       xn.Add("", "");
+                       XmlSerializer xs = new XmlSerializer(type);            
+
+                       using (Stream s = new FileStream(file, FileMode.Open))
+                       {
+                               result = (GraphicObject)xs.Deserialize(s);
+                       }
+
+                       if (ClassContainingHandlers == null)
+                               return result;
+
+                       foreach (EventSource es in EventsToResolve)
+                       {
+                               if (string.IsNullOrEmpty(es.Handler))
+                                       continue;
+
+                               if (es.Handler.StartsWith ("{")) {
+                                       CompilerServices.CompileEventSource (es);
+                               } else {                                        
+                                       MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Handler, BindingFlags.NonPublic | BindingFlags.Public
+                                               | BindingFlags.Instance);
+
+                                       if (mi == null) {
+                                               Debug.WriteLine ("Handler Method not found: " + es.Handler);
+                                               continue;
+                                       }
+
+                                       FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.EventName);
+                                       Delegate del = Delegate.CreateDelegate(fi.FieldType, ClassContainingHandlers, mi);
+                                       fi.SetValue(es.Source, del);
+                               }
+                       }
+                       return result;
+               }
+
+               #endregion
+       }
+}
+
index 234c4be20d996b4b4889ff758da835665595f880..644c65c8db76b8f173d779033e52f6fb6c01c8da 100755 (executable)
@@ -300,13 +300,13 @@ namespace go
                        \r
                public void LoadInterface<T>(string path, out T result)\r
                {\r
-                       GraphicObject.Load<T> (path, out result, this);\r
+                       Interface.Load<T> (path, out result, this);\r
                        AddWidget (result as GraphicObject);\r
                }\r
                public T LoadInterface<T> (string Path)\r
                {\r
                        T result;\r
-                       GraphicObject.Load<T> (Path, out result, this);\r
+                       Interface.Load<T> (Path, out result, this);\r
                        AddWidget (result as GraphicObject);\r
                        return result;\r
                }\r