]> O.S.I.I.S - jp/crow.git/commitdiff
* GOLib.sln:
authorjpbruyere <jp.bruyere@hotmail.com>
Thu, 3 Sep 2015 10:48:04 +0000 (12:48 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Thu, 3 Sep 2015 10:48:04 +0000 (12:48 +0200)
* GOLib.csproj:
* GOLIBTest_0.cs:
* GOLIBTest_fps.cs:
* ReflexionExtensions.cs:
* Label.cs:
* test4.goml:
* GenericStack.cs:
* PrivateContainer.cs:
* CompilerServices.cs:

* Tests.csproj:
* member.svg:
* GOLIBTest_TypeViewer.cs:
* tmpMembers.goml:
* testTypeViewer.goml: Type viewer

* Group.cs:
* Window.cs:
* GraphicObject.cs: set OnLayoutChanges to public

* Point.cs: Implement length

19 files changed:
GOLib.csproj
GOLib.sln
Images/Icons/member.svg [new file with mode: 0644]
Tests/GOLIBTest_0.cs
Tests/GOLIBTest_TypeViewer.cs
Tests/GOLIBTest_fps.cs
Tests/Interfaces/test4.goml
Tests/Interfaces/testTypeViewer.goml
Tests/Interfaces/tmpMembers.goml
Tests/Tests.csproj
src/CompilerServices/CompilerServices.cs
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/Label.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/Window.cs
src/Point.cs
src/ReflexionExtensions.cs [new file with mode: 0644]

index 101fa57f6ca513e776cd9884bf2a0f899ab9f38c..60f6c6063806cd66a8352be7bb99e49bb3b10e03 100644 (file)
     <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
index 98b5962cbf5a84080a93c7cda96b76b0bf1cc7c4..3bd7afc3fdfab2966d353453141e64ba1fc79600 100644 (file)
--- a/GOLib.sln
+++ b/GOLib.sln
@@ -56,4 +56,10 @@ Global
                {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
diff --git a/Images/Icons/member.svg b/Images/Icons/member.svg
new file mode 100644 (file)
index 0000000..af654a9
--- /dev/null
@@ -0,0 +1,93 @@
+<?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>
index d8d2a913ca4aff28d7d8dfc0f976c573fd8ac5f2..7ec0de998cf092942166abd87372a858c2f38cce 100644 (file)
@@ -14,7 +14,7 @@ using go;
 using System.Threading;\r
 \r
 \r
-namespace test\r
+namespace test6\r
 {\r
        class GOLIBTest_0 : OpenTKGameWindow\r
        {\r
index 347e06dc15481826e767f28f5272ca3f2582fd18..1980f5821de5e61ad5b2e174cf133d70e4557038 100644 (file)
@@ -13,6 +13,7 @@ using System.Diagnostics;
 using go;\r
 using System.Threading;\r
 using System.Reflection;\r
+using System.Linq;\r
 \r
 \r
 namespace test\r
@@ -43,6 +44,7 @@ namespace test
 \r
                        MemberInfo mi;\r
 \r
+\r
                }\r
 \r
                [STAThread]\r
@@ -65,7 +67,18 @@ namespace test
                        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
index fd7ccf5375703035ba139a1ec520770ec2b637bc..12fdf44416e89e2d3a37a16bdb6a58eb6db4bcb5 100644 (file)
@@ -41,16 +41,6 @@ namespace test
                                        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
@@ -63,6 +53,17 @@ namespace test
                }\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
index ec4251fe6dc44ba1955d708483b4f72d2b8457c6..0cdc2545896ba6cf066d8f0c27dd6bb88d52fd52 100755 (executable)
                                                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
index 7cec728627f745f46c9f682070624bc90c28cea6..eacf49592ae9d9558ff8dc91388ba7e37cc02e8f 100755 (executable)
@@ -1,16 +1,20 @@
 <?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>
index c86f157435fd14c8f6dcab9b4dffac1df1d958dd..9b24ae33eec38be92ae393ecd771be662f1e829d 100755 (executable)
@@ -2,7 +2,8 @@
        <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
index 6e2973a4815a8c4c4f24576a274ffab80ac40ad9..1b02997224cf2bd4a4ac43f1148fe055fe618412 100644 (file)
@@ -8,7 +8,7 @@
     <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>
index b1b08d5ee4dda013fb11ca67b3406009e853699a..1aaeac99000f8a7f1dff1cd5e35180eb864a5d21 100644 (file)
@@ -4,6 +4,8 @@ using System.Reflection;
 using System.Collections;
 using System.Diagnostics;
 using System.Linq;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
 
 
 namespace go
@@ -37,6 +39,10 @@ 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 ();
@@ -154,6 +160,11 @@ namespace go
                        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;
@@ -185,14 +196,28 @@ namespace go
                                        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 {
@@ -200,7 +225,13 @@ namespace go
                                        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) {
@@ -363,6 +394,36 @@ namespace go
                        } 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;
+               }
        }
 }
 
index 3b96d548eddbfce2efcf7e7b230d1ca0cace56cf..20130576f9f928dfc1966d4456ca9bf4fd683e28 100644 (file)
@@ -125,13 +125,13 @@ namespace go
                                                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
index 457a60164cd74cf9d0dbb2811dbb0bc97dd842b5..e1e2963b3c5f19708537d01b2392244c4c3f2448 100644 (file)
@@ -456,7 +456,7 @@ namespace go
                }\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
index aac566dbdd01a112301c380755b67178744c2bf6..e7a4b2b68f4def6fbd891661319e93b30a255862 100644 (file)
@@ -120,7 +120,7 @@ namespace go
                        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
index e9951862d42e47c1d24ba2d53596fe1af040c465..c0bfe47ed2e97342c5f9c50a4139e4ca051032ae 100755 (executable)
@@ -202,7 +202,9 @@ namespace go
                                                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
index cd234d62ae767975ede6a21c3daca172b45b5c2f..025934f9322387a522e7a76fefd4c69462f9311f 100644 (file)
@@ -92,7 +92,7 @@ namespace go
                        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:                               
index 7eb910cc95749b50acc20a555e15c13bbe037967..0fd2b7808677f0ab578ad8e779fa6241a553f7af 100644 (file)
@@ -36,8 +36,19 @@ namespace go
 
                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;
index db06a05b37cc0f35e1e377aebe35c6493ce4f166..58305f0025f4a5b286fd1408251f378e603316b9 100755 (executable)
@@ -26,6 +26,9 @@ namespace go
             _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
diff --git a/src/ReflexionExtensions.cs b/src/ReflexionExtensions.cs
new file mode 100644 (file)
index 0000000..fc16c9d
--- /dev/null
@@ -0,0 +1,56 @@
+//
+//  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";
+               }
+       }
+}
+