]> O.S.I.I.S - jp/crow.git/commitdiff
debug, code clean, geo 2d with double versions
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 1 Oct 2019 23:01:06 +0000 (01:01 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 1 Oct 2019 23:01:06 +0000 (01:01 +0200)
60 files changed:
Crow.sln
Crow/Crow.csproj
Crow/Default.style
Crow/Templates/ColorPicker.template
Crow/Templates/Spinner.template
Crow/src/BmpPicture.cs
Crow/src/CompilerServices/CompilerServices.cs
Crow/src/ExtensionsMethods.cs
Crow/src/Gradient.cs
Crow/src/GraphicObjects/MessageBox.cs
Crow/src/GraphicObjects/NumericControl.cs
Crow/src/GraphicObjects/Scroller.cs
Crow/src/GraphicObjects/Slider.cs
Crow/src/GraphicObjects/Spinner.cs
Crow/src/GraphicObjects/TabItem.cs
Crow/src/GraphicObjects/TabView.cs
Crow/src/GraphicObjects/TemplatedGroup.cs
Crow/src/GraphicObjects/TestCairoPatch.cs
Crow/src/GraphicObjects/Widget.cs
Crow/src/IML/IMLContext.cs
Crow/src/Input/KeyEventArgs.cs
Crow/src/Instantiator.cs
Crow/src/Interface.cs
Crow/src/Mono.Cairo/Context.cs
Crow/src/Mono.Cairo/Point.cs [deleted file]
Crow/src/Mono.Cairo/PointD.cs [deleted file]
Crow/src/ParsingException.cs
Crow/src/Picture.cs
Crow/src/Point.cs
Crow/src/PointD.cs [new file with mode: 0644]
Crow/src/Rectangle.cs
Crow/src/RectangleD.cs [new file with mode: 0644]
Crow/src/Size.cs
Crow/src/SizeD.cs [new file with mode: 0644]
Crow/src/SolidColor.cs
Crow/src/StbImage.cs [new file with mode: 0644]
Crow/src/backends/IBackend.cs
Crow/src/backends/win32/User32/Mouse.cs
Crow/src/backends/win32/User32/RawInput.cs
Crow/src/backends/win32/User32/Structs/BroadcastDeviceInterface.cs
Crow/src/backends/win32/User32/Structs/DeviceMode.cs
Crow/src/backends/win32/User32/Structs/RawHid.cs
Crow/src/backends/win32/WinBackend.cs
Crow/src/backends/xcb/MouseCursor.cs
Crow/src/backends/xcb/XCBBackend.cs
Crow/src/backends/xcb/XCBKeyboard.cs
Crow/src/backends/xlib/X11Keyboard.cs
Crow/src/backends/xlib/XLibBackend.cs
Crow/src/rsvg/Handle.cs
CrowIDE/CrowIDE.csproj
CrowIDE/src/DesignInterface.cs
CrowIDE/src/Editors/ImlVisualEditor.cs
CrowIDE/src/Project.cs
Directory.Build.props [new file with mode: 0644]
Samples/ControlLib/Class1.cs [new file with mode: 0644]
Samples/ControlLib/ControlLib.csproj [new file with mode: 0644]
Samples/HelloWorld/HelloWorld.csproj
Samples/HelloWorld/ui/helloworld.crow
Samples/ShowCase/ShowCase.csproj
Samples/common/ui/Interfaces/GraphicObject/0.crow

index 465d115b9dcaf65c85e709db7d9f91442e3e745c..6481a424f2c2e384a4d8eddd239ec73edbf0f90a 100644 (file)
--- a/Crow.sln
+++ b/Crow.sln
@@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShowCase", "Samples\ShowCas
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrowIDE", "CrowIDE\CrowIDE.csproj", "{C40A3F21-0558-4265-9251-718C1564D10A}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlLib", "Samples\ControlLib\ControlLib.csproj", "{91F1CE07-EECE-4F1D-A3EE-7239B563654A}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
@@ -33,6 +35,10 @@ Global
                {C40A3F21-0558-4265-9251-718C1564D10A}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {C40A3F21-0558-4265-9251-718C1564D10A}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {C40A3F21-0558-4265-9251-718C1564D10A}.Release|Any CPU.Build.0 = Release|Any CPU
+               {91F1CE07-EECE-4F1D-A3EE-7239B563654A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {91F1CE07-EECE-4F1D-A3EE-7239B563654A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {91F1CE07-EECE-4F1D-A3EE-7239B563654A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {91F1CE07-EECE-4F1D-A3EE-7239B563654A}.Release|Any CPU.Build.0 = Release|Any CPU
        EndGlobalSection
        GlobalSection(MonoDevelopProperties) = preSolution
                Policies = $0
@@ -75,5 +81,6 @@ Global
        GlobalSection(NestedProjects) = preSolution
                {F535A8AB-CD93-49AB-B1B0-FFF9AE51ED6A} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6}
                {56329D48-D382-4850-93DE-59C453894E8A} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6}
+               {91F1CE07-EECE-4F1D-A3EE-7239B563654A} = {B2C7855A-2878-47FD-AD32-9A83DB4AB8C6}
        EndGlobalSection
 EndGlobal
index e6ecc933d41c3b7e2f18bca2996fffb1b1d9c25b..b084eed8993d3e290547958d65369fa7c81d01cf 100644 (file)
@@ -1,70 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
 <Project Sdk="Microsoft.NET.Sdk">
-  <Import Project="$(SolutionDir)netfx.props" />
-  <PropertyGroup>
-    <TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
-    <AssemblyName>Crow</AssemblyName>
-    <Copyright></Copyright>
-    <AssemblyVersion>0.8.3.2</AssemblyVersion>    
-    <Description>C.R.O.W. is a widget toolkit and rendering engine entirely developed in C# with templates, styles, compositing, and bindings.</Description>        
-                    
-    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>        
-    <EnableDefaultItems>false</EnableDefaultItems>
-    <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
-        
-    <Authors>Jean-Philippe Bruyère</Authors>
-    <Title>C# Rapid Open Widget Toolkit</Title>
-       <License>MIT</License>
-    <PackageId>Crow</PackageId>
-    <PackageTags>GUI Widget toolkit Interface C# .Net Mono</PackageTags>
-    <PackageVersion>$(AssemblyVersion)-beta</PackageVersion>
-    <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-    <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
-    <PackageProjectUrl>https://github.com/jpbruyere/Crow/wiki</PackageProjectUrl>        
-    <PackageLicense>https://opensource.org/licenses/MIT</PackageLicense>
-    <PackageIconUrl>https://jpbruyere.github.io/Crow/images/crow.png</PackageIconUrl>
-    <PackageCopyright>Copyright 2013-2019</PackageCopyright>
-    <PackageReleaseNotes>xcb backend</PackageReleaseNotes>    
-    <RepositoryUrl>https://github.com/jpbruyere/Crow</RepositoryUrl>           
-       
-       <LangVersion>7.2</LangVersion>
-        
-    <OutputPath>$(SolutionDir)build\$(Configuration)\</OutputPath>        
-    <DefineConstants>DESIGN_MODE</DefineConstants>
-  </PropertyGroup>   
-  
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugType>full</DebugType>
-    <DefineConstants>TRACE;DESIGN_MODE;_DEBUG_CLIP_RECTANGLE;_DEBUG_FOCUS;_DEBUG_DRAGNDROP;DEBUG;NETFRAMEWORK;NET471</DefineConstants>
-    <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>    
-  </PropertyGroup>
-       
-  <ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
+       <PropertyGroup>
+               <TargetFrameworks>netstandard2.0</TargetFrameworks>
+               <AssemblyName>Crow</AssemblyName>
+               <Copyright>
+               </Copyright>
+               <AssemblyVersion>0.8.4.1</AssemblyVersion>
+               <Description>C.R.O.W. is a widget toolkit and rendering engine entirely developed in C# with templates, styles, compositing, and bindings.</Description>
+               <EnableDefaultItems>false</EnableDefaultItems>
+               <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
+               <Title>C# Rapid Open Widget Toolkit</Title>
+               <License>MIT</License>
+               <PackageId>Crow</PackageId>
+               <PackageTags>GUI Widget toolkit Interface C# .Net Mono</PackageTags>
+               <PackageVersion>$(AssemblyVersion)-beta</PackageVersion>
+               <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
+               <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
+               <PackageProjectUrl>https://github.com/jpbruyere/Crow/wiki</PackageProjectUrl>
+               <PackageLicense>https://opensource.org/licenses/MIT</PackageLicense>
+               <PackageIconUrl>https://jpbruyere.github.io/Crow/images/crow.png</PackageIconUrl>
+               <PackageCopyright>Copyright 2013-2019</PackageCopyright>
+               <PackageReleaseNotes>xcb backend</PackageReleaseNotes>
+               <DefineConstants>DESIGN_MODE</DefineConstants>
+       </PropertyGroup>
+       <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+               <DebugType>full</DebugType>
+               <DefineConstants>TRACE;_DEBUG_BINDING;DESIGN_MODE;_DEBUG_CLIP_RECTANGLE;_DEBUG_FOCUS;_DEBUG_DRAGNDROP;NET471;DEBUG;NETFRAMEWORK;NET461</DefineConstants>
+               <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
+       </PropertyGroup>
+       <!--  <ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
     <Reference Include="System" />
     <Reference Include="mscorlib" />
     <Reference Include="System.Data" />
     <Reference Include="System.Xml" />
     <Reference Include="Microsoft.CSharp" />        
-  </ItemGroup> 
-  
-  <ItemGroup Condition="$(TargetFramework.StartsWith('netstandard'))">
-    <PackageReference Include="System.Reflection.Emit.ILGeneration" Version="4.3.0" />
-    <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
-  </ItemGroup>
-       
-  <ItemGroup>
-    <Compile Include="src\**\*.cs" Exclude="src\Mono.Cairo\NativeMethods-internal.cs" />
-        
-    <EmbeddedResource Include="Templates\*.*">
-      <LogicalName>Crow.%(Filename).template</LogicalName>
-    </EmbeddedResource>
-    
-    <EmbeddedResource Include="Default.style" />
-    <EmbeddedResource Include="Icons\*.*" />
-  </ItemGroup>  
-  <ItemGroup>
-    <Compile Remove="src\backends\win32\User32\Structs\RawInputDevice.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="src\backends\win32\User32\Structs\RawInputDevice.cs" />
-  </ItemGroup>
-</Project>
+  </ItemGroup> -->
+       <ItemGroup Condition="$(TargetFramework.StartsWith('netstandard'))">
+               <PackageReference Include="System.Reflection.Emit.ILGeneration" Version="4.6.0" />
+               <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.6.0" />
+       </ItemGroup>
+       <ItemGroup>
+               <Compile Include="src\**\*.cs" Exclude="src\Mono.Cairo\NativeMethods-internal.cs" />
+               <EmbeddedResource Include="Templates\*.*">
+                       <LogicalName>Crow.%(Filename).template</LogicalName>
+               </EmbeddedResource>
+               <EmbeddedResource Include="Default.style" />
+               <EmbeddedResource Include="Icons\*.*" />
+       </ItemGroup>
+       <ItemGroup>
+               <Compile Remove="src\backends\win32\User32\Structs\RawInputDevice.cs" />
+       </ItemGroup>
+       <ItemGroup>
+               <None Include="src\backends\win32\User32\Structs\RawInputDevice.cs" />
+       </ItemGroup>
+</Project>
\ No newline at end of file
index 4a03e706ff7c1adbce330a4d4ae3ac18f940eaaa..77b0d3cbd3fdc6b2229a96c834b320627176551f 100644 (file)
@@ -88,8 +88,8 @@ Splitter {
        Margin = "1";
        Background = "Grey";
 }
-Spinner {
-       Foreground = "DimGrey";
+Spinner {      
+       Foreground = "Grey";
 }
 TabView {
        CacheEnabled = "false";
@@ -176,7 +176,7 @@ HSVSpinner {
        SmallIncrement = "0.01";
 }
 TxtInFileDialog {
-       Margine = "1";
+       Margin = "1";
        Font = "droid, 12";
 }
 CheckBoxAlt {
index cf9dd76039a8805d3a2f650837ac2862559811ba..b43555177cbda2e63cc7fa0b6b1e50c4c7be8135 100755 (executable)
                                <Label Focusable="true" Selectable="true" Text="{./SelectedColor}" />                           
                                <HorizontalStack Height="Fit">
                                        <Label Text="R" Width="Fit"/>
-                                       <Spinner Style="ColorSpinner" Value="{²./R}" Width="40"  />
+                                       <Spinner Style="ColorSpinner" Value="{²./R}" Width="46"  />
                                </HorizontalStack>
                                <HorizontalStack Height="Fit">
                                        <Label Text="G" Width="Fit"/>
-                                       <Spinner Style="ColorSpinner" Value="{²./G}" Width="40"  />
+                                       <Spinner Style="ColorSpinner" Value="{²./G}" Width="46"  />
                                </HorizontalStack>
                                <HorizontalStack Height="Fit">
                                        <Label Text="B" Width="Fit"/>
-                                       <Spinner Style="ColorSpinner" Value="{²./B}" Width="40"  />
+                                       <Spinner Style="ColorSpinner" Value="{²./B}" Width="46"  />
                                </HorizontalStack>
                                <HorizontalStack Height="Fit">
                                        <Label Text="A" Width="Fit"/>
-                                       <Spinner Style="ColorSpinner" Value="{²./A}" Width="40"  />
+                                       <Spinner Style="ColorSpinner" Value="{²./A}" Width="46"  />
                                </HorizontalStack>
                                <HorizontalStack Height="Fit">
                                        <Label Text="H" Width="Fit"/>
-                                       <Spinner Style="HSVSpinner" Value="{²./H}" Width="40"  />
+                                       <Spinner Style="HSVSpinner" Value="{²./H}" Width="46"  />
                                </HorizontalStack>
                                <HorizontalStack Height="Fit">
                                        <Label Text="S" Width="Fit"/>
-                                       <Spinner Style="HSVSpinner" Value="{²./S}" Width="40"  />
+                                       <Spinner Style="HSVSpinner" Value="{²./S}" Width="46"  />
                                </HorizontalStack>
                                <HorizontalStack Height="Fit">
                                        <Label Text="V" Width="Fit"/>
-                                       <Spinner Style="HSVSpinner" Value="{²./V}" Width="40"  />
+                                       <Spinner Style="HSVSpinner" Value="{²./V}" Width="46"  />
                                </HorizontalStack>
                        </VerticalStack>
                </HorizontalStack>
index 60d7ccf9eba299a8fcf6751ef4674cca6f0afb17..613b622969be83262c9d532c6f7905ecb17d5d89 100755 (executable)
@@ -1,12 +1,12 @@
 <?xml version="1.0"?>
-<HorizontalStack MinimumSize="40,13" Name="hstack" Margin="0" Spacing="0">
+<HorizontalStack MinimumSize="40,13" Name="hstack" Margin="0" Spacing="0" Background="{./Background}">
        <Border BorderWidth="1" Width="75%"  Background="White" 
                Foreground="{./Foreground}" Margin="0">
                <TextBox Foreground="{./Foreground}" Font="{./Font}" Width="Stretched"
                        Text="{²./Value}" TextAlignment="Right" Margin="0"/>
        </Border>
-       <VerticalStack MinimumSize="13,13" Width="25%" Height="Stretched" Spacing="0" Margin="0">
-               <Shape Style="ArrowBut" Height="50%" MouseDown="./onUp" Path="M 5.5,0.5 L 10.5,6.5 L 0.5,6.5 Z"/>                       
-               <Shape Style="ArrowBut" Height="50%" MouseDown="./onDown" Path="M 0.5,0.5 L 10.5,0.5 L 5.5,6.5 Z"/>                     
+       <VerticalStack MinimumSize="13,13" Width="25%" Height="Stretched" Spacing="1" Margin="1">
+               <Shape Style="ArrowBut" Height="50%" MouseDown="./onUp" Size="10,10" Path="M 4.5,0.5 L 9.5,9.5 L 0.5,9.5 Z"/>                   
+               <Shape Style="ArrowBut" Height="50%" MouseDown="./onDown" Size="10,10" Path="M 0.5,0.5 L 9.5,0.5 L 4.5,9.5 Z"/>
        </VerticalStack>
 </HorizontalStack>
index 540087dc6814c480461fa7997c2df5b5efd63526..a67f66f1a912fb16efbc6db33171831ad14352ca 100644 (file)
@@ -26,6 +26,7 @@
 
 using System;
 using System.IO;
+using System.Runtime.InteropServices;
 using Crow.Cairo;
 
 namespace Crow
@@ -49,7 +50,9 @@ namespace Crow
                /// </summary>
                /// <param name="path">image path, may be embedded</param>
                public BmpPicture (string path) : base(path)
-               {}
+               {
+                       Load ();
+               }
                #endregion
                /// <summary>
                /// load the image for rendering from the path given as argument
@@ -63,12 +66,26 @@ namespace Crow
                                Dimensions = sp.Dims;
                                return;
                        }
-                       using (Stream stream = Interface.StaticGetStreamFromPath (Path)) {                              
+                       using (Stream stream = Interface.StaticGetStreamFromPath (Path)) {
+                               using (StbImage stbi = new StbImage (stream)) {
+                                       image = new byte [stbi.Size];
+                                       //rgba to argb for cairo.
+                                       for (int i = 0; i < stbi.Size; i+=4) {
+                                               image [i] = Marshal.ReadByte (stbi.Handle, i + 2);
+                                               image [i + 1] = Marshal.ReadByte (stbi.Handle, i + 1);
+                                               image [i + 2] = Marshal.ReadByte (stbi.Handle, i);
+                                               image [i + 3] = Marshal.ReadByte (stbi.Handle, i + 3);
+                                       }
+                                       Dimensions = new Size (stbi.Width, stbi.Height);
+                               }
+
                                //loadBitmap (new System.Drawing.Bitmap (stream));      
                        }
                        sharedResources [Path] = new sharedPicture (image, Dimensions);
                }
 
+
+
                //load image via System.Drawing.Bitmap, cairo load png only
                /*void loadBitmap (System.Drawing.Bitmap bitmap)
                {
index 8819e86dbf89dccb3f0749cd9097d047c4d55c06..e1048eba08d979d09b44675302a0f7e2b1a99744 100644 (file)
@@ -131,7 +131,6 @@ namespace Crow.IML
                internal static Type [] argsValueChange = { typeof (object), miInvokeValueChange.GetParameters () [1].ParameterType };
                internal static FieldInfo fiVCNewValue = typeof (ValueChangeEventArgs).GetField ("NewValue");
                internal static FieldInfo fiVCMbName = typeof (ValueChangeEventArgs).GetField ("MemberName");
-               internal static MethodInfo miValueChangeAdd = eiValueChange.GetAddMethod ();
 
                internal static EventInfo eiDSChange = typeof (Widget).GetEvent ("DataSourceChanged");
                internal static MethodInfo miInvokeDSChange = eiDSChange.EventHandlerType.GetMethod ("Invoke");
@@ -918,7 +917,7 @@ namespace Crow.IML
                                if (a.IsDynamic)
                                        continue;
                                foreach (Type expT in a.GetExportedTypes ()) {
-                                       if (expT.Name != strDataType)
+                                       if (expT.Name != strDataType && expT.FullName != strDataType)
                                                continue;
                                        if (!knownTypes.ContainsKey(strDataType))
                                                knownTypes.Add (strDataType, expT);
index ac0aafd0a45e2c089fbf00e80e094c7f8f3c0a8a..001573714d93501cf310c152c669ffe31235a558 100644 (file)
@@ -43,41 +43,41 @@ namespace Crow
                        }else
                                ctx.Rectangle (r.X, r.Y, r.Width, r.Height);
                }
-               public static double GetLength(this Cairo.PointD p){
+               public static double GetLength(this PointD p){
                        return Math.Sqrt (Math.Pow (p.X, 2) + Math.Pow (p.Y, 2));
                }
-               public static Cairo.PointD GetPerp(this Cairo.PointD p){
-                       return new Cairo.PointD(-p.Y, p.X);
+               public static PointD GetPerp(this PointD p){
+                       return new PointD(-p.Y, p.X);
                }
-               public static Cairo.PointD GetNormalized(this Cairo.PointD p){
+               public static PointD GetNormalized(this PointD p){
                        double length = p.GetLength();
                        p.X /= length;
                        p.Y /= length;
                        return p;
                }
-               public static Cairo.PointD Substract(this Cairo.PointD p1, Cairo.PointD p2){
-                       return new Cairo.PointD(p1.X - p2.X, p1.Y - p2.Y);
+               public static PointD Substract(this PointD p1, PointD p2){
+                       return new PointD(p1.X - p2.X, p1.Y - p2.Y);
                }
-               public static Cairo.PointD Divide(this Cairo.PointD p1, double d){
-                       return new Cairo.PointD(p1.X / d, p1.Y / d);
+               public static PointD Divide(this PointD p1, double d){
+                       return new PointD(p1.X / d, p1.Y / d);
                }
-               public static Cairo.PointD Add(this Cairo.PointD p1, Cairo.PointD p2){
-                       return new Cairo.PointD(p1.X + p2.X, p1.Y + p2.Y);
+               public static PointD Add(this PointD p1, PointD p2){
+                       return new PointD(p1.X + p2.X, p1.Y + p2.Y);
                }
-               public static Cairo.PointD Multiply(this Cairo.PointD p1, double v){
-                       return new Cairo.PointD(p1.X * v, p1.Y * v);
+               public static PointD Multiply(this PointD p1, double v){
+                       return new PointD(p1.X * v, p1.Y * v);
                }
-               public static void DrawCote(this Cairo.Context ctx, Cairo.PointD p1, Cairo.PointD p2,
+               public static void DrawCote(this Cairo.Context ctx, PointD p1, PointD p2,
                        double stroke = 1.0, bool fill = false, double arrowWidth = 3.0, double arrowLength = 7.0)
                {                       
-                       Cairo.PointD vDir = p2.Substract(p1);
+                       PointD vDir = p2.Substract(p1);
                        vDir = vDir.GetNormalized ();
-                       Cairo.PointD vPerp = vDir.GetPerp ();
+                       PointD vPerp = vDir.GetPerp ();
 
-                       Cairo.PointD pA0 = p1.Add(vDir.Multiply(arrowLength));
-                       Cairo.PointD pA1 = p2.Substract(vDir.Multiply(arrowLength));
+                       PointD pA0 = p1.Add(vDir.Multiply(arrowLength));
+                       PointD pA1 = p2.Substract(vDir.Multiply(arrowLength));
 
-                       Cairo.PointD vA = vPerp.Multiply (arrowWidth);
+                       PointD vA = vPerp.Multiply (arrowWidth);
 
                        ctx.MoveTo (p1);
                        ctx.LineTo (pA0.Add (vA));
@@ -104,17 +104,17 @@ namespace Crow
                        ctx.LineWidth = stroke;
                        ctx.Stroke ();
                }
-               public static void DrawCoteInverse(this Cairo.Context ctx, Cairo.PointD p1, Cairo.PointD p2,
+               public static void DrawCoteInverse(this Cairo.Context ctx, PointD p1, PointD p2,
                        double stroke = 1.0, bool fill = false, double arrowWidth = 3.0, double arrowLength = 7.0)
                {                       
-                       Cairo.PointD vDir = p2.Substract(p1);
+                       PointD vDir = p2.Substract(p1);
                        vDir = vDir.GetNormalized ();
-                       Cairo.PointD vPerp = vDir.GetPerp ();
+                       PointD vPerp = vDir.GetPerp ();
 
-                       Cairo.PointD pA0 = p1.Add(vDir.Multiply(arrowLength));
-                       Cairo.PointD pA1 = p2.Substract(vDir.Multiply(arrowLength));
+                       PointD pA0 = p1.Add(vDir.Multiply(arrowLength));
+                       PointD pA1 = p2.Substract(vDir.Multiply(arrowLength));
 
-                       Cairo.PointD vA = vPerp.Multiply (arrowWidth);
+                       PointD vA = vPerp.Multiply (arrowWidth);
 
                        ctx.MoveTo (p1.Add (vA));
                        ctx.LineTo (pA0);
@@ -136,13 +136,13 @@ namespace Crow
                        ctx.LineWidth = stroke;
                        ctx.Stroke ();
                }
-               public static void DrawCoteFixed(this Cairo.Context ctx, Cairo.PointD p1, Cairo.PointD p2,
+               public static void DrawCoteFixed(this Cairo.Context ctx, PointD p1, PointD p2,
                        double stroke = 1.0, double coteWidth = 3.0)
                {                       
-                       Cairo.PointD vDir = p2.Substract(p1);
+                       PointD vDir = p2.Substract(p1);
                        vDir = vDir.GetNormalized ();
-                       Cairo.PointD vPerp = vDir.GetPerp ();
-                       Cairo.PointD vA = vPerp.Multiply (coteWidth);
+                       PointD vPerp = vDir.GetPerp ();
+                       PointD vA = vPerp.Multiply (coteWidth);
 
                        ctx.MoveTo (p1.Add (vA));
                        ctx.LineTo (p1.Substract (vA));
index e76be7b6fcec6b8d2364c40dcefa1f987503087b..0e814843790b3574e36c0045b1a26292398102c0 100644 (file)
@@ -107,7 +107,7 @@ namespace Crow
                }
                #endregion
 
-               public static object Parse(string s)
+               public static new object Parse(string s)
                {
                        if (string.IsNullOrEmpty (s))
                                return Color.White;
index c5af95ff7fc6f0035a9f8c78062ddcccc7cce224..e5746c6060ed3dabdad325ad4d0514fbe9bad903 100644 (file)
@@ -95,12 +95,12 @@ namespace Crow
                [DefaultValue("No")]
                public virtual string NoMessage
                {
-                       get { return cancelMessage; }
+                       get { return noMessage; }
                        set {
-                               if (cancelMessage == value)
+                               if (noMessage == value)
                                        return;
-                               cancelMessage = value;
-                               NotifyValueChanged ("NoMessage", cancelMessage);
+                               noMessage = value;
+                               NotifyValueChanged ("NoMessage", noMessage);
                        }
                }
                [DefaultValue("Information")]
index 73083311e7b157d647dc1a3566cef5a1574f80f1..ec63fe8dd929035864567dda18631d5acdc8bb55 100644 (file)
@@ -43,9 +43,9 @@ namespace Crow
 //             }
                #endregion
 
-               #region private fields
-               double _actualValue, minValue, maxValue, smallStep, bigStep;
-               int _decimals;
+               #region protected fields
+               protected double _actualValue, minValue, maxValue, smallStep, bigStep;
+               protected int _decimals;
                #endregion
 
                #region public properties
@@ -114,7 +114,7 @@ namespace Crow
                        }
                }
                [DefaultValue(0.0)]
-               public double Value
+               public virtual double Value
                {
                        get { return _actualValue; }
                        set
index a234a3e43e69101718b628d7a7173fedb4c239b3..7bdb7d395b6adc0807da6f616dd01d285861d771 100644 (file)
@@ -42,7 +42,7 @@ namespace Crow
                public Scroller (Interface iface) : base(iface){}
                #endregion
 
-               public event EventHandler<ScrollingEventArgs> Scrolled;
+               //public event EventHandler<ScrollingEventArgs> Scrolled;
 
                int scrollX, scrollY, maxScrollX, maxScrollY, scrollSpeed;
 
@@ -221,7 +221,7 @@ namespace Crow
                /// <summary> Process scrolling vertically, or if shift is down, vertically </summary>
                public override void onMouseWheel (object sender, MouseWheelEventArgs e)
                {
-                       if (IFace.IsKeyDown (Key.Shift_L))
+                       if (IFace.Shift)
                                ScrollX += e.Delta * ScrollSpeed;
                        else
                                ScrollY -= e.Delta * ScrollSpeed;
index bd46b051637ffdd40cbf45231ed14557b3117f33..e4942b2b50a8fa4b100db730564f02371bed0fa2 100644 (file)
@@ -105,17 +105,17 @@ namespace Crow
                }
                #endregion
 
-               [DefaultValue(10.0)]
-               public override double Maximum {
-                       get { return base.Maximum; }
-                       set {                           
-                               if (value == base.Maximum)
-                                       return;
-                               base.Maximum = value;
-                               LargeIncrement = base.Maximum / 10.0;
-                               SmallIncrement = LargeIncrement / 5.0;
-                       }
-               }
+               //[DefaultValue(10.0)]
+               //public override double Maximum {
+               //      get { return base.Maximum; }
+               //      set {                           
+               //              if (value == base.Maximum)
+               //                      return;
+               //              base.Maximum = value;
+               //              LargeIncrement = base.Maximum / 10.0;
+               //              SmallIncrement = LargeIncrement / 5.0;
+               //      }
+               //}
 
                #region GraphicObject Overrides
                protected override void onDraw (Context gr)
index 7c5fdb26f0b146e527a8b98fa04e3a74cab1edc0..8a3bcd626d8d9765eaebcd85f95650a029907269 100644 (file)
@@ -1,30 +1,6 @@
-//
-// Spinner.cs
+// Copyright (c) 2013-2019  Bruyère Jean-Philippe <jp_bruyere@hotmail.com>
 //
-// Author:
-//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 
 namespace Crow
 {
index 113a43997ad8879d515e38409f41aaa299d3581b..7c20a33e48f41c22067f2c1abcc1346a1cbc9b3c 100644 (file)
@@ -48,7 +48,7 @@ namespace Crow
                Widget titleWidget;
                int tabOffset;
                bool isSelected;
-               Measure tabThickness;
+               //Measure tabThickness;
                Fill selectedBackground = Color.Transparent;
                #endregion
 
index 550d60aa3ffaae6cf36edc6fbea453ff288aa6d6..423b8ab4e437152a795e51a2fe83ab88e203d984 100644 (file)
@@ -75,11 +75,11 @@ namespace Crow
                                        return;
                                leftSlope = value;
                                NotifyValueChanged ("leftSlope", leftSlope);
-                               tabSizeHasChanged = true;
+                               //tabSizeHasChanged = true;
                                //RegisterForLayouting (LayoutingType.ArrangeChildren);
                        }
                }
-               bool tabSizeHasChanged = false;
+               //bool tabSizeHasChanged = false;
                [DefaultValue(16)]
                public int RightSlope
                {
@@ -89,7 +89,7 @@ namespace Crow
                                        return;
                                rightSlope = value;
                                NotifyValueChanged ("RightSlope", rightSlope);
-                               tabSizeHasChanged = true;
+                               //tabSizeHasChanged = true;
                                //RegisterForLayouting (LayoutingType.ArrangeChildren);
                        }
                }
index 3556eaf06373ce512e7403f9f3f69d0a7c775897..9d7415d294b63b7ed0f45143ce1d7f45322e79c6 100644 (file)
@@ -340,7 +340,7 @@ namespace Crow {
                void loading(){
                        try {
                                loadPage (data, items, dataTest);
-                       } catch (Exception ex) {
+                       } catch {
                                if (Monitor.IsEntered (IFace.LayoutMutex))
                                        Monitor.Exit (IFace.LayoutMutex);
                                Console.WriteLine ("loading thread aborted");
@@ -519,5 +519,10 @@ namespace Crow {
                                loadingThread.Cancel ();
                        base.Dispose (disposing);
                }
+
+               public override void OnDataSourceChanged (object sender, DataSourceChangeEventArgs e)
+               {
+                       base.OnDataSourceChanged (sender, e);
+               }
        }
 }
index dcfb584c7fb5b0fb073ba1bf2b11296362a1e0e1..f8294a3b8749315845f711a37fe628f74fdb7e79 100644 (file)
@@ -54,7 +54,7 @@ namespace Crow
                {
                        base.onDraw (gr);
 
-                       double radius = 100;
+                       double radius = Math.Min (ClientRectangle.Width, ClientRectangle.Height) / 2;
 
                        double pi3 = Math.PI / 3.0;
 
index d85ddfaac4f09b570a14f9ee3aed4db54159b156..4ffb1c0cd118dac02da7ef4bfe55c33639b426a8 100644 (file)
@@ -410,7 +410,7 @@ namespace Crow
                public virtual Rectangle getSlot () { return Slot;}
                #endregion
                public Point ScreenPointToLocal(Point p){
-                       Point pt = p - ScreenCoordinates(Slot).TopLeft - ClientRectangle.TopLeft;
+                       Point pt = p - ScreenCoordinates (Slot).TopLeft - ClientRectangle.TopLeft;
                        if (pt.X < 0)
                                pt.X = 0;
                        if (pt.Y < 0)
@@ -912,7 +912,7 @@ namespace Crow
                                if (!isVisible && IFace.HoverWidget != null) {                                  
                                        if (IFace.HoverWidget.IsOrIsInside (this)) {
                                                //IFace.HoverWidget = null;
-                                               IFace.ProcessMouseMove (IFace.Mouse.X, IFace.Mouse.Y);
+                                               IFace.OnMouseMove (IFace.Mouse.X, IFace.Mouse.Y);
                                        }
                                }
 
@@ -988,7 +988,7 @@ namespace Crow
                /// Seek first logical tree upward if logicalParent is set, or seek graphic tree for
                /// a not null dataSource that will be active for all descendants having dataSource=null
                /// </summary>
-                       [DesignCategory ("Data")]
+               [DesignCategory ("Data")]
                public virtual object DataSource {
                        set {
                                if (DataSource == value)
@@ -1023,7 +1023,7 @@ namespace Crow
                        }
                }
                /// <summary>
-               /// If true, rendering of GraphicObject is clipped inside client rectangle
+               /// If true, lock datasource seeking upward in logic or graphic tree to this widget
                /// </summary>
                [DesignCategory ("Data")][DefaultValue(false)]
                public virtual bool RootDataLevel {
@@ -1182,7 +1182,7 @@ namespace Crow
                                                il.Emit (OpCodes.Ldnull);
                                                il.Emit (OpCodes.Call, CompilerServices.miCompileDynEventHandler);
                                                il.Emit (OpCodes.Castclass, ei.EventHandlerType);
-                                               il.Emit (OpCodes.Call, ei.AddMethod);
+                                               il.Emit (OpCodes.Callvirt, ei.AddMethod);
                                        }else
                                                Debug.WriteLine("error in styling, event not handled : " + trimed);
                                }
@@ -2016,7 +2016,7 @@ namespace Crow
                        if (IFace.HoverWidget != null) {
                                if (IFace.HoverWidget.IsOrIsInside (this)) {
                                        IFace.HoverWidget = null;
-                                       IFace.ProcessMouseMove (IFace.Mouse.X, IFace.Mouse.Y);
+                                       IFace.OnMouseMove (IFace.Mouse.X, IFace.Mouse.Y);
                                }
                        }
                        if (IFace.ActiveWidget != null) {
index 1d5b5509760324e4faa0c4cb87feb8e81d126e51..6773de426e86f143a8b2576c9458434dda9dc0e5 100644 (file)
@@ -212,7 +212,7 @@ namespace Crow.IML
                        il.Emit(OpCodes.Ldfld, CompilerServices.fiCachedDel);
                        il.Emit(OpCodes.Ldc_I4, index);//load delegate index
                        il.Emit(OpCodes.Callvirt, CompilerServices.miGetDelegateListItem);
-                       il.Emit(OpCodes.Call, evt.AddMethod);//call add event
+                       il.Emit(OpCodes.Callvirt, evt.AddMethod);//call add event
                }
                /// <summary>
                /// Emits the handler method addition, done at end of parsing, Loc_0 is root node instance
@@ -241,7 +241,7 @@ namespace Crow.IML
                        //load methodInfo (3rd arg)
                        il.Emit (OpCodes.Ldstr, membs[membs.Length-1]);
                        il.Emit (OpCodes.Call, CompilerServices.miCreateDel);
-                       il.Emit (OpCodes.Call, bd.SourceEvent.AddMethod);//call add event
+                       il.Emit (OpCodes.Callvirt, bd.SourceEvent.AddMethod);//call add event
                }
 //             public void emitHandlerMethodAddition(EventBinding bd){
 //                     //fetch source instance with address for handler addition (as 1st arg of handler.add)
index 29864f07fa53c11903da1d39928bc7d3ee021be5..334b2182312e7f4ad9c41d4545783c97fe3b4ff3 100644 (file)
@@ -33,7 +33,7 @@ namespace Crow
 {
     public class KeyEventArgs : CrowEventArgs
     {
-               int keyCode;
+               int keyCode=0;
                Key key;
                bool repeat;    
 
@@ -53,7 +53,7 @@ namespace Crow
                }
                public uint ScanCode
                {
-                   get { return (uint)Key; }
+                   get { return (uint)keyCode; }
                }
                public bool IsRepeat
                {
index d86c01336f7eefaaf2150db29dd5482782b7fb34..3268d2e67448473b9cdbe6658545eacad08c1ba5 100644 (file)
 // THE SOFTWARE.
 
 using System;
+using System.Collections.Generic;
+using System.Diagnostics;
 using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Reflection.Emit;
 using System.Text;
-using System.Diagnostics;
 using System.Xml;
-using System.Reflection.Emit;
-using System.Reflection;
-using System.Collections.Generic;
-using System.Linq;
 
-namespace Crow.IML
-{
+namespace Crow.IML {
        public class InstantiatorException : Exception {
                public string Path;
                public InstantiatorException (string path, Exception innerException)
@@ -688,7 +687,7 @@ namespace Crow.IML
                 il.Emit (OpCodes.Ldloc_0);//load methodInfo (3rd arg)
 
                 il.Emit (OpCodes.Call, CompilerServices.miCreateBoundDel);
-                il.Emit (OpCodes.Call, sourceEvent.AddMethod);//call add event
+                il.Emit (OpCodes.Callvirt, sourceEvent.AddMethod);//call add event
                                           
                 System.Reflection.Emit.Label finish = il.DefineLabel ();
                 il.Emit (OpCodes.Br, finish);
@@ -970,7 +969,7 @@ namespace Crow.IML
                        ilPC.Emit(OpCodes.Ldfld, CompilerServices.fiTemplateBinding);
 
                        //add template bindings dynValueChanged delegate to new parent event
-                       ilPC.Emit(OpCodes.Call, CompilerServices.eiValueChange.AddMethod);//call add event
+                       ilPC.Emit(OpCodes.Callvirt, CompilerServices.eiValueChange.AddMethod);//call add event
 
                        ilPC.MarkLabel (cancel);
                        ilPC.Emit (OpCodes.Ret);
@@ -996,7 +995,7 @@ namespace Crow.IML
                        PropertyInfo piSource = ctx.CurrentNodeType.GetProperty (bindingDef.SourceMember);
                        //if no dataSource member name is provided, valuechange is not handle and datasource change
                        //will be used as origine value
-                       string delName = "dyn_DSvalueChanged" + NewId;
+                       string delName = "dyn_DSvalueChangedKnownType" + NewId;
                        if (!string.IsNullOrEmpty (bindingDef.TargetMember)) {
                                #region create valuechanged method
                                dm = new DynamicMethod (delName,
@@ -1154,7 +1153,7 @@ namespace Crow.IML
                        PropertyInfo piSource = ctx.CurrentNodeType.GetProperty(bindingDef.SourceMember);
                        //if no dataSource member name is provided, valuechange is not handle and datasource change
                        //will be used as origine value
-                       string delName = "dyn_DSvalueChanged" + NewId;
+                       string delName = $"dyn_DSvalueChanged_{bindingDef.SourceMember}_{bindingDef.TargetMember}_{NewId}";
                        if (!string.IsNullOrEmpty(bindingDef.TargetMember)){
 #region create valuechanged method
                                dm = new DynamicMethod (delName,
index c4553066acf2599b9863fd6c915dd37834ea82de..4da0d1a7a5195882515d11b1e02655b788b8e0aa 100644 (file)
@@ -1,28 +1,6 @@
-//
-// Interface.cs
+// Copyright (c) 2013-2019  Bruyère Jean-Philippe <jp_bruyere@hotmail.com>
 //
-// Author:
-//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 
 using System;
 using System.Collections.Generic;
@@ -35,7 +13,6 @@ using System.Threading;
 using Crow.Cairo;
 using Crow.IML;
 
-
 namespace Crow
 {
        /// <summary>
@@ -76,7 +53,6 @@ namespace Crow
                protected IBackend backend;
                protected bool running;
 
-
                #region CTOR
                static Interface () {
                        /*if (Type.GetType ("Mono.Runtime") == null) {
@@ -95,7 +71,7 @@ namespace Crow
                        foreach (string af in Directory.GetFiles (AppDomain.CurrentDomain.BaseDirectory, "*.dll")) {
                                try {
                                        Assembly.LoadFrom (af);
-                               } catch (Exception ex) {
+                               } catch {
                                        Console.WriteLine ("{0} not loaded as assembly.", af);
                                }
                        }
@@ -108,7 +84,7 @@ namespace Crow
                }
 
                public Interface(int width=800, int height=600, IBackend _backend = null){
-                       CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
+                       CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
                        CurrentInterface = this;
                        clientRectangle = new Rectangle (0, 0, width, height);
                        backend = _backend;
@@ -166,31 +142,10 @@ namespace Crow
                                Thread.Sleep(1);
                        }
                }
-
-               public void ProcessKeyPress (char c)
+               public virtual void Quit ()
                {
-                       _focusedWidget?.onKeyPress (_focusedWidget, new KeyPressEventArgs(c));
-               }
-               public void ProcessKeyUp (Key key)
-               {
-                       _focusedWidget?.onKeyUp (_focusedWidget, new KeyEventArgs(key, false));
-//                     if (keyboardRepeatThread != null) {
-//                             keyboardRepeatOn = false;
-//                             keyboardRepeatThread.Abort();
-//                             keyboardRepeatThread.Join ();
-//                     }
+                       running = false;
                }
-               public void ProcessKeyDown (Key key)
-               {
-                       //Keyboard.SetKeyState((Crow.Key)Key,true);
-                       lastKeyDownEvt = new KeyEventArgs (key, true);
-
-                       _focusedWidget?.onKeyDown (_focusedWidget, new KeyEventArgs (key, false));
-
-                       //                      keyboardRepeatThread = new Thread (keyboardRepeatThreadFunc);
-                       //                      keyboardRepeatThread.IsBackground = true;
-                       //                      keyboardRepeatThread.Start ();
-               }
                public bool Shift {
                        get { return backend.Shift; }
                }
@@ -311,17 +266,17 @@ namespace Crow
                #endregion
 
                #region Events
-               public event EventHandler<MouseCursorChangedEventArgs> MouseCursorChanged;
-               public event EventHandler Quit;
-
-               public event EventHandler<MouseWheelEventArgs> MouseWheelChanged;
-               public event EventHandler<MouseButtonEventArgs> MouseButtonUp;
-               public event EventHandler<MouseButtonEventArgs> MouseButtonDown;
-               public event EventHandler<MouseButtonEventArgs> MouseClick;
-               public event EventHandler<MouseMoveEventArgs> MouseMove;
-               public event EventHandler<KeyEventArgs> KeyDown;
-               public event EventHandler<KeyEventArgs> KeyUp;
-               public event EventHandler<KeyPressEventArgs> KeyPress;
+               //public event EventHandler<MouseCursorChangedEventArgs> MouseCursorChanged;
+               ////public event EventHandler Quit;
+
+               //public event EventHandler<MouseWheelEventArgs> MouseWheelChanged;
+               //public event EventHandler<MouseButtonEventArgs> MouseButtonUp;
+               //public event EventHandler<MouseButtonEventArgs> MouseButtonDown;
+               //public event EventHandler<MouseButtonEventArgs> MouseClick;
+               //public event EventHandler<MouseMoveEventArgs> MouseMove;
+               //public event EventHandler<KeyEventArgs> KeyDown;
+               //public event EventHandler<KeyEventArgs> KeyUp;
+               //public event EventHandler<KeyPressEventArgs> KeyPress;
                /*public event EventHandler<KeyEventArgs> KeyboardKeyDown;
                public event EventHandler<KeyEventArgs> KeyboardKeyUp;*/
                #endregion
@@ -394,7 +349,7 @@ namespace Crow
                /// <summary>Clipping rectangles on the root context</summary>
                Region clipping = new Region();
                /// <summary>Main Cairo context</summary>
-               Context ctx;
+               //Context ctx;
                #endregion
 
                #region Default values and Style loading
@@ -417,7 +372,7 @@ namespace Crow
                        loadStylingFromAssembly (Assembly.GetExecutingAssembly ());
                }
                /// <summary> Search for .style resources in assembly </summary>
-               void loadStylingFromAssembly (Assembly assembly) {
+               protected void loadStylingFromAssembly (Assembly assembly) {
                        if (assembly == null)
                                return;
                        foreach (string s in assembly
@@ -429,7 +384,6 @@ namespace Crow
 
                        }
                }
-
                #endregion
 
 
@@ -466,6 +420,9 @@ namespace Crow
 
                        if (path.StartsWith ("#", StringComparison.Ordinal)) {
                                string resId = path.Substring (1);
+                               stream = Assembly.GetEntryAssembly ().GetManifestResourceStream (resId);
+                               if (stream != null)
+                                       return stream;
                                string assemblyName = resId.Split ('.') [0];
                                Assembly a = AppDomain.CurrentDomain.GetAssemblies ().FirstOrDefault (aa => aa.GetName ().Name == assemblyName);
                                if (a == null)
@@ -486,6 +443,9 @@ namespace Crow
 
                        if (path.StartsWith ("#", StringComparison.Ordinal)) {
                                string resId = path.Substring (1);
+                               stream = Assembly.GetEntryAssembly ().GetManifestResourceStream (resId);
+                               if (stream != null)
+                                       return stream;
                                string assemblyName = resId.Split ('.') [0];
                                Assembly a = AppDomain.CurrentDomain.GetAssemblies ().FirstOrDefault (aa => aa.GetName ().Name == assemblyName);
                                if (a == null)
@@ -863,12 +823,10 @@ namespace Crow
 
                                        ctx.Paint ();
 
+                                       backend?.Flush ();
+
                                        clipping.Dispose ();
                                        clipping = new Region ();
-                                       //}
-                                       //surf.WriteToPng (@"/mnt/data/test.png");
-
-                                       backend?.Flush ();
                                }
                        
                        /*#if DEBUG_LOG
@@ -1015,10 +973,11 @@ namespace Crow
                public MouseState Mouse;
                Stopwatch lastMouseDown = new Stopwatch (), mouseRepeatTimer = new Stopwatch ();
                bool doubleClickTriggered;      //next mouse up will trigger a double click
-               int mouseRepeatCount;
+               //int mouseRepeatCount;
                MouseButtonEventArgs lastMouseDownEvent;
 
                public MouseCursor MouseCursor {
+                       get => cursor;
                        set {
 
                                if (value == cursor)
@@ -1032,7 +991,7 @@ namespace Crow
                /// <summary>Processes mouse move events from the root container, this function
                /// should be called by the host on mouse move event to forward events to crow interfaces</summary>
                /// <returns>true if mouse is in the interface</returns>
-               public virtual bool ProcessMouseMove(int x, int y)
+               public virtual bool OnMouseMove(int x, int y)
                {
                        int deltaX = x - Mouse.X;
                        int deltaY = y - Mouse.Y;
@@ -1122,13 +1081,13 @@ namespace Crow
                /// </summary>
                /// <returns>return true, if interface handled the event, false otherwise.</returns>
                /// <param name="button">Button index</param>
-               public bool ProcessMouseButtonDown (MouseButton button)
+               public virtual bool OnMouseButtonDown (MouseButton button)
                {
                        Mouse.EnableBit ((int)button);
 
                        doubleClickTriggered = (lastMouseDown.ElapsedMilliseconds < DOUBLECLICK_TRESHOLD);
                        lastMouseDown.Restart ();
-                       mouseRepeatCount = -1;//stays negative until repeat delay is hit
+                       //mouseRepeatCount = -1;//stays negative until repeat delay is hit
 
                        lastMouseDownEvent = new MouseButtonEventArgs (button) { Mouse = Mouse };
 
@@ -1145,7 +1104,7 @@ namespace Crow
                /// </summary>
                /// <returns>return true, if interface handled the event, false otherwise.</returns>
                /// <param name="button">Button index</param>
-               public bool ProcessMouseButtonUp(MouseButton button)
+               public virtual bool OnMouseButtonUp(MouseButton button)
                {
                        Mouse.DisableBit ((int)button);
 
@@ -1173,7 +1132,7 @@ namespace Crow
                /// </summary>
                /// <returns>return true, if interface handled the event, false otherwise.</returns>
                /// <param name="delta">wheel delta</param>
-               public bool ProcessMouseWheelChanged(float delta)
+               public virtual bool OnMouseWheelChanged(float delta)
                {
                        Mouse.SetScrollRelative (0, delta);
                        MouseWheelEventArgs e = new MouseWheelEventArgs () { Mouse = Mouse, DeltaPrecise = delta };
@@ -1184,6 +1143,31 @@ namespace Crow
                        return true;
                }
 
+               public virtual void OnKeyPress (char c)
+               {
+                       _focusedWidget?.onKeyPress (_focusedWidget, new KeyPressEventArgs (c));
+               }
+               public virtual void OnKeyUp (Key key)
+               {
+                       _focusedWidget?.onKeyUp (_focusedWidget, new KeyEventArgs (key, false));
+                       //                      if (keyboardRepeatThread != null) {
+                       //                              keyboardRepeatOn = false;
+                       //                              keyboardRepeatThread.Abort();
+                       //                              keyboardRepeatThread.Join ();
+                       //                      }
+               }
+               public virtual void OnKeyDown (Key key)
+               {
+                       //Keyboard.SetKeyState((Crow.Key)Key,true);
+                       lastKeyDownEvt = new KeyEventArgs (key, true);
+
+                       _focusedWidget?.onKeyDown (_focusedWidget, new KeyEventArgs (key, false));
+
+                       //                      keyboardRepeatThread = new Thread (keyboardRepeatThreadFunc);
+                       //                      keyboardRepeatThread.IsBackground = true;
+                       //                      keyboardRepeatThread.Start ();
+               }
+
                public bool IsKeyDown (Key key) {
                        return false;
                }
index 3259294ff031826a1a6d64fe054347b2f3d2056a..6bfa49b73fe81ef5c41ac5319c1be20970ec5a0e 100644 (file)
@@ -37,7 +37,6 @@
 using System;
 using System.Runtime.InteropServices;
 using System.Text;
-using Color = Crow.Color;
 
 namespace Crow.Cairo { 
 
@@ -432,6 +431,10 @@ namespace Crow.Cairo {
                {
                        NativeMethods.cairo_arc (handle, xc, yc, radius, angle1, angle2);
                }
+               public void Arc (Point center, double radius, double angle1, double angle2)
+               {
+                       NativeMethods.cairo_arc (handle, center.X, center.Y, radius, angle1, angle2);
+               }
 
                public void ArcNegative (double xc, double yc, double radius, double angle1, double angle2)
                {
diff --git a/Crow/src/Mono.Cairo/Point.cs b/Crow/src/Mono.Cairo/Point.cs
deleted file mode 100644 (file)
index cf07f31..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// Mono.Cairo.Context.cs
-//
-// Author:
-//   Duncan Mak (duncan@ximian.com)
-//   Miguel de Icaza (miguel@novell.com)
-//   Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//   Alp Toker (alp@atoker.com)
-//
-// (C) Ximian Inc, 2003.
-// (C) Novell Inc, 2003.
-//
-// This is an OO wrapper API for the Cairo API.
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Crow.Cairo {
-       public struct Point
-       {
-               public Point (int x, int y)
-               {
-                       this.x = x;
-                       this.y = y;
-               }
-
-               int x, y;
-               public int X {
-                       get { return x; }
-                       set { x = value; }
-               }
-
-               public int Y {
-                       get { return y; }
-                       set { y = value; }
-               }
-       }
-}
diff --git a/Crow/src/Mono.Cairo/PointD.cs b/Crow/src/Mono.Cairo/PointD.cs
deleted file mode 100644 (file)
index 8bc019c..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// Mono.Cairo.Context.cs
-//
-// Author:
-//   Duncan Mak (duncan@ximian.com)
-//   Miguel de Icaza (miguel@novell.com)
-//   Hisham Mardam Bey (hisham.mardambey@gmail.com)
-//   Alp Toker (alp@atoker.com)
-//
-// (C) Ximian Inc, 2003.
-// (C) Novell Inc, 2003.
-//
-// This is an OO wrapper API for the Cairo API.
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Crow.Cairo {
-
-       public struct PointD
-       {
-               public PointD (double x, double y)
-               {
-                       this.x = x;
-                       this.y = y;
-               }
-
-               double x, y;
-               public double X {
-                       get { return x; }
-                       set { x = value; }
-               }
-
-               public double Y {
-                       get { return y; }
-                       set { y = value; }
-               }
-       }
-}
index 1b59698156b063766e02503197b3162c333a3c66..d2a52f8d7b024e3100b42f29163341af2c7802f5 100644 (file)
@@ -6,7 +6,6 @@ namespace Crow.Coding
        {
                public int Line;
                public int Column;
-               public string Source;
                public ParserException(int line, int column, string txt, string source = null)
                        : base(txt)
                {
index 133bc4efb834eac7fe5ab892aab88d4aeaad21da..2a71d6b51c2965885cae2485c38e40d408876808 100644 (file)
@@ -129,7 +129,7 @@ namespace Crow
                }
                #endregion
 
-               public static object Parse(string path)
+               public static new object Parse(string path)
                {
                        if (string.IsNullOrEmpty (path))
                                return null;
index 08dd4436b9f1adc72a6ce3726265ccce7540af64..83ae76512aaf08f8297bfb9a97967d1c4820195a 100644 (file)
@@ -1,28 +1,6 @@
-//
-// Point.cs
+// Copyright (c) 2013-2019  Bruyère Jean-Philippe jp_bruyere@hotmail.com
 //
-// Author:
-//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 
 using System;
 using System.Collections.Generic;
@@ -33,148 +11,76 @@ namespace Crow
 {
     public struct Point
     {
-        int _x;
-        int _y;
+               public int X;
+               public int Y;
 
-        public int X
-        {
-            get { return _x; }
-            set { _x = value; }
-        }
-        public int Y
-        {
-            get { return _y; }
-            set { _y = value; }
-        }
-        public Point(int x, int y)
-        {
-            _x = x;
-            _y = y;
-        }
-
-               public int Length {
-                       get { return (int)Math.Sqrt (Math.Pow (_x, 2) + Math.Pow (_y, 2)); }
-               }
-               public double LengthD {
-                       get { return Math.Sqrt (Math.Pow (_x, 2) + Math.Pow (_y, 2)); }
-               }
-        public static implicit operator Cairo.Point(Point p)
-        {
-            return new Cairo.Point(p.X, p.Y);
-        }
-        public static implicit operator Cairo.PointD(Point p)
-        {
-            return new Cairo.PointD(p.X, p.Y);
-        }
-        public static implicit operator Point(int i)
-        {
-            return new Point(i, i);
-        }
-        public static Point operator /(Point p, int d)
-        {
-            return new Point(p.X / d, p.Y / d);
-        }
-        public static Point operator *(Point p, int d)
-        {
-            return new Point(p.X * d, p.Y * d);
-        }
-        public static Point operator /(Point p, double d)
-        {
-            return new Point((int)(p.X / d), (int)(p.Y / d));
-        }
-        public static Point operator *(Point p, double d)
-        {
-            return new Point((int)(p.X * d), (int)(p.Y * d));
-        }
-        public static Point operator +(Point p1, Point p2)
-        {
-            return new Point(p1.X + p2.X, p1.Y + p2.Y);
-        }
-               public static Point operator +(Point p, int i)
+               public Point (int x, int y)
                {
-                       return new Point(p.X + i, p.Y + i);
+                       X = x;
+                       Y = y;
                }
-        public static Point operator -(Point p1, Point p2)
-        {
-            return new Point(p1.X - p2.X, p1.Y - p2.Y);
-        }
-        public static bool operator >=(Point p1, Point p2)
-        {
-            return p1.X >= p2.X && p1.Y >= p2.Y ? true : false;
-        }
-        public static bool operator <=(Point p1, Point p2)
-        {
-            return p1.X <= p2.X && p1.Y <= p2.Y ? true : false;
-        }
-        public static bool operator ==(Point s, int i)
-        {
-            if (s.X == i && s.Y == i)
-                return true;
-            else
-                return false;
-        }
-        public static bool operator !=(Point s, int i)
-        {
-            if (s.X == i && s.Y == i)
-                return false;
-            else
-                return true;
-        }
-        public static bool operator >(Point s, int i)
-        {
-            if (s.X > i && s.Y > i)
-                return true;
-            else
-                return false;
-        }
-        public static bool operator <(Point s, int i)
-        {
-            if (s.X < i && s.Y < i)
-                return true;
-            else
-                return false;
-        }
-        public static bool operator ==(Point s1, Point s2)
-        {
-            if (s1.X == s2.X  && s1.Y == s2.Y)
-                return true;
-            else
-                return false;
-        }
-        public static bool operator !=(Point s1, Point s2)
-        {
-            if (s1.X == s2.X && s1.Y == s2.Y)
-                return false;
-            else
-                return true;
-        }
 
-        public override string ToString()
-        {
-                       return string.Format("({0},{1})", X, Y);
-        }
+               public int Length => (int)Math.Sqrt (Math.Pow (X, 2) + Math.Pow (Y, 2));
+               public double LengthD => Math.Sqrt (Math.Pow (X, 2) + Math.Pow (Y, 2));
+               public Point Normalized {
+                       get {
+                               int l = Length;
+                               return new Point (X / l, Y / l);
+                       }
+               }
+               public static implicit operator PointD (Point p) => new PointD (p.X, p.Y);
+               public static implicit operator Point (int i) => new Point (i, i);
+
+               public static Point operator + (Point p1, Point p2) => new Point (p1.X + p2.X, p1.Y + p2.Y);
+               public static Point operator + (Point p, int i) => new Point (p.X + i, p.Y + i);
+               public static Point operator - (Point p1, Point p2) => new Point (p1.X - p2.X, p1.Y - p2.Y);
+               public static Point operator - (Point p, int i) => new Point (p.X - i, p.Y - i);
+               public static Point operator * (Point p1, Point p2) => new Point (p1.X * p2.X, p1.Y * p2.Y);
+               public static Point operator * (Point p, int d) => new Point (p.X * d, p.Y * d);
+               public static Point operator / (Point p1, Point p2) => new Point (p1.X / p2.X, p1.Y / p2.Y);
+               public static Point operator / (Point p, int d) => new Point (p.X / d, p.Y / d);
 
-        public override bool Equals(object obj)
-        {
-            return base.Equals(obj);
-        }
-        public override int GetHashCode()
-        {
-            return base.GetHashCode();
-        }
-               public static Point Parse(string s)
+               public static bool operator == (Point s1, Point s2) => s1.X == s2.X && s1.Y == s2.Y;
+               public static bool operator == (Point s, int i) => s.X == i && s.Y == i;
+               public static bool operator != (Point s1, Point s2) => !(s1.X == s2.X && s1.Y == s2.Y);
+               public static bool operator != (Point s, int i) => !(s.X == i && s.Y == i);
+               public static bool operator > (Point p1, Point p2) => p1.X > p2.X && p1.Y > p2.Y;
+               public static bool operator > (Point s, int i) => s.X > i && s.Y > i;
+               public static bool operator < (Point p1, Point p2) => p1.X < p2.X && p1.Y < p2.Y;
+               public static bool operator < (Point s, int i) => s.X < i && s.Y < i;
+               public static bool operator >= (Point p1, Point p2) => p1.X >= p2.X && p1.Y >= p2.Y;
+               public static bool operator >= (Point s, int i) => s.X >= i && s.Y >= i;
+               public static bool operator <= (Point p1, Point p2) => p1.X <= p2.X && p1.Y <= p2.Y;
+               public static bool operator <= (Point s, int i) => s.X <= i && s.Y <= i;
+
+               public override string ToString () => string.Format ("({0},{1})", X, Y);
+               public override bool Equals (object obj) => obj is Point ? this == (Point)obj :
+                       obj is Point && (Point)this == (Point)obj;
+               public static Point Parse (string s)
                {
                        if (string.IsNullOrEmpty (s))
-                               return default(Point);
-                       string[] d = s.Trim().Split(',');
+                               return default (Point);
+                       string [] d = s.Trim ().Split (',');
                        if (d.Length == 2)
                                return new Point (int.Parse (d [0]), int.Parse (d [1]));
                        else if (d.Length == 1) {
                                int tmp = int.Parse (d [0]);
                                return new Point (tmp, tmp);
                        }
-                       throw new Exception ("Crow.Point Parsing Error: " + s);
+                       throw new Exception ("Crow.PointD Parsing Error: " + s);
                }
-    }
 
+               public override int GetHashCode ()
+               {
+#pragma warning disable RECS0025 // Champ autre qu’en lecture seule référencé dans « GetHashCode() »
+                       unchecked {
+                               var hashCode = 1861411795;
+                               hashCode = hashCode * -1521134295 + X.GetHashCode ();
+
+                               hashCode = hashCode * -1521134295 + Y.GetHashCode ();
+                               return hashCode;
+                       }
+#pragma warning restore RECS0025 // Champ autre qu’en lecture seule référencé dans « GetHashCode() »    }
+               }
+       }
 }
diff --git a/Crow/src/PointD.cs b/Crow/src/PointD.cs
new file mode 100644 (file)
index 0000000..9db0a18
--- /dev/null
@@ -0,0 +1,79 @@
+// Copyright (c) 2013-2019  Bruyère Jean-Philippe jp_bruyere@hotmail.com
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+using System;
+
+namespace Crow {
+       public struct PointD {
+               public double X;
+               public double Y;
+               public PointD (double x, double y)
+               {
+                       X = x;
+                       Y = y;
+               }
+
+               public double Length => Math.Sqrt (Math.Pow (X, 2) + Math.Pow (Y, 2));
+               public PointD Normalized {
+                       get {
+                               double l = Length;
+                               return new PointD (X / l, Y / l);
+                       }
+               }
+               public static implicit operator Point (PointD p) => new Point ((int)Math.Round (p.X), (int)Math.Round (p.Y));
+               public static implicit operator PointD (double i) => new PointD (i, i);
+
+               public static PointD operator + (PointD p1, PointD p2) => new PointD (p1.X + p2.X, p1.Y + p2.Y);
+               public static PointD operator + (PointD p, double i) => new PointD (p.X + i, p.Y + i);
+               public static PointD operator - (PointD p1, PointD p2) => new PointD (p1.X - p2.X, p1.Y - p2.Y);
+               public static PointD operator - (PointD p, double i) => new PointD (p.X - i, p.Y - i);
+               public static PointD operator * (PointD p1, PointD p2) => new PointD (p1.X * p2.X, p1.Y * p2.Y);
+               public static PointD operator * (PointD p, double d) => new PointD (p.X * d, p.Y * d);
+               public static PointD operator / (PointD p1, PointD p2) => new PointD (p1.X / p2.X, p1.Y / p2.Y);
+               public static PointD operator / (PointD p, double d) => new PointD (p.X / d, p.Y / d);
+
+               public static bool operator == (PointD s1, PointD s2) => s1.X == s2.X && s1.Y == s2.Y;
+               public static bool operator == (PointD s, double i) => s.X == i && s.Y == i;
+               public static bool operator != (PointD s1, PointD s2) => !(s1.X == s2.X && s1.Y == s2.Y);
+               public static bool operator != (PointD s, double i) => !(s.X == i && s.Y == i);
+               public static bool operator > (PointD p1, PointD p2) => p1.X > p2.X && p1.Y > p2.Y;
+               public static bool operator > (PointD s, double i) => s.X > i && s.Y > i;
+               public static bool operator < (PointD p1, PointD p2) => p1.X < p2.X && p1.Y < p2.Y;
+               public static bool operator < (PointD s, double i) => s.X < i && s.Y < i;
+               public static bool operator >= (PointD p1, PointD p2) => p1.X >= p2.X && p1.Y >= p2.Y;
+               public static bool operator >= (PointD s, double i) => s.X >= i && s.Y >= i;
+               public static bool operator <= (PointD p1, PointD p2) => p1.X <= p2.X && p1.Y <= p2.Y;
+               public static bool operator <= (PointD s, double i) => s.X <= i && s.Y <= i;
+
+               public override string ToString () => string.Format ("({0},{1})", X, Y);
+               public override bool Equals (object obj) => obj is PointD ? this == (PointD)obj :
+                       obj is Point && (Point)this == (Point)obj;
+               public static PointD Parse (string s)
+               {
+                       if (string.IsNullOrEmpty (s))
+                               return default (PointD);
+                       string [] d = s.Trim ().Split (',');
+                       if (d.Length == 2)
+                               return new PointD (double.Parse (d [0]), double.Parse (d [1]));
+                       else if (d.Length == 1) {
+                               double tmp = double.Parse (d [0]);
+                               return new PointD (tmp, tmp);
+                       }
+                       throw new Exception ("Crow.PointD Parsing Error: " + s);
+               }
+
+               public override int GetHashCode ()
+               {
+#pragma warning disable RECS0025 // Champ autre qu’en lecture seule référencé dans « GetHashCode() »
+                       unchecked {
+                               var hashCode = 1861411795;
+                               hashCode = hashCode * -1521134295 + X.GetHashCode ();
+
+                               hashCode = hashCode * -1521134295 + Y.GetHashCode ();
+                               return hashCode;
+                       }
+#pragma warning restore RECS0025 // Champ autre qu’en lecture seule référencé dans « GetHashCode() »    }
+               }
+       }
+}
\ No newline at end of file
index b59341572025de9ff7d332b9ef6212aa1d5a8e5d..0a85419418519ea723f690119621423f80f69d2e 100644 (file)
@@ -1,56 +1,21 @@
-//
-// Rectangle.cs
+// Copyright (c) 2013-2019  Bruyère Jean-Philippe jp_bruyere@hotmail.com
 //
-// Author:
-//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Xml.Serialization;
 using System.Runtime.InteropServices;
 
-namespace Crow
-{
+namespace Crow {
        [StructLayout(LayoutKind.Sequential)]
        public struct Rectangle
     {
-               internal static Type TRectangle = typeof(Rectangle);
+               public static readonly Rectangle Zero = new Rectangle (0, 0, 0, 0);
 
-               public int X;
-               public int Y;
-               public int Width;
-               public int Height;
+               public int X, Y, Width, Height;
 
                #region ctor
-               public Rectangle(Point p, Size s): this (p.X, p.Y, s.Width, s.Height)
-               {
-               }
-               public Rectangle(Size s) : this (0, 0, s.Width, s.Height)
-        {
-        }
-        public Rectangle(int x, int y, int width, int height)
-        {
+               public Rectangle(Point p, Size s): this (p.X, p.Y, s.Width, s.Height) { }
+               public Rectangle(Size s) : this (0, 0, s.Width, s.Height) { }
+        public Rectangle(int x, int y, int width, int height) {
                        X = x;
                        Y = y;
                        Width = width;
@@ -60,60 +25,46 @@ namespace Crow
 
                #region PROPERTIES
                [XmlIgnore]public int Left{
-            get { return X; }
+                       get => X;
             set { X = value; }
         }
                [XmlIgnore]public int Top{
-            get { return Y; }
+            get => Y;
             set { Y = value; }
         }
-               [XmlIgnore]public int Right{
-            get { return X + Width; }
-        }
-               [XmlIgnore]public int Bottom{
-            get { return Y + Height; }
-        }
+               [XmlIgnore] public int Right => X + Width;
+               [XmlIgnore]public int Bottom => Y + Height;
                [XmlIgnore]public Size Size{
-            get { return new Size(Width, Height); }
-            set
-            {
+                       get => new Size (Width, Height);
+            set {
                 Width = value.Width;
                 Height = value.Height;
             }
         }
                [XmlIgnore]public Point Position{
-                       get { return new Point(X, Y); }
-                       set
-                       {
+                       get => new Point (X, Y);
+                       set {
                                X = value.X;
                                Y = value.Y;
                        }
                }
                [XmlIgnore]public Point TopLeft{
-            set
-            {
+                       get => new Point (X, Y);
+                       set {
                 X = value.X;
                 Y = value.Y;
             }
-            get { return new Point(X, Y); }
-        }
-               [XmlIgnore]public Point TopRight{
-            get { return new Point(Right, Y); }
-        }
-               [XmlIgnore]public Point BottomLeft{
-            get { return new Point(X, Bottom); }
-        }
-               [XmlIgnore]public Point BottomRight{
-            get { return new Point(Right, Bottom); }
-        }
-               [XmlIgnore]public Point Center
-        {
-            get { return new Point(Left + Width / 2, Top + Height / 2); }
         }
+               [XmlIgnore] public Point TopRight => new Point (Right, Y);
+               [XmlIgnore] public Point BottomLeft => new Point (X, Bottom);
+               [XmlIgnore] public Point BottomRight => new Point (Right, Bottom);        
+               [XmlIgnore] public Point Center => new Point (Left + Width / 2, Top + Height / 2);
+               [XmlIgnore] public Point CenterD => new PointD (Left + Width / 2.0, Top + Height / 2.0);
+
                #endregion
 
                #region FUNCTIONS
-        public void Inflate(int xDelta, int yDelta)
+               public void Inflate(int xDelta, int yDelta)
         {
             this.X -= xDelta;
             this.Width += 2 * xDelta;
@@ -124,23 +75,14 @@ namespace Crow
                {
                        Inflate (delta, delta);
                }
-               public Rectangle Inflated (int delta) {
-                       return Inflated (delta,delta);
-               }
+               public Rectangle Inflated (int delta) => Inflated (delta, delta);
                public Rectangle Inflated (int deltaX, int deltaY) {
                        Rectangle r = this;
                        r.Inflate (deltaX, deltaY);
                        return r;
                }
-        public bool ContainsOrIsEqual(Point p)
-        {
-            return (p.X >= X && p.X <= X + Width && p.Y >= Y && p.Y <= Y + Height) ?
-                true : false;
-        }
-        public bool ContainsOrIsEqual(Rectangle r)
-        {
-            return r.TopLeft >= this.TopLeft && r.BottomRight <= this.BottomRight ? true : false;
-        }
+               public bool ContainsOrIsEqual (Point p) => (p.X >= X && p.X <= X + Width && p.Y >= Y && p.Y <= Y + Height);
+               public bool ContainsOrIsEqual (Rectangle r) => r.TopLeft >= this.TopLeft && r.BottomRight <= this.BottomRight;
         public bool Intersect(Rectangle r)
         {
             int maxLeft = Math.Max(this.Left, r.Left);
@@ -148,30 +90,29 @@ namespace Crow
             int maxTop = Math.Max(this.Top, r.Top);
             int minBottom = Math.Min(this.Bottom, r.Bottom);
 
-                       return (maxLeft < minRight) && (maxTop < minBottom) ?
-                               true : false;
+                       return (maxLeft < minRight) && (maxTop < minBottom);
         }
         public Rectangle Intersection(Rectangle r)
         {
             Rectangle result = new Rectangle();
             
-            if (r.Left >= this.Left)
+            if (r.Left >= Left)
                 result.Left = r.Left;
             else
-                result.TopLeft = this.TopLeft;
+                result.TopLeft = TopLeft;
 
-            if (r.Right >= this.Right)
-                result.Width = this.Right - result.Left;
+            if (r.Right >= Right)
+                result.Width = Right - result.Left;
             else
                 result.Width = r.Right - result.Left;
 
-            if (r.Top >= this.Top)
+            if (r.Top >= Top)
                 result.Top = r.Top;
             else
-                result.Top = this.Top;
+                result.Top = Top;
 
-            if (r.Bottom >= this.Bottom)
-                result.Height = this.Bottom - result.Top;
+            if (r.Bottom >= Bottom)
+                result.Height = Bottom - result.Top;
             else
                 result.Height = r.Bottom - result.Top;
 
@@ -188,33 +129,13 @@ namespace Crow
             int y2 = Math.Max(r1.Bottom, r2.Bottom);
             return new Rectangle(x, y, x2 - x, y2 - y);
         }
-               public static Rectangle operator +(Rectangle r, Point p)
-               {
-                       return new Rectangle(r.X + p.X, r.Y + p.Y, r.Width, r.Height);
-               }
-               public static Rectangle operator -(Rectangle r, Point p)
-               {
-                       return new Rectangle(r.X - p.X, r.Y - p.Y, r.Width, r.Height);
-               }
-               public static bool operator ==(Rectangle r1, Rectangle r2)
-        {
-            return r1.TopLeft == r2.TopLeft && r1.Size == r2.Size ? true : false;
-        }
-        public static bool operator !=(Rectangle r1, Rectangle r2)
-        {
-            return r1.TopLeft == r2.TopLeft && r1.Size == r2.Size ? false : true;
-        }
+               public static Rectangle operator + (Rectangle r, Point p) => new Rectangle (r.X + p.X, r.Y + p.Y, r.Width, r.Height);
+               public static Rectangle operator - (Rectangle r, Point p) => new Rectangle (r.X - p.X, r.Y - p.Y, r.Width, r.Height);
+               public static bool operator == (Rectangle r1, Rectangle r2) => r1.TopLeft == r2.TopLeft && r1.Size == r2.Size;
+               public static bool operator != (Rectangle r1, Rectangle r2) => !(r1.TopLeft == r2.TopLeft && r1.Size == r2.Size);        
         #endregion        
 
-               public static readonly Rectangle Zero = new Rectangle(0, 0, 0, 0);
-        public static Rectangle Empty
-        {
-            get { return Zero; }
-        }
-        public override string ToString()
-        {
-            return string.Format("{0},{1},{2},{3}", X, Y, Width, Height);
-        }
+               public override string ToString () => $"{X},{Y},{Width},{Height}";        
         public static Rectangle Parse(string s)
         {
             string[] d = s.Split(new char[] { ',' });
@@ -237,11 +158,7 @@ namespace Crow
                                return hash;
                        }
                }
-               public override bool Equals (object obj)
-               {
-                       return (obj == null || obj.GetType() != TRectangle) ?
-                               false :
-                               this == (Rectangle)obj;
-               }
+               public override bool Equals (object obj) => (obj == null || obj.GetType () != typeof (Rectangle)) ?
+                               false : this == (Rectangle)obj;
     }
 }
diff --git a/Crow/src/RectangleD.cs b/Crow/src/RectangleD.cs
new file mode 100644 (file)
index 0000000..4e17a17
--- /dev/null
@@ -0,0 +1,164 @@
+// Copyright (c) 2013-2019  Bruyère Jean-Philippe jp_bruyere@hotmail.com
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System;
+using System.Runtime.InteropServices;
+
+namespace Crow {
+       [StructLayout(LayoutKind.Sequential)]
+       public struct RectangleD
+    {
+               public static readonly RectangleD Zero = new RectangleD (0, 0, 0, 0);
+
+               public double X, Y, Width, Height;
+
+               #region ctor
+               public RectangleD(PointD p, Size s): this (p.X, p.Y, s.Width, s.Height) { }
+               public RectangleD(SizeD s) : this (0, 0, s.Width, s.Height) { }
+        public RectangleD(double x, double y, double width, double height) {
+                       X = x;
+                       Y = y;
+                       Width = width;
+                       Height = height;
+        }
+               #endregion
+
+               #region PROPERTIES
+               [XmlIgnore]public double Left{
+                       get => X;
+            set { X = value; }
+        }
+               [XmlIgnore]public double Top{
+            get => Y;
+            set { Y = value; }
+        }
+               [XmlIgnore] public double Right => X + Width;
+               [XmlIgnore]public double Bottom => Y + Height;
+               [XmlIgnore]public SizeD Size{
+                       get => new SizeD (Width, Height);
+            set {
+                Width = value.Width;
+                Height = value.Height;
+            }
+        }
+               [XmlIgnore]public PointD Position{
+                       get => new PointD (X, Y);
+                       set {
+                               X = value.X;
+                               Y = value.Y;
+                       }
+               }
+               [XmlIgnore]public PointD TopLeft{
+                       get => new PointD (X, Y);
+                       set {
+                X = value.X;
+                Y = value.Y;
+            }
+        }
+               [XmlIgnore] public PointD TopRight => new PointD (Right, Y);
+               [XmlIgnore] public PointD BottomLeft => new PointD (X, Bottom);
+               [XmlIgnore] public PointD BottomRight => new PointD (Right, Bottom);        
+               [XmlIgnore] public PointD Center => new PointD (Left + Width / 2, Top + Height / 2);
+               [XmlIgnore] public PointD CenterD => new PointD (Left + Width / 2.0, Top + Height / 2.0);
+
+               #endregion
+
+               #region FUNCTIONS
+               public void Inflate(double xDelta, double yDelta)
+        {
+            this.X -= xDelta;
+            this.Width += 2 * xDelta;
+            this.Y -= yDelta;
+            this.Height += 2 * yDelta;
+        }
+               public void Inflate(double delta)
+               {
+                       Inflate (delta, delta);
+               }
+               public RectangleD Inflated (double delta) => Inflated (delta, delta);
+               public RectangleD Inflated (double deltaX, double deltaY) {
+                       RectangleD r = this;
+                       r.Inflate (deltaX, deltaY);
+                       return r;
+               }
+               public bool ContainsOrIsEqual (PointD p) => (p.X >= X && p.X <= X + Width && p.Y >= Y && p.Y <= Y + Height);
+               public bool ContainsOrIsEqual (RectangleD r) => r.TopLeft >= this.TopLeft && r.BottomRight <= this.BottomRight;
+        public bool Intersect(RectangleD r)
+        {
+            double maxLeft = Math.Max(this.Left, r.Left);
+            double minRight = Math.Min(this.Right, r.Right);
+            double maxTop = Math.Max(this.Top, r.Top);
+            double minBottom = Math.Min(this.Bottom, r.Bottom);
+
+                       return (maxLeft < minRight) && (maxTop < minBottom);
+        }
+        public RectangleD Intersection(RectangleD r)
+        {
+            RectangleD result = new RectangleD();
+            
+            if (r.Left >= Left)
+                result.Left = r.Left;
+            else
+                result.TopLeft = TopLeft;
+
+            if (r.Right >= Right)
+                result.Width = Right - result.Left;
+            else
+                result.Width = r.Right - result.Left;
+
+            if (r.Top >= Top)
+                result.Top = r.Top;
+            else
+                result.Top = Top;
+
+            if (r.Bottom >= Bottom)
+                result.Height = Bottom - result.Top;
+            else
+                result.Height = r.Bottom - result.Top;
+
+            return result;
+        }
+               #endregion
+
+        #region operators
+        public static RectangleD operator +(RectangleD r1, RectangleD r2)
+        {
+            double x = Math.Min(r1.X, r2.X);
+            double y = Math.Min(r1.Y, r2.Y);
+            double x2 = Math.Max(r1.Right, r2.Right);
+            double y2 = Math.Max(r1.Bottom, r2.Bottom);
+            return new RectangleD(x, y, x2 - x, y2 - y);
+        }
+               public static RectangleD operator + (RectangleD r, PointD p) => new RectangleD (r.X + p.X, r.Y + p.Y, r.Width, r.Height);
+               public static RectangleD operator - (RectangleD r, PointD p) => new RectangleD (r.X - p.X, r.Y - p.Y, r.Width, r.Height);
+               public static bool operator == (RectangleD r1, RectangleD r2) => r1.TopLeft == r2.TopLeft && r1.Size == r2.Size;
+               public static bool operator != (RectangleD r1, RectangleD r2) => !(r1.TopLeft == r2.TopLeft && r1.Size == r2.Size);        
+        #endregion        
+
+               public override string ToString () => $"{X},{Y},{Width},{Height}";        
+        public static RectangleD Parse(string s)
+        {
+            string[] d = s.Split(new char[] { ',' });
+            return new RectangleD(
+                double.Parse(d[0]),
+                double.Parse(d[1]),
+                double.Parse(d[2]),
+                double.Parse(d[3]));
+        }
+               public override int GetHashCode ()
+               {
+                       unchecked // Overflow is fine, just wrap
+                       {
+                               int hash = 17;
+                               // Suitable nullity checks etc, of course :)
+                               hash = hash * 23 + X.GetHashCode();
+                               hash = hash * 23 + Y.GetHashCode();
+                               hash = hash * 23 + Width.GetHashCode();
+                               hash = hash * 23 + Height.GetHashCode();
+                               return hash;
+                       }
+               }
+               public override bool Equals (object obj) => (obj == null || obj.GetType () != typeof (RectangleD)) ?
+                               false : this == (RectangleD)obj;
+    }
+}
index 4d0bcb58bd65adfec4b77a6118d424404734820c..18bc8b5751f15fb2a01d68631778b9ead50b5ff0 100644 (file)
-//
-// Size.cs
+// Copyright (c) 2013-2019  Bruyère Jean-Philippe jp_bruyere@hotmail.com
 //
-// Author:
-//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 
 namespace Crow
 {
     public struct Size
     {
-        public static Size Zero
-        { get { return new Size(0, 0); } }
+               public static Size Zero => new Size (0, 0);
 
-        int _width;
-        int _height;
+               public int Width, Height;
 
-        public Size(int width, int height)
-        {
-            _width = width;
-            _height = height;
-        }
-               public Size(int size)
-               {
-                       _width = size;
-                       _height = size;
-               }
-        public int Width
-        {
-            get { return _width; }
-            set { _width = value; }
-        }
-        public int Height
-        {
-            get { return _height; }
-            set { _height = value; }
-        }
-
-               #region operators
-               public static implicit operator Rectangle(Size s)
+               #region CTOR
+               public Size (int width, int height)
                {
-                       return new Rectangle (s);
+                       Width = width;
+                       Height = height;
                }
-        public static implicit operator Size(int i)
-        {
-            return new Size(i, i);
-        }
-               public static implicit operator string(Size s)
+               public Size (int size)
                {
-                       return s.ToString ();
+                       Width = size;
+                       Height = size;
                }
-               public static implicit operator Size(string s)
-               {
-                       return string.IsNullOrEmpty (s) ? Size.Zero : Parse (s);
-               }
-               public static bool operator ==(Size s1, Size s2)
-        {
-            if (s1.Width == s2.Width && s1.Height == s2.Height)
-                return true;
-            else
-                return false;
-        }
-        public static bool operator !=(Size s1, Size s2)
-        {
-            if (s1.Width == s2.Width && s1.Height == s2.Height)
-                return false;
-            else
-                return true;
-        }
-        public static bool operator >(Size s1, Size s2)
-        {
-            if (s1.Width > s2.Width && s1.Height > s2.Height)
-                return true;
-            else
-                return false;
-        }
-        public static bool operator >=(Size s1, Size s2)
-        {
-            if (s1.Width >= s2.Width && s1.Height >= s2.Height)
-                return true;
-            else
-                return false;
-        }
-        public static bool operator <(Size s1, Size s2)
-        {
-            if (s1.Width < s2.Width)
-                if (s1.Height <= s2.Height)
-                    return true;
-                else
-                    return false;
-            else if (s1.Width == s2.Width && s1.Height < s2.Height)
-                return true;
+               #endregion
 
-            return false;
-        }
-               public static bool operator <(Size s, int i)
-               {
-                       return s.Width < i && s.Height < i ? true : false;
-               }
-               public static bool operator <=(Size s, int i)
-               {
-                       return s.Width <= i && s.Height <= i ? true : false;
-               }
-               public static bool operator >(Size s, int i)
-               {
-                       return s.Width > i && s.Height > i ? true : false;
-               }
-               public static bool operator >=(Size s, int i)
-               {
-                       return s.Width >= i && s.Height >= i ? true : false;
-               }
-               public static bool operator <=(Size s1, Size s2)
-        {
-            if (s1.Width <= s2.Width && s1.Height <= s2.Height)
-                return true;
-            else
-                return false;
-        }
-        public static bool operator ==(Size s, int i)
-        {
-            if (s.Width == i && s.Height == i)
-                return true;
-            else
-                return false;
-        }
-        public static bool operator !=(Size s, int i)
-        {
-            if (s.Width == i && s.Height == i)
-                return false;
-            else
-                return true;
-               }
-               public static Size operator +(Size s1, Size s2)
-               {
-                       return new Size(s1.Width + s2.Width, s1.Height + s2.Height);
-               }
-        public static Size operator +(Size s, int i)
-        {
-            return new Size(s.Width + i, s.Height + i);
-        }
-               public static Size operator *(Size s, int i)
-               {
-                       return new Size(s.Width * i, s.Height * i);
-               }
-               public static Size operator /(Size s, int i)
-               {
-                       return new Size(s.Width / i, s.Height / i);
-               }
+               #region operators
+               public static implicit operator Rectangle(Size s)=> new Rectangle (s);
+        public static implicit operator Size(int i)=> new Size(i, i);
+               public static implicit operator string(Size s)=> s.ToString ();
+               public static implicit operator Size(string s)=> string.IsNullOrEmpty (s) ? Zero : Parse (s);
+
+               public static bool operator == (Size s1, Size s2) => (s1.Width == s2.Width && s1.Height == s2.Height);
+               public static bool operator != (Size s1, Size s2) => (s1.Width == s2.Width && s1.Height == s2.Height);
+               public static bool operator > (Size s1, Size s2) => (s1.Width > s2.Width && s1.Height > s2.Height);
+               public static bool operator >= (Size s1, Size s2) => (s1.Width >= s2.Width && s1.Height >= s2.Height);
+               public static bool operator < (Size s1, Size s2) => (s1.Width < s2.Width) ? s1.Height <= s2.Height :
+                                                                                                                               (s1.Width == s2.Width && s1.Height < s2.Height);
+               public static bool operator < (Size s, int i) => s.Width < i && s.Height < i;
+               public static bool operator <= (Size s, int i) => s.Width <= i && s.Height <= i;
+               public static bool operator > (Size s, int i) => s.Width > i && s.Height > i;
+               public static bool operator >= (Size s, int i) => s.Width >= i && s.Height >= i;
+               public static bool operator <= (Size s1, Size s2) => (s1.Width <= s2.Width && s1.Height <= s2.Height);
+               public static bool operator == (Size s, int i) => (s.Width == i && s.Height == i);
+               public static bool operator != (Size s, int i) => (s.Width == i && s.Height == i);
+               public static Size operator + (Size s1, Size s2) => new Size (s1.Width + s2.Width, s1.Height + s2.Height);
+               public static Size operator + (Size s, int i) => new Size (s.Width + i, s.Height + i);
+               public static Size operator * (Size s, int i) => new Size (s.Width * i, s.Height * i);
+               public static Size operator / (Size s, int i) => new Size (s.Width / i, s.Height / i);
                #endregion
 
                public override int GetHashCode ()
@@ -178,21 +54,13 @@ namespace Crow
                        {
                                int hash = 17;
                                // Suitable nullity checks etc, of course :)
-                               hash = hash * 23 + _width.GetHashCode();
-                               hash = hash * 23 + _height.GetHashCode();
+                               hash = hash * 23 + Width.GetHashCode();
+                               hash = hash * 23 + Height.GetHashCode();
                                return hash;
                        }
                }
-               public override bool Equals (object obj)
-               {
-                       return (obj == null || obj.GetType() != typeof(Size)) ?
-                               false :
-                               this == (Size)obj;
-               }
-               public override string ToString()
-               {
-                       return string.Format("{0},{1}", Width, Height);
-               }
+               public override bool Equals (object obj) => (obj == null || obj.GetType () != typeof (Size)) ? false : this == (Size)obj;
+               public override string ToString () => $"{Width},{Height}";
                public static Size Parse(string s)
                {
                        string[] d = s.Split(new char[] { ',' });
@@ -201,5 +69,4 @@ namespace Crow
                                int.Parse(d[1]));
                }
        }
-
 }
diff --git a/Crow/src/SizeD.cs b/Crow/src/SizeD.cs
new file mode 100644 (file)
index 0000000..2dbdb02
--- /dev/null
@@ -0,0 +1,71 @@
+// Copyright (c) 2013-2019  Bruyère Jean-Philippe jp_bruyere@hotmail.com
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+namespace Crow
+{
+       public struct SizeD {
+               public static SizeD Zero => new SizeD (0, 0);
+
+               public double Width, Height;
+
+               #region CTOR
+               public SizeD (double width, double height)
+               {
+                       Width = width;
+                       Height = height;
+               }
+               public SizeD (double size)
+               {
+                       Width = size;
+                       Height = size;
+               }
+               #endregion
+
+               #region operators
+               public static implicit operator RectangleD (SizeD s) => new RectangleD (s);
+               public static implicit operator SizeD (double i) => new SizeD (i, i);
+               public static implicit operator string (SizeD s) => s.ToString ();
+               public static implicit operator SizeD (string s) => string.IsNullOrEmpty (s) ? Zero : Parse (s);
+
+               public static bool operator == (SizeD s1, SizeD s2) => (s1.Width == s2.Width && s1.Height == s2.Height);
+               public static bool operator != (SizeD s1, SizeD s2) => (s1.Width == s2.Width && s1.Height == s2.Height);
+               public static bool operator > (SizeD s1, SizeD s2) => (s1.Width > s2.Width && s1.Height > s2.Height);
+               public static bool operator >= (SizeD s1, SizeD s2) => (s1.Width >= s2.Width && s1.Height >= s2.Height);
+               public static bool operator < (SizeD s1, SizeD s2) => (s1.Width < s2.Width) ? s1.Height <= s2.Height :
+                                                                                                                               (s1.Width == s2.Width && s1.Height < s2.Height);
+               public static bool operator < (SizeD s, double i) => s.Width < i && s.Height < i;
+               public static bool operator <= (SizeD s, double i) => s.Width <= i && s.Height <= i;
+               public static bool operator > (SizeD s, double i) => s.Width > i && s.Height > i;
+               public static bool operator >= (SizeD s, double i) => s.Width >= i && s.Height >= i;
+               public static bool operator <= (SizeD s1, SizeD s2) => (s1.Width <= s2.Width && s1.Height <= s2.Height);
+               public static bool operator == (SizeD s, double i) => (s.Width == i && s.Height == i);
+               public static bool operator != (SizeD s, double i) => (s.Width == i && s.Height == i);
+               public static SizeD operator + (SizeD s1, SizeD s2) => new SizeD (s1.Width + s2.Width, s1.Height + s2.Height);
+               public static SizeD operator + (SizeD s, double i) => new SizeD (s.Width + i, s.Height + i);
+               public static SizeD operator * (SizeD s, double i) => new SizeD (s.Width * i, s.Height * i);
+               public static SizeD operator / (SizeD s, double i) => new SizeD (s.Width / i, s.Height / i);
+               #endregion
+
+               public override int GetHashCode ()
+               {
+                       unchecked // Overflow is fine, just wrap
+                       {
+                               int hash = 17;
+                               // Suitable nullity checks etc, of course :)
+                               hash = hash * 23 + Width.GetHashCode ();
+                               hash = hash * 23 + Height.GetHashCode ();
+                               return hash;
+                       }
+               }
+               public override bool Equals (object obj) => (obj == null || obj.GetType () != typeof (SizeD)) ? false : this == (SizeD)obj;
+               public override string ToString () => $"{Width},{Height}";
+               public static SizeD Parse (string s)
+               {
+                       string [] d = s.Split (new char [] { ',' });
+                       return d.Length == 1 ? new SizeD (double.Parse (d [0])) : new SizeD (
+                               double.Parse (d [0]),
+                               double.Parse (d [1]));
+               }
+       }
+}
index f14c7cf72ddf2b0346b4dc7da7146626631dcf80..5c8ebb729bf5dc750cdf6bda72cf3a6af0155b77 100644 (file)
@@ -53,7 +53,7 @@ namespace Crow
                {
                        ctx.SetSourceRGBA (color.R, color.G, color.B, color.A);
                }
-               public static object Parse(string s)
+               public static new object Parse(string s)
                {
                        return new SolidColor((Color)s);
                }
diff --git a/Crow/src/StbImage.cs b/Crow/src/StbImage.cs
new file mode 100644 (file)
index 0000000..8cb4d75
--- /dev/null
@@ -0,0 +1,68 @@
+// Copyright (c) 2019  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System;
+using System.IO;
+using System.Runtime.InteropServices;
+
+namespace Crow {
+    public class StbImage : IDisposable {
+        const string stblib = "stb";
+
+        [DllImport (stblib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load")]
+        static extern IntPtr Load ([MarshalAs (UnmanagedType.LPStr)] string filename, out int x, out int y, out int channels_in_file, int desired_channels);
+
+               [DllImport (stblib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_from_memory")]
+        static extern IntPtr Load (IntPtr bitmap, int byteCount, out int x, out int y, out int channels_in_file, int desired_channels);        
+
+        [DllImport (stblib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_image_free")]
+        static extern void FreeImage (IntPtr img);
+
+               public readonly IntPtr Handle;
+               public readonly int Width;
+               public readonly int Height;
+               public readonly int Channels;
+               public int Size => Width * Height * Channels;
+
+               /// <summary>
+               /// Open image file with STBI library
+               /// </summary>
+               /// <param name="path">file path</param>
+               /// <param name="requestedChannels">Force returned channels count, set 0 for original count</param>
+               public StbImage (string path, int requestedChannels = 4) {
+                       Handle = StbImage.Load (path, out Width, out Height, out Channels, requestedChannels);
+                       if (Handle == IntPtr.Zero)
+                               throw new Exception ($"STBI image loading error.");
+                       if (requestedChannels > 0)
+                               Channels = requestedChannels;
+               }
+               /// <summary>
+               /// Open image in memory with STBI library
+               /// </summary>
+               /// <param name="bitmap">raw bitmap datas</param>
+               /// <param name="bitmapByteCount">Bitmap byte count.</param>
+               /// <param name="requestedChannels">Force returned channels count, set 0 for original count</param>
+               public StbImage (IntPtr bitmap, ulong bitmapByteCount, int requestedChannels = 4) {
+                       Handle = StbImage.Load (bitmap, (int)bitmapByteCount, out Width, out Height, out Channels, requestedChannels);
+                       if (Handle == IntPtr.Zero)
+                               throw new Exception ($"STBI image loading error.");
+                       if (requestedChannels > 0)
+                               Channels = requestedChannels;
+               }
+               public StbImage (Stream stream, int requestedChannels = 4)
+               {
+                       byte [] buff = new byte [stream.Length];
+                       stream.Read (buff, 0, (int)stream.Length);
+                       GCHandle hnd = GCHandle.Alloc (buff, GCHandleType.Pinned);
+                       Handle = StbImage.Load (hnd.AddrOfPinnedObject(), (int)stream.Length, out Width, out Height, out Channels, requestedChannels);
+                       hnd.Free ();
+                       if (Handle == IntPtr.Zero)
+                               throw new Exception ($"STBI image loading error.");
+                       if (requestedChannels > 0)
+                               Channels = requestedChannels;
+               }
+               public void Dispose () {
+                       StbImage.FreeImage (Handle);
+               }
+       }
+}
index 0cad0f4fb77b8dfdae414924b15a3dbe6f7ba422..e5a3e93561a1e0f2bbc0934ba046aafdb4328741 100644 (file)
@@ -1,28 +1,6 @@
-//
-// IBackend.cs
+// Copyright (c) 2019  Bruyère Jean-Philippe jp_bruyere@hotmail.com
 //
-// Author:
-//       Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 using System;
 
 namespace Crow
index b61eaa2b7568803f546e91fa6a2bafaf2130c733..36f1696524e4164775c62ed1b7ae07bffd74a90e 100644 (file)
@@ -120,11 +120,11 @@ namespace OpenToolkit.NT.Native
             /// For extended error information, your application can call <see cref="Marshal.GetLastWin32Error"/>.
             /// </returns>
             [DllImport("user32", SetLastError = true)]
-            public static unsafe extern int GetMouseMovePointsEx
+            public static extern int GetMouseMovePointsEx
             (
                 [In] uint size,
                 [In] ref MouseMovePoint movePointIn,
-                [Out] MouseMovePoint* movePointOutBuffer,
+                [Out] IntPtr movePointOutBuffer,
                 [In] int pointAmount,
                 [In] GetMouseMovePointsResolution resolution
             );
index 486496167ee1ed1438b93fae8455489735cf2905..6273253714af58a946172cb3b32ec970590edb8b 100644 (file)
@@ -55,10 +55,10 @@ namespace OpenToolkit.NT.Native
             /// </returns>
             [SuppressUnmanagedCodeSecurity]
             [DllImport(Library)]
-            public static unsafe extern IntPtr DefRawInputProc
+            public static extern IntPtr DefRawInputProc
             (
-                [In] Native.RawInput* rawInputArrayOut,
-                [In] int rawInputAmount,
+                [In] IntPtr rawInputArrayOut,//Native.RawInput*
+                               [In] int rawInputAmount,
                 [In] uint headerSize
             );
 
@@ -155,10 +155,10 @@ namespace OpenToolkit.NT.Native
             /// </returns>
             [SuppressUnmanagedCodeSecurity]
             [DllImport(Library, SetLastError = true)]
-            public static unsafe extern uint GetRawInputBuffer
+            public static extern uint GetRawInputBuffer
             (
-                [Out] [Optional] Native.RawInput* data,
-                [In] [Out] ref uint rawInputSize,
+                [Out] [Optional] IntPtr data,//Native.RawInput*
+                               [In] [Out] ref uint rawInputSize,
                 [In] uint headerSize
             );
 
@@ -219,10 +219,10 @@ namespace OpenToolkit.NT.Native
             /// <see cref="Marshal.GetLastWin32Error"/> returns the error indication.
             /// </returns>
             [DllImport(Library, SetLastError = true)]
-            public static unsafe extern uint GetRawInputDeviceList
+            public static extern uint GetRawInputDeviceList
             (
-                [Out] [Optional] RawInputDeviceList* deviceListArrayOut,
-                [In] [Out] ref uint deviceListAmount,
+                [Out] [Optional] IntPtr deviceListArrayOut,//RawInputDeviceList*
+                               [In] [Out] ref uint deviceListAmount,
                 [In] uint deviceListSize
             );
 
@@ -286,7 +286,7 @@ namespace OpenToolkit.NT.Native
             /// </returns>
             [SuppressUnmanagedCodeSecurity]
             [DllImport(Library, SetLastError = true)]
-            public static unsafe extern uint GetRawInputDeviceInfo
+            public static extern uint GetRawInputDeviceInfo
             (
                 [In] [Optional] IntPtr device,
                 [In] GetRawInputDeviceInfoEnum command,
@@ -341,20 +341,22 @@ namespace OpenToolkit.NT.Native
             /// <paramref name="header"/>.<para/>
             /// If there is an error, the return value is (uint)-1 [== <see cref="uint.MaxValue"/>].
             /// </returns>
-            public static unsafe uint GetRawInputData(IntPtr rawInput, out RawInputHeader header)
+            public static uint GetRawInputData(IntPtr rawInput, out RawInputHeader header)
             {
-                uint size = RawInputHeader.SizeInBytes;
-                fixed (RawInputHeader* headerPtr = &header)
-                {
-                    return GetRawInputData
-                    (
-                        rawInput,
-                        GetRawInputDataCommand.Header,
-                        (IntPtr)headerPtr,
-                        ref size,
-                        RawInputHeader.SizeInBytes
-                    );
-                }
+                               //uint size = RawInputHeader.SizeInBytes;
+                               //fixed (RawInputHeader* headerPtr = &header)
+                               //{
+                               //    return GetRawInputData
+                               //    (
+                               //        rawInput,
+                               //        GetRawInputDataCommand.Header,
+                               //        (IntPtr)headerPtr,
+                               //        ref size,
+                               //        RawInputHeader.SizeInBytes
+                               //    );
+                               //}
+                               header = default (RawInputHeader);
+                               return 0u;
             }
 
             /// <summary>
@@ -370,20 +372,21 @@ namespace OpenToolkit.NT.Native
             /// <paramref name="data"/>.<para/>
             /// If there is an error, the return value is (uint)-1 [== <see cref="uint.MaxValue"/>].
             /// </returns>
-            public static unsafe uint GetRawInputData(IntPtr rawInput, out Native.RawInput data)
+            public static uint GetRawInputData(IntPtr rawInput, out Native.RawInput data)
             {
                 uint size = Native.RawInput.SizeInBytes;
-                fixed (Native.RawInput* dataPtr = &data)
-                {
-                    return GetRawInputData
-                    (
-                        rawInput,
-                        GetRawInputDataCommand.Input,
-                        (IntPtr)dataPtr,
-                        ref size,
-                        RawInputHeader.SizeInBytes
-                    );
-                }
+                               throw new NotImplementedException ();
+                //fixed (Native.RawInput* dataPtr = &data)
+                //{
+                //    return GetRawInputData
+                //    (
+                //        rawInput,
+                //        GetRawInputDataCommand.Input,
+                //        (IntPtr)dataPtr,
+                //        ref size,
+                //        RawInputHeader.SizeInBytes
+                //    );
+                //}
             }
 
             /// <summary>
index 874402bd9a6d776fad680646f15d85a2737b2ed4..c9d04396cbb6976c406a5b4b6a869304c5dac783 100644 (file)
@@ -34,21 +34,12 @@ namespace OpenToolkit.NT.Native
         /// <summary>
         /// Gets a string that specifies the name of the device.
         /// </summary>
-        public unsafe string Name
-        {
-            get
-            {
-                fixed (char* namePtr = &_name)
-                {
-                    return Marshal.PtrToStringUni((IntPtr)namePtr);
-                }
-            }
-        }
+        //public string Name => Marshal.PtrToStringUni (_name);
 
-        /// <summary>
-        /// The first character of the <see cref="Name"/>.
-        /// </summary>
-        private char _name;
+               /// <summary>
+               /// The first character of the <see cref="Name"/>.
+               /// </summary>
+               //IntPtr _name;
 
         /// <summary>
         /// The size of this structure in bytes.
index 9f3c13d20ecf3108deda27d79b5366cc4b1355f4..72d97138136f02a11c420c2c22f4898b1592bcd2 100644 (file)
@@ -117,26 +117,17 @@ namespace OpenToolkit.NT.Native
         /// Gets the name of the printer form to use; such as "Letter" or "Legal".
         /// This must be a name that can be obtain by calling the Win32 EnumForms function.
         /// </summary>
-        public unsafe string FormName
-        {
-            get
-            {
-                fixed (char* formNamePtr = &_formName)
-                {
-                    return Marshal.PtrToStringUni((IntPtr)formNamePtr);
-                }
-            }
-        }
-
-        /// <summary>
-        /// With the current struct layout (which is set in stone because of interoperability with the Windows API),
-        /// there is no way to put a `string` type at this position(string is a reference type -> there is a pointer
-        /// here, which is either 4 or 8 bytes depending on the platform). This means that a string can never be
-        /// properly aligned at position 102 (which, again, can't be changed). This is why the <see cref="FormName"/>
-        /// property exists.
-        /// </summary>
-        [FieldOffset(102)]
-        private char _formName;
+        public string FormName => Marshal.PtrToStringUni (_formName);
+
+               /// <summary>
+               /// With the current struct layout (which is set in stone because of interoperability with the Windows API),
+               /// there is no way to put a `string` type at this position(string is a reference type -> there is a pointer
+               /// here, which is either 4 or 8 bytes depending on the platform). This means that a string can never be
+               /// properly aligned at position 102 (which, again, can't be changed). This is why the <see cref="FormName"/>
+               /// property exists.
+               /// </summary>
+               [FieldOffset(102)]
+        private IntPtr _formName;
 
         /// <summary>
         /// For displays, specifies the number of logical pixels per inch of a display device and should be equal
index f415e71aafd08a9088fbb7c6b7f3a3a5263c8bc4..a2209921e22c9c30109fba9bd54ea34dde101d01 100644 (file)
@@ -30,19 +30,20 @@ namespace OpenToolkit.NT.Native
         /// Gets the raw input data as an array of bytes.
         /// </summary>
         /// <returns>An array of raw input data.</returns>
-        public unsafe byte[] GetRawData()
+        public byte[] GetRawData()
         {
             byte[] result = new byte[SizeHid * Count];
 
-            fixed (byte* dataPtr = &RawData)
-            {
-                for (int i = 0; i < result.Length; i++)
-                {
-                    result[i] = *(dataPtr + i);
-                }
-            }
 
-            return result;
+                       //fixed (byte* dataPtr = &RawData)
+                       //{
+                       //    for (int i = 0; i < result.Length; i++)
+                       //    {
+                       //        result[i] = *(dataPtr + i);
+                       //    }
+                       //}
+                       throw new NotImplementedException();
+            //return result;
         }
 
         /// <summary>
@@ -50,17 +51,18 @@ namespace OpenToolkit.NT.Native
         /// </summary>
         /// <param name="index">The index at which to access the raw input data.</param>
         /// <returns>A byte of raw input data at the given index.</returns>
-        public unsafe byte GetRawDataAt(int index)
+        public byte GetRawDataAt(int index)
         {
             if (index < 0 || index > SizeHid * Count)
             {
                 throw new ArgumentOutOfRangeException(nameof(index));
             }
 
-            fixed (byte* dataPtr = &RawData)
-            {
-                return *(dataPtr + index);
-            }
-        }
+                       //fixed (byte* dataPtr = &RawData)
+                       //{
+                       //    return *(dataPtr + index);
+                       //}
+                       throw new NotImplementedException ();
+               }
     }
 }
index 50e54b93582783d89554a94a5c37a89e8b85e7c5..35bce85eaa7e401fec2a1a3d9975c44e29e169c0 100644 (file)
@@ -44,7 +44,7 @@ namespace Crow.Win32 {
 
                WindowProc WindowProcedureDelegate;
                string className = "myWindowClass";
-               IntPtr instance;// = Marshal.GetHINSTANCE(typeof(Win32Backend).Module);
+               IntPtr instance = IntPtr.Zero; //Marshal.GetHINSTANCE(typeof(Win32Backend).Module);
                IntPtr handle = IntPtr.Zero;
                IntPtr hdc = IntPtr.Zero;
                Interface iFace;
@@ -291,9 +291,9 @@ namespace Crow.Win32 {
                        Key k = GetKey ((int)scancode);
 
                        if (pressed)
-                               iFace.ProcessKeyDown (k);
+                               iFace.OnKeyDown (k);
                        else
-                               iFace.ProcessKeyUp (k);
+                               iFace.OnKeyUp (k);
                }
                void handleChar (IntPtr lParam, IntPtr wParam) {
                        char c = IntPtr.Size == 4 ?
@@ -301,7 +301,7 @@ namespace Crow.Win32 {
                                (char)wParam.ToInt64 ();
 
                        if (!char.IsControl (c))
-                               iFace.ProcessKeyPress (c);
+                               iFace.OnKeyPress (c);
                }
 
 
@@ -312,32 +312,32 @@ namespace Crow.Win32 {
 
                        switch (message) {
                                case WindowMessage.MouseMove:
-                                       iFace.ProcessMouseMove
+                                       iFace.OnMouseMove
                                        ((int)((uint)lParam.ToInt32 () & 0x0000FFFF), (int)(((uint)lParam.ToInt32 () & 0xFFFF0000) >> 16));
                                        break;
                                case WindowMessage.LButtonDown:
-                                       iFace.ProcessMouseButtonDown (Crow.MouseButton.Left);
+                                       iFace.OnMouseButtonDown (Crow.MouseButton.Left);
                                        return IntPtr.Zero;
                                case WindowMessage.RButtonDown:
-                                       iFace.ProcessMouseButtonDown (Crow.MouseButton.Right);
+                                       iFace.OnMouseButtonDown (Crow.MouseButton.Right);
                                        return IntPtr.Zero;
                                case WindowMessage.MButtonDown:
-                                       iFace.ProcessMouseButtonDown (Crow.MouseButton.Middle);
+                                       iFace.OnMouseButtonDown (Crow.MouseButton.Middle);
                                        return IntPtr.Zero;
                                case WindowMessage.LButtonUp:
-                                       iFace.ProcessMouseButtonUp (Crow.MouseButton.Left);
+                                       iFace.OnMouseButtonUp (Crow.MouseButton.Left);
                                        return IntPtr.Zero;
                                case WindowMessage.RButtonUp:
-                                       iFace.ProcessMouseButtonUp (Crow.MouseButton.Right);
+                                       iFace.OnMouseButtonUp (Crow.MouseButton.Right);
                                        return IntPtr.Zero;
                                case WindowMessage.MButtonUp:
-                                       iFace.ProcessMouseButtonUp (Crow.MouseButton.Middle);
+                                       iFace.OnMouseButtonUp (Crow.MouseButton.Middle);
                                        return IntPtr.Zero;
                                case WindowMessage.MouseWheel:
-                                       iFace.ProcessMouseWheelChanged ((((long)wParam << 32) >> 48) / 120.0f);
+                                       iFace.OnMouseWheelChanged ((((long)wParam << 32) >> 48) / 120.0f);
                                        return IntPtr.Zero;
                                case WindowMessage.MouseHWheel:
-                                       iFace.ProcessMouseWheelChanged ((((long)wParam << 32) >> 48) / 120.0f);
+                                       iFace.OnMouseWheelChanged ((((long)wParam << 32) >> 48) / 120.0f);
                                        return IntPtr.Zero;
                                case WindowMessage.KeyDown:
                                case WindowMessage.SystemKeyDown:
index 8d29f6733d2b13aa4109bd2d7042f9f04d8b3b88..c8e461ac1f278646101f337b8a3814ba3fcaa94f 100644 (file)
@@ -58,10 +58,9 @@ namespace Crow
                        XCursorFile tmp = new XCursorFile ();
 
                        using (BinaryReader sr = new BinaryReader (s)) {
-                               byte[] data;
                                //magic: CARD32 ’Xcur’ (0x58, 0x63, 0x75, 0x72)
                                if (new string (sr.ReadChars (4)) != "Xcur") {
-                                       Debug.WriteLine ("XCursor Load error: Wrong magic");
+                                       Console.WriteLine ("XCursor Load error: Wrong magic");
                                        return null;
                                }
                                //header: CARD32 bytes in this header
index 8464defb6edb9e56a7e21141cb39b9add47c5bfb..7397af4f4c6834f9ab646ef9368ff2c094ee41f4 100644 (file)
@@ -38,6 +38,8 @@ namespace Crow.XCB
        using xcb_timestamp_t = System.UInt32;
 
        using xcb_void_cookie_t = System.UInt32;
+       using xcb_intern_atom_cookie_t = System.UInt32;
+       using xcb_atom_t = System.UInt32;
 
        public class XCBBackend : IBackend
        {
@@ -149,8 +151,15 @@ namespace Crow.XCB
                        COLORMAP = 8192,
                        CURSOR = 16384
                }
+               enum xcb_prop_mode : byte
+               {
+                       Replace,//Discard the previous property value and store the new data.
+                       Prepend,//Insert the new data before the beginning of existing data.The format must match existing property value.If the property is undefined, it is treated as defined with the correct type and format with zero-length data.
+                       Append,//Insert the new data after the beginning of existing data.The format must match existing property value.If the property is undefined, it is treated as defined with the correct type and format with zero-length data.
+               }
 
-               [StructLayout(LayoutKind.Sequential)]
+
+       [StructLayout(LayoutKind.Sequential)]
                struct xcb_generic_event_t{
                        public xcb_event_type response_type;  /**< Type of the response */
                        public byte pad0;           /**< Padding */
@@ -314,6 +323,15 @@ namespace Crow.XCB
                        public UInt16 sequence;       /**< Sequence number */
                        public UInt32 length;         /**< Length of the response */
                }
+               [StructLayout (LayoutKind.Sequential)]
+               struct xcb_intern_atom_reply_t
+               {
+                       byte response_type;
+                       byte pad0;
+                       UInt16 sequence;
+                       UInt32 length;
+                       xcb_atom_t atom;
+               }
                #endregion
 
 
@@ -359,6 +377,13 @@ namespace Crow.XCB
                [DllImport ("xcb")]//in xcbproto
                static extern xcb_void_cookie_t xcb_free_cursor (IntPtr connection, UInt32 cursor);
 
+               [DllImport ("xcb")]
+               static extern xcb_intern_atom_cookie_t xcb_intern_atom (IntPtr connection, byte onlyIfExists, UInt16 nameLength, string name);
+               [DllImport ("xcb")]
+               static extern IntPtr xcb_intern_atom_reply (IntPtr connection, xcb_intern_atom_cookie_t cookie, IntPtr xcb_generic_error);
+               [DllImport ("xcb")]
+               static extern xcb_void_cookie_t xcb_change_property (IntPtr connection, xcb_prop_mode mode, xcb_window_t window, xcb_atom_t property, xcb_atom_t type, byte format, UInt32 data_len, ref IntPtr data);
+
                //TODO: there should be a generic free method in xcb or at least xcb_free_event!!
                [DllImport ("X11")]
                static extern IntPtr XFree (IntPtr data);
@@ -391,6 +416,7 @@ namespace Crow.XCB
 
                XKB.XCBKeyboard Keyboard;
 
+               xcb_atom_t wmQuitAtom;
 
                #region IBackend implementation
                public void Init (Interface _iFace)
@@ -409,7 +435,7 @@ namespace Crow.XCB
                        win = xcb_generate_id (conn);
 
                        xcb_cw_t mask = xcb_cw_t.BACK_PIXEL | xcb_cw_t.EVENT_MASK;
-                       uint[] values = {
+                       uint [] values = {
                                scr.black_pixel,
                                (uint)(
                                        xcb_event_mask_t.EXPOSURE |
@@ -421,6 +447,12 @@ namespace Crow.XCB
                                )
                        };
 
+                       xcb_intern_atom_cookie_t cookie = xcb_intern_atom (conn, 1, 12, "WM_PROTOCOLS");
+                       IntPtr reply = xcb_intern_atom_reply (conn, cookie, IntPtr.Zero);
+
+                       xcb_intern_atom_cookie_t cookie2 = xcb_intern_atom (conn, 0, 16, "WM_DELETE_WINDOW");
+                       IntPtr reply2 = xcb_intern_atom_reply (conn, cookie2, IntPtr.Zero);
+
 
                        GCHandle hndValues = GCHandle.Alloc (values, GCHandleType.Pinned);
 
@@ -429,6 +461,11 @@ namespace Crow.XCB
 
                        hndValues.Free ();
 
+                       IntPtr tmp = Marshal.ReadIntPtr (reply2, 8);
+                       wmQuitAtom = (xcb_atom_t)tmp;
+
+                       xcb_change_property (conn, xcb_prop_mode.Replace, win, (xcb_atom_t)Marshal.ReadInt32(reply,8), 4, 32, 1, ref tmp);
+
                        xcb_map_window (conn, win);
 
                        xcb_flush (conn);
@@ -465,26 +502,26 @@ namespace Crow.XCB
                                return;
                        xcb_event_t evt = (xcb_event_t)Marshal.PtrToStructure (evtPtr, typeof(xcb_event_t));
 
-                       switch (evt.response_type) {
+                       switch ((xcb_event_type)((uint)evt.response_type & ~0x80u)) {
                        case xcb_event_type.EXPOSE:
                                if (evt.width > 0)
                                        iFace.ProcessResize (new Rectangle (0, 0, evt.width, evt.height));
                                break;
                        case xcb_event_type.MOTION_NOTIFY:
-                               iFace.ProcessMouseMove (evt.event_x, evt.event_y);
+                               iFace.OnMouseMove (evt.event_x, evt.event_y);
                                break;
                        case xcb_event_type.BUTTON_PRESS:
                                if (evt.button == xcb_button_t.WheelUp)
-                                       iFace.ProcessMouseWheelChanged (Interface.WheelIncrement);
+                                       iFace.OnMouseWheelChanged (Interface.WheelIncrement);
                                else if(evt.button == xcb_button_t.WheelDown)
-                                       iFace.ProcessMouseWheelChanged (-Interface.WheelIncrement);
+                                       iFace.OnMouseWheelChanged (-Interface.WheelIncrement);
                                else
-                                       iFace.ProcessMouseButtonDown ((MouseButton)(evt.detail - 1));                           
+                                       iFace.OnMouseButtonDown ((MouseButton)(evt.detail - 1));                                
                                break;
                        case xcb_event_type.BUTTON_RELEASE:
                                if (evt.button == xcb_button_t.WheelUp || evt.button == xcb_button_t.WheelDown)
                                        break;
-                               iFace.ProcessMouseButtonUp ((MouseButton)(evt.detail - 1));
+                               iFace.OnMouseButtonUp ((MouseButton)(evt.detail - 1));
                                break;
                        case xcb_event_type.KEY_PRESS:
                                Keyboard.HandleEvent (evt.keycode, true);
@@ -492,8 +529,12 @@ namespace Crow.XCB
                        case xcb_event_type.KEY_RELEASE:
                                Keyboard.HandleEvent (evt.keycode, false);
                                break;
+                       case xcb_event_type.CLIENT_MESSAGE:
+                               if ((xcb_atom_t)Marshal.ReadInt32 (evtPtr, 12)==wmQuitAtom)
+                                       iFace.Quit ();
+                               break;
                        default:
-                               Console.WriteLine ("unknown event");
+                               Console.WriteLine ($"unknown event: {evt.response_type}");
                                break;
                        }
                        XFree (evtPtr);
index 5043ec37998ca2cbfb694839b217d4fa2b5f5aa2..810f417e96cdad9c1ef19dab3c5623e2b56411db 100644 (file)
@@ -2535,7 +2535,7 @@ namespace Crow.XKB
                        xkb_key_direction keyDir = xkb_key_direction.KEY_DOWN;
 
                        if (pressed) {
-                               iFace.ProcessKeyDown ((Key)ks);
+                               iFace.OnKeyDown ((Key)ks);
 
                                IntPtr ptrKeySyms = IntPtr.Zero;
 
@@ -2547,10 +2547,10 @@ namespace Crow.XKB
                                char c = char.ConvertFromUtf32 ((int)utf32) [0];
 
                                if (!char.IsControl (c))
-                                       iFace.ProcessKeyPress (c);
+                                       iFace.OnKeyPress (c);
                        } else {
                                keyDir = xkb_key_direction.KEY_UP;
-                               iFace.ProcessKeyUp ((Key)ks);
+                               iFace.OnKeyUp ((Key)ks);
                        }
 
                        xkb_state_update_key (xkbState, keycode, keyDir);
index 2af86d3ffc493cc8078e935f6be1a060471a96f3..c73a2ee20511e68df128efd883a3f82bd28fa8c5 100644 (file)
@@ -39,7 +39,7 @@ namespace Crow.XLib
                static extern IntPtr XGetKeyboardMapping (IntPtr disp, byte first_keycode, int keycode_count, 
                        out int keysyms_per_keycode_return);
                [DllImport ("libX11")]
-               unsafe static extern byte* XGetModifierMapping (IntPtr disp);
+               static extern IntPtr XGetModifierMapping (IntPtr disp);
                [DllImport ("libX11")]
                static extern uint XKeycodeToKeysym (IntPtr display, int keycode, int index);
                #endregion
@@ -48,7 +48,7 @@ namespace Crow.XLib
 
                public event EventHandler<KeyEventArgs> KeyDown;
                public event EventHandler<KeyEventArgs> KeyUp;
-               public event EventHandler<KeyPressEventArgs> KeyPress;
+               //public event EventHandler<KeyPressEventArgs> KeyPress;
 
                public void HandleEvent (uint keycode, bool pressed) {
                        /*int min_keycode, max_keycode, keysyms_per_keycode;
@@ -103,17 +103,26 @@ namespace Crow.XLib
                                max_keycode + 1 - min_keycode, out keysyms_per_keycode);
                        XFree (ksp);
 
-                       unsafe {
-                               byte* modmap_unmanaged = XGetModifierMapping (xDisp);
-                               int nummodmap = 0;
-                               int* ptr = (int*)modmap_unmanaged;
-                               nummodmap = ptr [0];
+                       IntPtr modmap_unmanaged = XGetModifierMapping (xDisp);
+                       int nummodmap = nummodmap = Marshal.ReadInt32(modmap_unmanaged);
 
-                               for (int i = 0; i< nummodmap; i++) {
-                                       Console.WriteLine(modmap_unmanaged[i+4]);
-                               }
-                               XFree ((IntPtr)modmap_unmanaged);
+                       for (int i = 0; i < nummodmap; i++) {
+                               Console.WriteLine (Marshal.ReadByte(modmap_unmanaged, i + 4));
                        }
+                       XFree (modmap_unmanaged);
+
+
+                       //unsafe {
+                       //      byte* modmap_unmanaged = XGetModifierMapping (xDisp);
+                       //      int nummodmap = 0;
+                       //      int* ptr = (int*)modmap_unmanaged;
+                       //      nummodmap = ptr [0];
+
+                       //      for (int i = 0; i< nummodmap; i++) {
+                       //              Console.WriteLine(modmap_unmanaged[i+4]);
+                       //      }
+                       //      XFree ((IntPtr)modmap_unmanaged);
+                       //}
                }
        }
 }
index a8d62e06c31a2756d24c2d2d907d38b82105791c..544296a39e77754d027848d7ab950df5ca7618ad 100644 (file)
@@ -142,22 +142,24 @@ namespace Crow.XLib
                                        break;
                                case XEventName.MotionNotify:
                                        //Debug.WriteLine ("motion: ({0},{1})", xevent.MotionEvent.x, xevent.MotionEvent.y);
-                                       iFace.ProcessMouseMove (xevent.MotionEvent.x, xevent.MotionEvent.y);
+                                       iFace.OnMouseMove (xevent.MotionEvent.x, xevent.MotionEvent.y);
                                        break;
                                case XEventName.ButtonPress:
                                        //Debug.WriteLine ("button press: {0}", xevent.ButtonEvent.button);
                                        if (xevent.ButtonEvent.button == 4)
-                                               iFace.ProcessMouseWheelChanged (Interface.WheelIncrement);
+                                               iFace.OnMouseWheelChanged (Interface.WheelIncrement);
                                        else if(xevent.ButtonEvent.button == 5)
-                                               iFace.ProcessMouseWheelChanged (-Interface.WheelIncrement);
+                                               iFace.OnMouseWheelChanged (-Interface.WheelIncrement);
                                        else
-                                               iFace.ProcessMouseButtonDown ((MouseButton)(xevent.ButtonEvent.button - 1));
+                                               iFace.OnMouseButtonDown ((MouseButton)(xevent.ButtonEvent.button - 1));
                                        break;
                                case XEventName.ButtonRelease:
                                        //Debug.WriteLine ("button release: {0}", xevent.ButtonEvent.button);
-                                       iFace.ProcessMouseButtonUp ((MouseButton)(xevent.ButtonEvent.button - 1));
+                                       iFace.OnMouseButtonUp ((MouseButton)(xevent.ButtonEvent.button - 1));
+                                       break;
+                               default:
+                                       Console.WriteLine (xevent);
                                        break;
-
                                }
                        }
                }
index 26e7869ca507c84aa8a85a967d9b19e034814b51..d33f244d45ff4263543f4e5ea58ce02d455d35e2 100644 (file)
@@ -21,9 +21,9 @@ namespace Rsvg {
                }
 
                [DllImport("rsvg-2")]
-               static extern unsafe IntPtr rsvg_handle_new_from_data(byte[] data, UIntPtr n_data, out IntPtr error);
+               static extern IntPtr rsvg_handle_new_from_data(byte[] data, UIntPtr n_data, out IntPtr error);
 
-               public unsafe Handle (byte[] data)
+               public Handle (byte[] data)
                {
                        if (GetType () != typeof (Handle)) {
                                throw new InvalidOperationException ("Can't override this constructor.");
@@ -34,9 +34,9 @@ namespace Rsvg {
                }
 
                [DllImport("rsvg-2")]
-               static extern unsafe IntPtr rsvg_handle_new_from_file(string file_name, out IntPtr error);
+               static extern IntPtr rsvg_handle_new_from_file(string file_name, out IntPtr error);
 
-               public unsafe Handle (string file_name)
+               public Handle (string file_name)
                {
                        IntPtr error = IntPtr.Zero;
                        Raw = rsvg_handle_new_from_file(file_name, out error);
@@ -59,9 +59,7 @@ namespace Rsvg {
                static extern void rsvg_handle_render_cairo(IntPtr raw, IntPtr cr);
 
                public void RenderCairo(Context cr) {
-                       unsafe{
-                               rsvg_handle_render_cairo (Raw, cr == null ? IntPtr.Zero : cr.Handle);
-                       }
+                       rsvg_handle_render_cairo (Raw, cr == null ? IntPtr.Zero : cr.Handle);
                }
 
                [DllImport("rsvg-2")]
@@ -86,9 +84,9 @@ namespace Rsvg {
                }
 
                [DllImport("rsvg-2")]
-               static extern unsafe bool rsvg_handle_close(IntPtr raw, out IntPtr error);
+               static extern bool rsvg_handle_close(IntPtr raw, out IntPtr error);
 
-               public unsafe bool Close() {
+               public bool Close() {
                        IntPtr error = IntPtr.Zero;
                        bool raw_ret = rsvg_handle_close(Raw, out error);
                        if (error != IntPtr.Zero) throw new Exception (error.ToString());
index 590ca9c852a4b092c781d66a492dbad671d0beab..beb912d6f1afa9401feb73c4815951713b55e60a 100644 (file)
@@ -1,15 +1,8 @@
 <Project Sdk="Microsoft.NET.Sdk">
-  <Import Project="$(SolutionDir)netfx.props" />
   <PropertyGroup>
     <TargetFramework>net472</TargetFramework>
-    <OutputPath>$(SolutionDir)build\$(Configuration)\</OutputPath>
     <OutputType>Exe</OutputType>        
-    <RepositoryUrl>https://github.com/jpbruyere/Crow</RepositoryUrl>
-    <License>MIT</License>
-    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <EnableDefaultItems>false</EnableDefaultItems>
-    <ReleaseVersion>0.8.0</ReleaseVersion>
-               
     <StartupObject>Crow.Coding.CrowIDE</StartupObject>
   </PropertyGroup>
               
@@ -21,8 +14,8 @@
   <ItemGroup>
     <EmbeddedResource Remove="icons\blank-file2.svg" />
   </ItemGroup>
+       
   <ItemGroup>
-
     <PackageReference Include="System.CodeDom" Version="4.5.0" />
 <!--<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.10.0" />-->
         
index 241e80eeb9dc4f4f956a0c4c901bc0ed0a88b47b..08c274484d7862e6a91794fc75a0a313b83d49a7 100644 (file)
@@ -108,7 +108,7 @@ namespace Crow.Coding
                        }
 
                }
-               public override bool ProcessMouseMove (int x, int y)
+               public override bool OnMouseMove (int x, int y)
                {
                        int deltaX = x - Mouse.X;
                        int deltaY = y - Mouse.Y;
index 291541027e2e64e80b77607b61bdda461f5136c3..d3ba67c5c422c483f569d50bfb6fc01d0fee3061 100644 (file)
@@ -515,8 +515,8 @@ namespace Crow.Coding
                        double z = zoom / 100.0;
                        double coteW = 3, coteL = 5;
                        bool fill = true;
-                       Cairo.PointD p1 = new Cairo.PointD (hr.X + 0.5, hr.Y - space);
-                       Cairo.PointD p2 = new Cairo.PointD (hr.Right - 0.5, hr.Y - space);
+                       PointD p1 = new PointD (hr.X + 0.5, hr.Y - space);
+                       PointD p2 = new PointD (hr.Right - 0.5, hr.Y - space);
 
                        if (p1.Y < cb.Top) {
                                if (hr.Bottom > cb.Bottom - space)
@@ -536,8 +536,8 @@ namespace Crow.Coding
                                drawCenteredTextLine (gr, p1.Add(p2.Substract(p1).Divide (2)), g.Width.Value.ToString());
                        }
 
-                       p1 = new Cairo.PointD (hr.X - space, hr.Top + 0.5);
-                       p2 = new Cairo.PointD (hr.X - space, hr.Bottom - 0.5);
+                       p1 = new PointD (hr.X - space, hr.Top + 0.5);
+                       p2 = new PointD (hr.X - space, hr.Bottom - 0.5);
 
                        if (p1.X < cb.Left) {
                                if (hr.Right > cb.Right - space)
index b12d67c81b178455b343a8f1b2e0efeca23027c1..846f11b80f25d342087f3de6743985e49b4df167 100644 (file)
@@ -56,7 +56,7 @@ namespace Crow.Coding {
             solution = sol;
 
                        ProjectRootElement projectRootElt = ProjectRootElement.Open (solutionProject.AbsolutePath);
-                       project = new Microsoft.Build.Evaluation.Project (projectRootElt, null, "15.0");
+                       project = new Microsoft.Build.Evaluation.Project (projectRootElt, null, "Current");
 
                        cmdSave = new Crow.Command (new Action (() => Save ())) { Caption = "Save", Icon = new SvgPicture ("#CrowIDE.icons.save.svg"), CanExecute = true };
             cmdOpen = new Crow.Command (new Action (() => Load ())) { Caption = "Open", Icon = new SvgPicture ("#CrowIDE.icons.open.svg"), CanExecute = false };
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644 (file)
index 0000000..1f04e9b
--- /dev/null
@@ -0,0 +1,10 @@
+<Project>
+       <PropertyGroup>
+               <RootDirectory>$(MSBuildThisFileDirectory)</RootDirectory>        
+               <OutputPath>$(SolutionDir)build\$(Configuration)\</OutputPath>
+               <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)\</IntermediateOutputPath>
+               <License>MIT</License>
+               <Authors>Jean-Philippe Bruyère</Authors>           
+               <LangVersion>7.2</LangVersion>
+       </PropertyGroup>
+</Project>
diff --git a/Samples/ControlLib/Class1.cs b/Samples/ControlLib/Class1.cs
new file mode 100644 (file)
index 0000000..23bcb16
--- /dev/null
@@ -0,0 +1,8 @@
+using System;
+
+namespace ControlLib
+{
+       public class Class1
+       {
+       }
+}
diff --git a/Samples/ControlLib/ControlLib.csproj b/Samples/ControlLib/ControlLib.csproj
new file mode 100644 (file)
index 0000000..42ac58c
--- /dev/null
@@ -0,0 +1,24 @@
+<Project Sdk="Microsoft.NET.Sdk">  
+  <PropertyGroup>
+    <TargetFrameworks>net471;netstandard2.0</TargetFrameworks>
+    <EnableDefaultNoneItems>false</EnableDefaultNoneItems>     
+    <ReleaseVersion>0.8.0</ReleaseVersion>
+  </PropertyGroup>
+            
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DefineConstants>TRACE;DEBUG;NETFRAMEWORK;NET471</DefineConstants>
+  </PropertyGroup>
+  <ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
+    <Reference Include="System" />
+  </ItemGroup>    
+
+  <ItemGroup>  
+    <ProjectReference Include="..\..\Crow\Crow.csproj" />
+  </ItemGroup>    
+    
+  <ItemGroup>
+    <EmbeddedResource Include="ui\**\*.*">
+      <LogicalName>ControlLib.%(Filename)%(Extension)</LogicalName>
+    </EmbeddedResource>                
+  </ItemGroup>
+</Project>
index 14bb3d73ad02b2af705061f9c2b013040ff03b21..9363d574dfa03526fe18202701d16748b7b6af77 100644 (file)
@@ -1,14 +1,8 @@
-<Project Sdk="Microsoft.NET.Sdk">
-  <Import Project="$(SolutionDir)netfx.props" />
+<Project Sdk="Microsoft.NET.Sdk">  
   <PropertyGroup>
     <TargetFrameworks>net471;netstandard2.0</TargetFrameworks>
-    <OutputPath>$(SolutionDir)build\$(Configuration)\</OutputPath>
     <OutputType>Exe</OutputType>        
-    <RepositoryUrl>https://github.com/jpbruyere/Crow</RepositoryUrl>
-    <License>MIT</License>
-    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <EnableDefaultNoneItems>false</EnableDefaultNoneItems>     
-    <ReleaseVersion>0.8.0</ReleaseVersion>
   </PropertyGroup>
             
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <ProjectReference Include="..\..\Crow\Crow.csproj" />
   </ItemGroup>    
     
-  <ItemGroup>    
-    <Datas Include="..\data\**\*.*">      
-      <Link>data\%(RecursiveDir)%(Filename)%(Extension)</Link>
-    </Datas>
+  <ItemGroup>
     <EmbeddedResource Include="ui\**\*.*">
       <LogicalName>HelloWorld.%(Filename)%(Extension)</LogicalName>
     </EmbeddedResource>                
-  </ItemGroup>     
-  <ItemGroup>
-    <Compile Remove="..\common\CrowWin.cs" />
   </ItemGroup>
 </Project>
index 1d1a35151e112cf41e7efe8fa5f8c5b6e74a8984..d150136e2064a7f0a8535ede48bad60b9b9238fd 100644 (file)
@@ -1,8 +1,9 @@
 <?xml version="1.0"?>
-<Window Caption="Hello World" Icon="#Crow.Icons.crow.svg" Width="40%" Height="40%" CornerRadius="5">
+
     <VerticalStack>
         <Label Text="Hello World" Font="mono, 20"/>
         <Image Path="#Crow.Icons.crow.svg"/>
+        <CheckBox/>
     </VerticalStack>
-</Window>
+
 
index fd711e6d4d3041fa458561365cc504e7aee7cbaa..97dd96901b55c53ec42ab83468784a5644fdce4d 100644 (file)
@@ -1,25 +1,15 @@
 <Project Sdk="Microsoft.NET.Sdk">
-  <Import Project="$(SolutionDir)netfx.props" />
   <PropertyGroup>
-    <TargetFrameworks>net471;netstandard2.0</TargetFrameworks>
-    <OutputPath>$(SolutionDir)build\$(Configuration)\</OutputPath>
+    <TargetFrameworks>net471</TargetFrameworks>
     <OutputType>Exe</OutputType>        
-    <RepositoryUrl>https://github.com/jpbruyere/Crow</RepositoryUrl>
-    <License>MIT</License>
-    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <EnableDefaultNoneItems>false</EnableDefaultNoneItems>    
-    <ReleaseVersion>0.8.0</ReleaseVersion>
   </PropertyGroup>
             
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugType>full</DebugType>
     <DefineConstants>TRACE;DEBUG</DefineConstants>
     <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
-  </PropertyGroup>
-    
-  <ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
-    <Reference Include="System" />
-  </ItemGroup>    
+  </PropertyGroup> 
 
   <ItemGroup>  
     <ProjectReference Include="..\..\Crow\Crow.csproj" />    
@@ -37,7 +27,4 @@
       <Link>Interfaces\%(RecursiveDir)%(Filename)%(Extension)</Link>
     </None>
   </ItemGroup>     
-  <ItemGroup>
-    <Compile Remove="..\common\CrowWin.cs" />
-  </ItemGroup>
 </Project>
index d786e6ae2872c5e66a5806db107e882a7f4e97cf..2548fb64b82a03b1457ccf4da5cb8b65dcb52f76 100755 (executable)
@@ -1,5 +1,2 @@
 <?xml version="1.0"?>
-<VerticalStack Height="Fit" Width="20" Margin="1" Spacing="2" Background="White" >                     
-       <Widget Height="50" Background="Green"/>                                                
-       <Widget Height="50" Background="Red"/>                                          
-</VerticalStack>
+<TestCairoPatch Background="White"/>