--- /dev/null
+[submodule "OpenTK"]
+ path = OpenTK
+ url = git://github.com/jpbruyere/opentk.git
+[submodule "GGL"]
+ path = GGL
+ url = git://github.com/jpbruyere/GGL.git
<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
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
--- /dev/null
+Subproject commit 271fc3f235118a8298219387b8de50a2af06ca5d
<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>
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
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
}\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
}\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
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
{\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
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
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
\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
{\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
--- /dev/null
+//
+// 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
+ }
+}
+
\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