<DebugType>None</DebugType>\r
<BaseAddress>4194304</BaseAddress>\r
</PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+ <DefineConstants>__linux__</DefineConstants>\r
+ </PropertyGroup>\r
<!-- <PropertyGroup Condition=" '$(Platform)' == 'Linux_x86' ">\r
<DefineConstants>__linux__</DefineConstants>\r
<PlatformTarget>x86</PlatformTarget>\r
<PlatformTarget>anycpu</PlatformTarget>\r
</PropertyGroup>-->\r
<ItemGroup>\r
- <Compile Include="src\EventSource.cs">\r
- <LogicalName>\r
- </LogicalName>\r
- </Compile>\r
<Compile Include="src\Colors.cs">\r
<LogicalName>\r
</LogicalName>\r
<LogicalName>\r
</LogicalName>\r
</Compile>\r
+ <Compile Include="src\GraphicObjects\Spinner.cs">\r
+ <LogicalName>\r
+ </LogicalName>\r
+ </Compile>\r
+ <Compile Include="src\DynAttribute.cs">\r
+ <LogicalName>\r
+ </LogicalName>\r
+ </Compile>\r
+ <Compile Include="src\GraphicObjects\IValueChange.cs">\r
+ <LogicalName>\r
+ </LogicalName>\r
+ </Compile>\r
</ItemGroup>\r
<ItemGroup>\r
<Reference Include="System" />\r
</LogicalName>\r
</Folder>\r
</ItemGroup>\r
- <ItemGroup>\r
- <None Include="Images\Icons\icon_alert.gif">\r
- <LogicalName>\r
- </LogicalName>\r
- </None>\r
- </ItemGroup>\r
<ItemGroup>\r
<EmbeddedResource Include="Images\Icons\question_mark.svg">\r
<LogicalName>go.image.icons.question_mark</LogicalName>\r
</EmbeddedResource>\r
+ <EmbeddedResource Include="Images\Icons\icon_alert.gif" />\r
+ <EmbeddedResource Include="Images\Icons\updown.svg" />\r
</ItemGroup>\r
<ItemGroup>\r
<ProjectReference Include="OpenTK\Source\OpenTK\OpenTK.csproj">\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
+ {232716B4-D19D-4FD7-B310-94A98FD926F0}.Release|Linux_x86.ActiveCfg = Debug|Any CPU\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
+ {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.ActiveCfg = Release|Any CPU\r
+ {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.Build.0 = Release|Any CPU\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
{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
+ {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.ActiveCfg = Release|Any CPU\r
+ {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.Build.0 = Release|Any CPU\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
EndGlobal\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 65.480012 51.479989"
+ height="51.479988"
+ width="65.480011">
+
+ <defs
+ id="defs4">
+ <filter
+ height="1.4299999"
+ y="-0.215"
+ width="1.3096"
+ x="-0.1548"
+ id="filter4391"
+ style="color-interpolation-filters:sRGB">
+ <feGaussianBlur
+ id="feGaussianBlur4393"
+ stdDeviation="3.225" />
+ </filter>
+ </defs>
+
+ <g
+ id="up">
+ <path
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter4391)"
+ d="M 32,9 7,44 57,44 Z"
+ id="path4144"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
+ </g>
+ <g
+ id="down"
+ transform="matrix(-1,0,0,-1,64,53)">
+ <path
+ sodipodi:nodetypes="cccc"
+ inkscape:connector-curvature="0"
+ id="path4142"
+ d="M 32,9 7,44 57,44 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter4391)" />
+ </g>
+</svg>
protected override void OnLoad (EventArgs e)\r
{\r
base.OnLoad (e);\r
- LoadInterface("Interfaces/test1.goml", out g);\r
+ LoadInterface("Interfaces/log.xml", out g);\r
\r
}\r
protected override void OnRenderFrame (FrameEventArgs e)\r
\r
\r
c.MouseMove += pFps_mousemove;\r
- slTest.ValueChanged += (object sender, ValueChangeEventArgs vce) => {\r
- labV.Text = vce.NewValue.ToString ("00.00");\r
- };\r
+// slTest.ValueChanged += (object sender, ValueChangeEventArgs vce) => {\r
+// labV.Text = vce.NewValue.ToString ("00.00");\r
+// };\r
\r
\r
int i = 0;\r
\r
namespace test\r
{\r
- class GOLIBTest_fps : OpenTKGameWindow\r
+ class GOLIBTest_fps : OpenTKGameWindow , IValueChange\r
{\r
#region FPS\r
- static int _fps = 0;\r
+ int _fps = 0;\r
\r
- public static int fps {\r
+ public int fps {\r
get { return _fps; }\r
set {\r
+ if (_fps == value)\r
+ return;\r
+ \r
+ int oldVal = _fps;\r
_fps = value;\r
- if (_fps > fpsMax)\r
+\r
+ if (_fps > fpsMax) {\r
fpsMax = _fps;\r
- else if (_fps < fpsMin)\r
+ ValueChanged(this, new ValueChangeEventArgs ("fpsMax", fpsMax, _fps));\r
+ } else if (_fps < fpsMin) {\r
+ ValueChanged(this, new ValueChangeEventArgs ("fpsMin", fpsMin, _fps));\r
fpsMin = _fps;\r
+ }\r
+\r
+ if (ValueChanged != null)\r
+ ValueChanged(this, new ValueChangeEventArgs ("fps", oldVal, _fps));\r
+\r
+ //ValueChanged.Raise (this, new ValueChangeEventArgs ("fps", oldVal, _fps));\r
}\r
+ }\r
+ string name = "testName";\r
\r
+ public string Name {\r
+ get {\r
+ return name;\r
+ }\r
+ set {\r
+ name = value;\r
+ }\r
}\r
\r
- public static int fpsMin = int.MaxValue;\r
- public static int fpsMax = 0;\r
+ public int fpsMin = int.MaxValue;\r
+ public int fpsMax = 0;\r
\r
- static void resetFps ()\r
+ void resetFps ()\r
{\r
fpsMin = int.MaxValue;\r
fpsMax = 0;\r
labFpsMax = g.FindByName ("labFpsMax") as Label;\r
labUpdate = g.FindByName ("labUpdate") as Label;\r
\r
+ //ValueChanged += (object sender, ValueChangeEventArgs vce) => labFps.Text = vce.NewValue.ToString ();\r
+ \r
+\r
}\r
protected override void OnRenderFrame (FrameEventArgs e)\r
{\r
\r
fps = (int)RenderFrequency;\r
\r
- labFps.Text = fps.ToString();\r
+ //labFps.Text = fps.ToString();\r
labUpdate.Text = this.updateTime.ElapsedMilliseconds.ToString() + " ms";\r
+\r
if (frameCpt > 200) {\r
- labFpsMin.Text = fpsMin.ToString();\r
- labFpsMax.Text = fpsMax.ToString();\r
+// labFpsMin.Text = fpsMin.ToString();\r
+// labFpsMax.Text = fpsMax.ToString();\r
resetFps ();\r
frameCpt = 0;\r
\r
frameCpt++;\r
}\r
\r
+ #region IValueChange implementation\r
+\r
+ public event EventHandler<ValueChangeEventArgs> ValueChanged;\r
+\r
+ #endregion\r
+\r
[STAThread]\r
static void Main ()\r
{\r
--- /dev/null
+#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
+\r
+\r
+namespace test\r
+{\r
+ interface IValueChange\r
+ {
+ }
+\r
+}
\ No newline at end of file
</HorizontalStack>\r
<HorizontalStack>\r
<Label Text="Fps:" Width = "30" VerticalAlignment="Center" TextAlignment="LeftCenter"/>\r
- <Label Name="labFps" Text="xxxx" Font="droid bold, 12"\r
+ <Label Name="labFps" Text="{fps}" Font="droid bold, 12"\r
TextAlignment="Center" Background="AoEnglish"/>\r
</HorizontalStack>\r
<HorizontalStack>\r
<Label Text="Min:" Width = "30" />\r
- <Label Name="labFpsMin" Text="xxxx" Font="droid bold, 12"\r
+ <Label Name="labFpsMin" Text="{fpsMin}" Font="droid bold, 12"\r
TextAlignment="Center" Background="AoEnglish"/>\r
</HorizontalStack>\r
<HorizontalStack>\r
<Label Text="Max:" Width = "30"/>\r
- <Label Name="labFpsMax" Text="xxxx" Font="droid bold, 12"\r
+ <Label Name="labFpsMax" Text="{fpsMax}" Font="droid bold, 12"\r
TextAlignment="Center" Background="AoEnglish"/>\r
</HorizontalStack>\r
</VerticalStack> \r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<Container Name="topContainer" HorizontalAlignment="Center" VerticalAlignment="Top"
+ Margin="2"
+ Width="600" Height="-1">
+ <Border Margin="2" BorderWidth="1" Background="0,6;0,6;0,6;0,6" Height="-1">
+ <Group Width="0" Name="logs">
+ <VerticalStack Name="VerticalStack" Width="0" Focusable="False">
+ <Label Name="line1" Width="0" Text="Line1" Margin="0"/>
+ <Label Name="line2" Width="0" Text="Line2" Margin="0"/>
+ <Label Name="line3" Width="0" Text="Line3" Margin="0"/>
+ <Label Name="line4" Width="0" Text="Line4" Margin="0"/>
+ </VerticalStack>
+ <Button Name="btOk" Background="Gray" Fit="True"
+ HorizontalAlignment="Right" VerticalAlignment="Bottom"
+ MouseClick="BtOk_MouseClick">
+ <Label Text="Ok" Margin="3" Foreground="White" />
+ </Button>
+ </Group>
+ </Border>
+</Container>
+
<OutputType>Exe</OutputType>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
- <StartupObject>test.GOLIBTest_4</StartupObject>
+ <StartupObject>test.GOLIBTest_fps</StartupObject>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<OutputPath>..\bin\$(configuration)</OutputPath>
<IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
</LogicalName>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="Interfaces\log.xml">
+ <LogicalName>
+ </LogicalName>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\">
using System;
using System.Reflection.Emit;
using System.Reflection;
+using System.Collections;
+using System.Diagnostics;
+using System.Linq;
+
namespace go
{
}
static int dynHandleCpt = 0;
- public static void CompileEventSource(EventSource es)
+ public static void CompileEventSource(DynAttribute es)
{
Type srcType = es.Source.GetType ();
#region Retrieve EventHandler parameter type
- EventInfo ei = srcType.GetEvent (es.EventName);
+ EventInfo ei = srcType.GetEvent (es.MemberName);
MethodInfo invoke = ei.EventHandlerType.GetMethod ("Invoke");
ParameterInfo[] pars = invoke.GetParameters ();
#region IL generation
ILGenerator il = dm.GetILGenerator(256);
- string src = es.Handler.Trim();
+ string src = es.Value.Trim();
if (! (src.StartsWith("{") || src.EndsWith ("}")))
- throw new Exception (string.Format("GOML:Malformed {0} Event handler: {1}", es.EventName, es.Handler));
+ throw new Exception (string.Format("GOML:Malformed {0} Event handler: {1}", es.MemberName, es.Value));
src = src.Substring (1, src.Length - 2);
string[] srcLines = src.Split (new char[] { ';' });
#endregion
- FieldInfo evtFi = getEventHandlerField (srcType, es.EventName);
+ FieldInfo evtFi = getEventHandlerField (srcType, es.MemberName);
Delegate del = dm.CreateDelegate(evtFi.FieldType);
evtFi.SetValue(es.Source, del);
}
+ public static void CreateBinding(DynAttribute binding, object _source)
+ {
+
+ Type srcType = _source.GetType ();
+ Type dstType = binding.Source.GetType ();
+
+ MemberInfo miSrc = srcType.GetMember (binding.Value).FirstOrDefault();
+ Type srcValueType = null;
+ if (miSrc.MemberType == MemberTypes.Property)
+ srcValueType = (miSrc as PropertyInfo).PropertyType;
+ else if (miSrc.MemberType == MemberTypes.Field)
+ srcValueType = (miSrc as FieldInfo).FieldType;
+ else
+ throw new Exception("unandled source type for binding");
+
+ #region Retrieve EventHandler parameter type
+ EventInfo ei = srcType.GetEvent ("ValueChanged");
+ MethodInfo evtInvoke = ei.EventHandlerType.GetMethod ("Invoke");
+ ParameterInfo[] evtParams = evtInvoke.GetParameters ();
+
+ Type handlerArgsType = evtParams [1].ParameterType;
+ #endregion
+
+ Type[] args = {typeof(object), handlerArgsType};
+ DynamicMethod dm = new DynamicMethod("dynHandle_" + dynHandleCpt,
+ typeof(void),
+ args,
+ srcType.Module, true);
+
+ //register target object reference
+ int dstIdx = Interface.References.IndexOf(binding.Source);
+
+ if (dstIdx < 0) {
+ dstIdx = Interface.References.Count;
+ Interface.References.Add (binding.Source);
+ }
+
+
+
+ #region IL generation
+ ILGenerator il = dm.GetILGenerator(256);
+
+ System.Reflection.Emit.Label labFailed = il.DefineLabel();
+ System.Reflection.Emit.Label labContinue = il.DefineLabel();
+
+ #region test if valueChange event is the correct one
+ il.Emit (OpCodes.Ldstr, binding.Value);
+ //push name from arg
+ il.Emit(OpCodes.Ldarg_1);
+ FieldInfo fiMbName = typeof(ValueChangeEventArgs).GetField("MemberName");
+ il.Emit(OpCodes.Ldfld, fiMbName);
+ MethodInfo miStrEqu = typeof(string).GetMethod("op_Inequality", new Type[] {typeof(string),typeof(string)});
+ il.Emit(OpCodes.Call, miStrEqu);
+ il.Emit(OpCodes.Brfalse_S, labContinue);
+ il.Emit(OpCodes.Br_S, labFailed);
+ il.MarkLabel(labContinue);
+ #endregion
+
+ string[] srcLines = binding.Value.Trim().Split (new char[] { ';' });
+ foreach (string srcLine in srcLines) {
+ MethodInfo infoWriteLine = typeof(System.Diagnostics.Debug).GetMethod("WriteLine", new Type[] { typeof(string) });
+
+ string statement = srcLine.Trim ();
+
+ //load target ref onto the stack
+ FieldInfo fiRefs = typeof(Interface).GetField("References");
+ il.Emit(OpCodes.Ldsfld, fiRefs);
+ il.Emit(OpCodes.Ldc_I4, dstIdx);
+
+ MethodInfo miGetRef = Interface.References.GetType().GetMethod("get_Item");
+ il.Emit(OpCodes.Callvirt, miGetRef);
+ il.Emit(OpCodes.Isinst, dstType);
+
+ //push new value
+ il.Emit(OpCodes.Ldarg_1);
+ FieldInfo fiNewValue = typeof(ValueChangeEventArgs).GetField("NewValue");
+ il.Emit(OpCodes.Ldfld, fiNewValue);
+
+ PropertyInfo piTarget = dstType.GetProperty(binding.MemberName);
+ MethodInfo miToStr = typeof(object).GetMethod("ToString",Type.EmptyTypes);
+
+ if (!srcValueType.IsValueType)
+ il.Emit(OpCodes.Castclass, srcValueType);
+ il.Emit(OpCodes.Callvirt, miToStr);
+ il.Emit(OpCodes.Callvirt, piTarget.GetSetMethod());
+ }
+ il.MarkLabel(labFailed);
+ il.Emit(OpCodes.Ret);
+
+ #endregion
+
+ Delegate del = dm.CreateDelegate(ei.EventHandlerType);
+ MethodInfo addHandler = ei.GetAddMethod ();
+ //Delegate del = dm.CreateDelegate(typeof(System.EventHandler));
+ addHandler.Invoke(_source, new object[] {del});
+ }
+
+
public static FieldInfo getEventHandlerField(Type type, string eventName)
{
FieldInfo fi;
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+\r
+namespace go\r
+{\r
+ public class DynAttribute\r
+ {\r
+ public GraphicObject Source;\r
+ public string MemberName;\r
+ public String Value;\r
+ }\r
+}\r
+++ /dev/null
-using System;\r
-using System.Collections.Generic;\r
-using System.Linq;\r
-using System.Text;\r
-\r
-namespace go\r
-{\r
- public class EventSource\r
- {\r
- public GraphicObject Source;\r
- public string EventName;\r
- public String Handler;\r
- }\r
-}\r
public override void ReadXml(System.Xml.XmlReader reader)\r
{\r
string handler = reader.GetAttribute("OnClick");\r
- Interface.EventsToResolve.Add(new EventSource \r
+ Interface.EventsToResolve.Add(new DynAttribute \r
{ \r
Source = this, \r
- Handler = handler,\r
- EventName = "OnClick"\r
+ Value = handler,\r
+ MemberName = "OnClick"\r
});\r
\r
//Container c = this as Container;\r
public event EventHandler<KeyboardKeyEventArgs> KeyUp;\r
public event EventHandler Focused;\r
public event EventHandler Unfocused;\r
+\r
#endregion\r
\r
#region public properties\r
if (string.IsNullOrEmpty (handler))\r
continue;\r
\r
- Interface.EventsToResolve.Add(new EventSource \r
+ Interface.EventsToResolve.Add(new DynAttribute \r
{ \r
Source = this, \r
- Handler = handler,\r
- EventName = ei.Name\r
+ Value = handler,\r
+ MemberName = ei.Name\r
});\r
}\r
foreach (PropertyInfo pi in this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) {\r
else\r
pi.SetValue (this, defaultValue, null);\r
} else {\r
+ if (v.StartsWith("{")) {\r
+ //binding\r
+ if (!v.EndsWith("}"))\r
+ throw new Exception (string.Format("GOML:Malformed binding: {0}", v));\r
+ \r
+ string strBinding = v.Substring (1, v.Length - 2);\r
+ Interface.Bindings.Add (new DynAttribute () {\r
+ Source = this,\r
+ MemberName = name,\r
+ Value = strBinding\r
+ });\r
+ }\r
+\r
if (pi.PropertyType == typeof(string)) {\r
pi.SetValue (this, v, null);\r
continue;\r
return tmp;\r
}\r
\r
-\r
+ public override void RegisterForLayouting (int layoutType)\r
+ {\r
+ base.RegisterForLayouting (layoutType);\r
+ }\r
\r
public override Rectangle ContextCoordinates(Rectangle r){\r
return r + ClientRectangle.Position;\r
--- /dev/null
+//
+// IValueChange.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;
+
+namespace go
+{
+ public interface IValueChange
+ {
+ event EventHandler<ValueChangeEventArgs> ValueChanged;
+ }
+}
+
hSVG = new Rsvg.Handle (ms.ToArray ());\r
imgSize = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);\r
_imgPath = resId;\r
- //loadImage (@"Images/Icons/question_mark.svg");\r
}\r
}\r
//load image via System.Drawing.Bitmap, cairo load png only\r
public NumericControl(double minimum, double maximum, double step)
: base()
{
- _minValue = minimum;
- _maxValue = maximum;
- _smallStep = step;
- _bigStep = step * 5;
+ minValue = minimum;
+ maxValue = maximum;
+ smallStep = step;
+ bigStep = step * 5;
}
#endregion
#endregion
#region private fields
- double _actualValue, _minValue, _maxValue, _smallStep, _bigStep;
+ double _actualValue, minValue, maxValue, smallStep, bigStep;
#endregion
#region public properties
[XmlAttributeAttribute()][DefaultValue(0)]
public virtual double Minimum {
- get { return _minValue; }
+ get { return minValue; }
set {
- if (_minValue == value)
+ if (minValue == value)
return;
- _minValue = value;
+ minValue = value;
}
}
[XmlAttributeAttribute()][DefaultValue(10.0)]
public virtual double Maximum
{
- get { return _maxValue; }
+ get { return maxValue; }
set {
- if (_maxValue == value)
+ if (maxValue == value)
return;
- _maxValue = value;
+ maxValue = value;
}
}
[XmlAttributeAttribute()][DefaultValue(0.5)]
public virtual double SmallIncrement
{
- get { return _smallStep; }
+ get { return smallStep; }
set {
- if (_smallStep == value)
+ if (smallStep == value)
return;
- _smallStep = value;
+ smallStep = value;
}
}
[XmlAttributeAttribute()][DefaultValue(2.0)]
public virtual double LargeIncrement
{
- get { return _bigStep; }
+ get { return bigStep; }
set {
- if (_bigStep == value)
+ if (bigStep == value)
return;
- _bigStep = value;
+ bigStep = value;
}
}
if (value == _actualValue)
return;
- Decimal oldV = (Decimal)_actualValue;
+ int oldV = Convert.ToInt32(_actualValue);
- if (value < _minValue)
- _actualValue = _minValue;
- else if (value > _maxValue)
- _actualValue = _maxValue;
+ if (value < minValue)
+ _actualValue = minValue;
+ else if (value > maxValue)
+ _actualValue = maxValue;
else
_actualValue = value;
- onValueChanged(this,new ValueChangeEventArgs(oldV,(Decimal)_actualValue));
+ onValueChanged(this,new ValueChangeEventArgs("Value", oldV, Convert.ToInt32( _actualValue)));
registerForGraphicUpdate();
}
}
--- /dev/null
+//
+// Spinner.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;
+
+namespace go
+{
+ public class Spinner : NumericControl
+ {
+ public Spinner (double minimum, double maximum, double step) :
+ base (minimum, maximum, step)
+ {
+ butUp = new Button ();
+ butUp.setChild (new Image ("go.Image.Icons.updown.svg"));
+ }
+ public Spinner () : base()
+ {
+ }
+
+ Button butUp;
+ Button butDown;
+ Label labCpt;
+
+ }
+}
+
public class TextBoxWidget : Label\r
{\r
#region CTOR\r
- public TextBoxWidget(string _initialValue, GOEvent _onTextChanged = null)\r
+ public TextBoxWidget(string _initialValue)\r
: base(_initialValue)\r
{\r
\r
{ }\r
#endregion\r
\r
- static bool _capitalOn = false; //????????????????\r
- [XmlIgnore]public static bool capitalOn\r
- {\r
- get\r
- {\r
- return _capitalOn;\r
- //Keyboard[Key.ShiftLeft] || Keyboard[Key.ShiftRight] ?\r
- //!_capitalOn : _capitalOn;\r
- }\r
- set { _capitalOn = value; }\r
- }\r
-\r
-\r
#region GraphicObject overrides\r
[XmlIgnore]public override bool HasFocus //trigger update when lost focus to errase text beam\r
{\r
protected override void onDraw (Context gr)\r
{\r
base.onDraw (gr);\r
- // gr.FontOptions.Antialias = Antialias.Subpixel;\r
- // gr.FontOptions.HintMetrics = HintMetrics.On;\r
-// gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);\r
-// gr.SetFontSize (Font.Size);\r
-\r
FontExtents fe = gr.FontExtents;\r
-\r
-\r
-\r
-// gr.MoveTo(rText.X, rText.Y + fe.Ascent);\r
-// #if _WIN32 || _WIN64\r
-// gr.ShowText(txt);\r
-// #elif __linux__\r
-// gr.ShowText(Text);\r
-// #endif\r
-// gr.Fill();\r
-\r
}\r
#endregion\r
\r
using System.Diagnostics;
using System.Collections.Generic;
using System.Xml;
+using System.Linq;
namespace go
{
public static bool ReplaceTabsWithSpace = false;
public static bool DesignerMode = false;
+ /// <summary>
+ /// Graphic objects References use in dynamic delegates for binding
+ /// </summary>
+ public static List<object> References = new List<object>();
+
public static LayoutingQueue LayoutingQueue = new LayoutingQueue();
#region Load/Save
- internal static List<EventSource> EventsToResolve;
+ internal static List<DynAttribute> EventsToResolve;
+ internal static List<DynAttribute> Bindings;
public static void Save<T>(string file, T graphicObject)
{
}
}
Type t = Type.GetType("go." + root);
- var go = Activator.CreateInstance(t);
+ //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>();
+ EventsToResolve = new List<DynAttribute>();
+ Bindings = new List<DynAttribute> ();
XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
xn.Add("", "");
if (ClassContainingHandlers == null)
return;
- foreach (EventSource es in EventsToResolve)
+ foreach (DynAttribute es in EventsToResolve)
{
- if (string.IsNullOrEmpty(es.Handler))
+ if (string.IsNullOrEmpty(es.Value))
continue;
- if (es.Handler.StartsWith ("{")) {
+ if (es.Value.StartsWith ("{")) {
CompilerServices.CompileEventSource (es);
} else {
- MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Handler, BindingFlags.NonPublic | BindingFlags.Public
+ MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Value, BindingFlags.NonPublic | BindingFlags.Public
| BindingFlags.Instance);
if (mi == null) {
- Debug.WriteLine ("Handler Method not found: " + es.Handler);
+ Debug.WriteLine ("Handler Method not found: " + es.Value);
continue;
}
- FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.EventName);
+ FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.MemberName);
Delegate del = Delegate.CreateDelegate(fi.FieldType, ClassContainingHandlers, mi);
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);
+ CompilerServices.CreateBinding (binding, ClassContainingHandlers);
+ }
}
public static GraphicObject Load(string file, Type type, object ClassContainingHandlers = null)
{
GraphicObject result;
- EventsToResolve = new List<EventSource>();
+ EventsToResolve = new List<DynAttribute>();
XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
xn.Add("", "");
if (ClassContainingHandlers == null)
return result;
- foreach (EventSource es in EventsToResolve)
+ foreach (DynAttribute es in EventsToResolve)
{
- if (string.IsNullOrEmpty(es.Handler))
+ if (string.IsNullOrEmpty(es.Value))
continue;
- if (es.Handler.StartsWith ("{")) {
+ if (es.Value.StartsWith ("{")) {
CompilerServices.CompileEventSource (es);
} else {
- MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Handler, BindingFlags.NonPublic | BindingFlags.Public
+ MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Value, BindingFlags.NonPublic | BindingFlags.Public
| BindingFlags.Instance);
if (mi == null) {
- Debug.WriteLine ("Handler Method not found: " + es.Handler);
+ Debug.WriteLine ("Handler Method not found: " + es.Value);
continue;
}
- FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.EventName);
+ FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.MemberName);
Delegate del = Delegate.CreateDelegate(fi.FieldType, ClassContainingHandlers, mi);
fi.SetValue(es.Source, del);
}
{
public class ValueChangeEventArgs: EventArgs
{
- public Decimal OldValue;
- public Decimal NewValue;
+ public string MemberName;
+ public object OldValue;
+ public object NewValue;
- public ValueChangeEventArgs (Decimal _oldValue, Decimal _newValue) : base()
+
+ public ValueChangeEventArgs (string _memberName, object _oldValue, object _newValue) : base()
{
+ MemberName = _memberName;
OldValue = _oldValue;
NewValue = _newValue;
}