<Compile Include="src\TextChangeEventArgs.cs" />\r
<Compile Include="src\ValueChangeEventArgs.cs" />\r
<Compile Include="src\LayoutChangeEventArgs.cs" />\r
+ <Compile Include="src\ReflexionExtensions.cs" />\r
</ItemGroup>\r
<ItemGroup>\r
<Reference Include="System" />\r
<EmbeddedResource Include="Templates\Scrollbar.goml" />\r
<EmbeddedResource Include="Templates\AnalogMeter0.goml" />\r
<EmbeddedResource Include="Images\meter.svg" />\r
+ <EmbeddedResource Include="Images\Icons\member.svg" />\r
</ItemGroup>\r
</Project>\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
EndGlobalSection\r
+ GlobalSection(MonoDevelopProperties) = preSolution\r
+ Policies = $0\r
+ $0.StandardHeader = $1\r
+ $1.Text = @ \n ${FileName}\n \n Author:\n ${AuthorName} <${AuthorEmail}>\n\n Copyright (c) ${Year} ${CopyrightHolder}\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+ $1.IncludeInNewFiles = True\r
+ EndGlobalSection\r
EndGlobal\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<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"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="64"
+ height="64"
+ viewBox="0 0 63.999998 63.999998"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="member.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.9604882"
+ inkscape:cx="-66.406882"
+ inkscape:cy="33.211154"
+ inkscape:document-units="px"
+ inkscape:current-layer="svg2"
+ showgrid="false"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0"
+ units="px"
+ inkscape:window-width="1280"
+ inkscape:window-height="1009"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1" />
+ <g
+ id="ctor">
+ <rect
+ style="opacity:1;fill:#3fff69;fill-opacity:1;stroke:#000000;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:0.74509804"
+ id="rect4185"
+ width="58"
+ height="58"
+ x="3"
+ y="3" />
+ <text
+ sodipodi:linespacing="125%"
+ id="text4176"
+ y="51.758148"
+ x="7.4200573"
+ style="font-style:normal;font-weight:normal;font-size:57.0553093px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ xml:space="preserve"><tspan
+ y="51.758148"
+ x="7.4200573"
+ id="tspan4178"
+ sodipodi:role="line">#</tspan></text>
+ </g>
+ <circle
+ style="opacity:1;fill:#70bbff;fill-opacity:1;stroke:#000000;stroke-width:5.99999905;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:0.74509804"
+ id="property"
+ cx="32"
+ cy="32"
+ r="29" />
+ <metadata
+ id="metadata4158">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <rect
+ style="opacity:1;fill:#ff543f;fill-opacity:1;stroke:#000000;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:0.74509804"
+ id="method"
+ width="58"
+ height="58"
+ x="3"
+ y="3" />
+ <path
+ style="fill:#f7ff3f;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2.06100774px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 22.471298,1.892924 8.8054675,32.128113 30.276085,31.763018 10.90935,62.764759 56.012472,21.268821 30.415746,22.059981 47.587854,2.0447011 Z"
+ id="event"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccc" />
+</svg>
using System.Threading;\r
\r
\r
-namespace test\r
+namespace test6\r
{\r
class GOLIBTest_0 : OpenTKGameWindow\r
{\r
using go;\r
using System.Threading;\r
using System.Reflection;\r
+using System.Linq;\r
\r
\r
namespace test\r
\r
MemberInfo mi;\r
\r
+\r
}\r
\r
[STAThread]\r
get { return Type.Name; }\r
}\r
public MemberInfo[] Members {\r
- get { return Type.GetProperties (BindingFlags.Public | BindingFlags.Instance); }\r
+ get {\r
+ MemberInfo[] mi = Properties.Cast<MemberInfo> ().Concat (Methods.Cast<MemberInfo> ()).ToArray(); \r
+ return mi;\r
+ }\r
+ }\r
+ public MethodInfo[] Methods {\r
+ get { return Type.GetMethods (BindingFlags.Public | BindingFlags.Instance).Where (m => !m.IsSpecialName).ToArray(); }\r
}\r
+ public PropertyInfo[] Properties {\r
+ get { return Type.GetProperties (); }\r
+ }\r
+ \r
}\r
+\r
}
\ No newline at end of file
ValueChanged.Raise(this, new ValueChangeEventArgs ("fps", _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 int fpsMin = int.MaxValue;\r
public int fpsMax = 0;\r
}\r
#endregion\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 GOLIBTest_fps ()\r
: base(600, 400,"test")\r
{}\r
TextAlignment="Center" Background="AoEnglish"/>\r
</HorizontalStack>\r
</VerticalStack>\r
- <HorizontalStack Height="350" Width="250">\r
+ <HorizontalStack Height="350" Width="150">\r
<Scroller Name="scroller1" Background="DimGray" Height="0" Width="0" \r
Margin="5" VerticalScrolling="true" ScrollY="{../scrollbar1.Scroll}">\r
<VerticalStack Name="colors" VerticalAlignment="Top" Margin="1">\r
<?xml version="1.0"?>
- <VerticalStack Height="-1" Width="200" Name="hstack" Margin="0" Spacing="0">
+ <VerticalStack Height="-1" Width="250" 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="{Members}" Width="0" Height="0" ItemTemplate="Interfaces/tmpMembers.goml">
+ <ListBox Data="{Members}" Width="0" Height="400" 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>
+ <HorizontalStack Width="0" Height="0">
+ <Scroller Name="scroller1" Height="0" Width="0"
+ Margin="10" VerticalScrolling="true" ScrollY="{../scrollbar1.Scroll}">
+ <VerticalStack Width="0" Height="-1" Name="List" Margin="0" VerticalAlignment="Top"/>
+ </Scroller>
+ <Scrollbar Name="scrollbar1" Scroll="{../scroller1.ScrollY}" MaximumScroll="{../scroller1.MaximumScroll}"
+ Orientation="Vertical" Width="10" />
+ </HorizontalStack>
</Border>
</Template>
</ListBox>
<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
+ <Label Text="{Name}" Width="0" Height="-1" Margin="2" Background="Gray"/>\r
+ <Label Text="{MemberType}" Width="-1" Height="-1" Margin="0"/>\r
+ <Image Width="8" Height="8" Path="#go.Images.Icons.member.svg" SvgSub="{GetIcon}"/>\r
</HorizontalStack>\r
\r
<OutputType>Exe</OutputType>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
- <StartupObject>test.GOLIBTest_4</StartupObject>
+ <StartupObject>test.GOLIBTest_Window</StartupObject>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<OutputPath>..\bin\$(configuration)</OutputPath>
<IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
using System.Collections;
using System.Diagnostics;
using System.Linq;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
namespace go
}
static int dynHandleCpt = 0;
+ /// <summary>
+ /// Compile events expression in GOML attributes
+ /// </summary>
+ /// <param name="es">Event binding details</param>
public static void CompileEventSource(DynAttribute es)
{
Type srcType = es.Source.GetType ();
evtFi.SetValue(es.Source, del);
}
+ /// <summary>
+ /// Resolves GOML property bindings afler loading
+ /// </summary>
+ /// <param name="binding">Binding details</param>
+ /// <param name="_source">Data source for binding</param>
public static void ResolveBinding(DynAttribute binding, object _source)
{
object srcGO = null;
throw new Exception ("Syntax error in binding, expected 'go dot member'");
}
+ if (srcGO == null) {
+ Debug.WriteLine ("Invalid Binding Source: " + binding.Value);
+ return;
+ }
Type srcType = srcGO.GetType ();
Type dstType = binding.Source.GetType ();
MemberInfo miSrc = srcType.GetMember (statement).FirstOrDefault ();
MemberInfo miDst = dstType.GetMember (binding.MemberName).FirstOrDefault ();
+ object srcVal = null; //value in source member
+
+ #region search for extensions methods if member not found in type
+ if (miSrc == null && !string.IsNullOrEmpty(statement))
+ {
+ Assembly a = Assembly.GetExecutingAssembly();
+ miSrc = CompilerServices.GetExtensionMethods(a, srcType).FirstOrDefault();
+ }
+ #endregion
+
#region initialize target with actual value
- object srcVal = null;
+
if (miSrc == null)
srcVal = srcGO;//if no member is provided for binding, source raw value is taken
else {
srcVal = (miSrc as PropertyInfo).GetGetMethod ().Invoke (srcGO, null);
else if (miSrc.MemberType == MemberTypes.Field)
srcVal = (miSrc as FieldInfo).GetValue (srcGO);
- else
+ else if (miSrc.MemberType == MemberTypes.Method){
+ MethodInfo mthSrc = miSrc as MethodInfo;
+ if (mthSrc.IsDefined(typeof(ExtensionAttribute), false))
+ srcVal = mthSrc.Invoke(null, new object[] {srcGO});
+ else
+ srcVal = mthSrc.Invoke(srcGO, null);
+ }else
throw new Exception ("unandled source member type for binding");
}
if (miDst.MemberType == MemberTypes.Property) {
} while(fi == null);
return fi;
}
+
+ /// <summary>
+ /// Gets extension methods defined in assembley for extendedType
+ /// </summary>
+ /// <returns>Extension methods enumerable</returns>
+ /// <param name="assembly">Assembly</param>
+ /// <param name="extendedType">Extended type to search for</param>
+ public static IEnumerable<MethodInfo> GetExtensionMethods(Assembly assembly,
+ Type extendedType)
+ {
+ IEnumerable<MethodInfo> query = null;
+ Type curType = extendedType;
+
+ do {
+ query = from type in assembly.GetTypes ()
+ where type.IsSealed && !type.IsGenericType && !type.IsNested
+ from method in type.GetMethods (BindingFlags.Static
+ | BindingFlags.Public | BindingFlags.NonPublic)
+ where method.IsDefined (typeof(ExtensionAttribute), false)
+ where method.GetParameters () [0].ParameterType == curType
+ select method;
+
+ if (query.Count() > 0)
+ break;
+
+ curType = curType.BaseType;
+ } while (curType != null);
+
+ return query;
+ }
}
}
else if (gobjs.Length == 1) {\r
int sz = Children.Where(ch=>ch.Visible).Except (gobjs).Sum (g => g.Slot.Width);\r
if (sz < Slot.Width) {\r
- gobjs [0].Slot.Width = Slot.Width - sz - Spacing;\r
+ gobjs [0].Slot.Width = Slot.Width - sz - (Children.Count+1) * Spacing;\r
int idx = Children.IndexOf (gobjs [0]);\r
if (idx > 0 && idx < Children.Count - 1)\r
gobjs [0].Slot.Width -= Spacing;\r
-\r
if (gobjs [0].LastSlots.Width != gobjs [0].Slot.Width) {\r
gobjs [0].bmp = null;\r
+ //gobjs [0].OnLayoutChanges (LayoutingType.Width);\r
gobjs [0].LastSlots.Width = gobjs [0].Slot.Width;\r
}\r
}\r
}\r
\r
/// <summary> trigger dependant sizing component update </summary>\r
- protected virtual void OnLayoutChanges(LayoutingType layoutType)\r
+ public virtual void OnLayoutChanges(LayoutingType layoutType)\r
{\r
if (Parent==null)\r
return;\r
return tmp;\r
}\r
\r
- protected override void OnLayoutChanges (LayoutingType layoutType)\r
+ public override void OnLayoutChanges (LayoutingType layoutType)\r
{\r
base.OnLayoutChanges (layoutType);\r
\r
lines [selectionEnd.Y].Substring (selectionEnd.X, lines [selectionEnd.Y].Length - selectionEnd.X);\r
l++;\r
for (int c = 0; c < linesToRemove-1; c++)\r
- lines.RemoveAt (l); \r
+ lines.RemoveAt (l);\r
+ currentCol = selectionStart.X;\r
+ currentLine = selectionStart.Y;\r
} else \r
lines [l] = lines [l].Remove (selectionStart.X, selectionEnd.X - selectionStart.X);\r
currentCol = selectionStart.X;\r
return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * Margin, child.Slot.Height + 2 * (Margin));
}
- protected override void OnLayoutChanges (LayoutingType layoutType)
+ public override void OnLayoutChanges (LayoutingType layoutType)
{
switch (layoutType) {
case LayoutingType.Width:
void Window_MouseMove (object sender, OpenTK.Input.MouseMoveEventArgs e)
{
+
+// if ((e.Position - this.Slot.TopLeft).Length < 3)
+// System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.SizeNWSE;
+// else
+// System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
+
if (!e.Mouse.IsButtonDown (MouseButton.Left))
return;
+
+ //
+
+ System.Windows.Forms.Cursor.Show();// = System.Windows.Forms.Cursors.SizeAll;
+
this.TopContainer.redrawClip.AddRectangle (this.ScreenCoordinates(this.Slot));
this.Left += e.XDelta;
this.Top += e.YDelta;
_y = y;\r
}\r
\r
+ public int Length {\r
+ get { return (int)Math.Sqrt (Math.Pow (_x, 2) + Math.Pow (_y, 2)); }\r
+ }\r
public static implicit operator Cairo.Point(Point p)\r
{\r
return new Cairo.Point(p.X, p.Y);\r
--- /dev/null
+//
+// ReflexionExtensions.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.Reflection;
+
+namespace go
+{
+ public static class ReflexionExtensions
+ {
+ public static string GetIcon(this MemberInfo mi)
+ {
+ switch (mi.MemberType) {
+ case MemberTypes.Constructor:
+ return "ctor";
+ case MemberTypes.Event:
+ return "event";
+ case MemberTypes.Field:
+ return "field";
+ case MemberTypes.Method:
+ return "method";
+ case MemberTypes.Property:
+ return "property";
+ case MemberTypes.TypeInfo:
+ break;
+ case MemberTypes.Custom:
+ break;
+ case MemberTypes.NestedType:
+ break;
+ case MemberTypes.All:
+ break;
+ default:
+ return "pubfld";
+ }
+ return "notset";
+ }
+ }
+}
+