diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2020-02-11 10:49:09 +0100 |
|---|---|---|
| committer | j-p <jp_bruyere@hotmail.com> | 2020-05-10 00:50:02 +0200 |
| commit | 701e6c825abbfb431bda3f6692e32a5f12e7307b (patch) | |
| tree | 6cfc0e63453fd235dfe81967094c3357a692c67b /Samples/HelloWorld | |
| parent | 2774a37e0a20412971e17571e152768b299318db (diff) | |
wip
Diffstat (limited to 'Samples/HelloWorld')
| -rw-r--r-- | Samples/HelloWorld/HelloWorld.csproj | 6 | ||||
| -rw-r--r-- | Samples/HelloWorld/ILView.cs | 15 | ||||
| -rw-r--r-- | Samples/HelloWorld/main.cs | 58 | ||||
| -rw-r--r-- | Samples/HelloWorld/ui/helloworld.crow | 13 |
4 files changed, 83 insertions, 9 deletions
diff --git a/Samples/HelloWorld/HelloWorld.csproj b/Samples/HelloWorld/HelloWorld.csproj index 448fb435..908af2fc 100644 --- a/Samples/HelloWorld/HelloWorld.csproj +++ b/Samples/HelloWorld/HelloWorld.csproj @@ -7,7 +7,8 @@ </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DefineConstants>TRACE;DEBUG;NETFRAMEWORK;NET471</DefineConstants> + <DebugType>full</DebugType> + <DefineConstants>TRACE;DEBUG</DefineConstants> </PropertyGroup> <ItemGroup Condition="$(TargetFramework.StartsWith('net4'))"> <Reference Include="System" /> @@ -22,4 +23,7 @@ <LogicalName>HelloWorld.%(Filename)%(Extension)</LogicalName> </EmbeddedResource> </ItemGroup> + <ItemGroup> + <PackageReference Include="Mono.Cecil" Version="0.11.1" /> + </ItemGroup> </Project> diff --git a/Samples/HelloWorld/ILView.cs b/Samples/HelloWorld/ILView.cs new file mode 100644 index 00000000..9bac2299 --- /dev/null +++ b/Samples/HelloWorld/ILView.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2020 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 Crow; + +namespace HelloWorld +{ + public class ILView : Widget + { + public ILView () + { + } + } +} diff --git a/Samples/HelloWorld/main.cs b/Samples/HelloWorld/main.cs index 14a1a2ad..c407b04e 100644 --- a/Samples/HelloWorld/main.cs +++ b/Samples/HelloWorld/main.cs @@ -1,5 +1,9 @@ using System; +using System.Linq; +using System.Reflection; +using System.Reflection.Emit; using Crow; +using Crow.IML; namespace HelloWorld { @@ -10,6 +14,7 @@ namespace HelloWorld vke.Run (); } } + protected override void Startup () { CMDQuit = new Command (new Action (() => running = false)) { Caption = "Quit", Icon = new SvgPicture ("#Crow.Icons.exit-symbol.svg") }; @@ -19,6 +24,17 @@ namespace HelloWorld w.DataSource = this; } + public SolidColor testColor = Color.Red; + public SolidColor TestColor { + get => testColor; + set { + if (testColor == value) + return; + testColor = value; + NotifyValueChanged ("TestColor", testColor); + } + } + Color [] colors = { Color.Blue, Color.DarkGoldenRod, Color.Red, Color.Azure, Color.Brown, Color.Black, Color.White, Color.Pink }; int ptr = 0; @@ -37,6 +53,48 @@ namespace HelloWorld if (ptr == colors.Length) ptr = 0; } + public override bool OnKeyDown (Key key) + { + switch (key) { + case Key.d: + dump (); + break; + case Key.space: + TestColor = Color.Green; + break; + default: + return base.OnKeyDown (key); + } + return true; + } + + void dump () + { + Instantiator inst = Instantiators ["#HelloWorld.helloworld.crow"]; + + foreach (Delegate cd in inst.CachedDelegates) { + FieldInfo mb = typeof(Delegate).GetField("original_method_info", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField); + + DynamicMethod dynMethod = mb.GetValue (cd) as DynamicMethod; + /*Console.WriteLine (typeof (ILGenerator).GetFields (BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField)); + + var ilgen = dynMethod.GetILGenerator (); + + + +*/ + + MethodBody body = dynMethod.GetMethodBody (); + + byte [] il = body.GetILAsByteArray (); + foreach (byte b in il) { + Console.Write ($"{b:x2} "); + //Console.WriteLine (b); + } + + } + + } } } diff --git a/Samples/HelloWorld/ui/helloworld.crow b/Samples/HelloWorld/ui/helloworld.crow index d150136e..1bc9601f 100644 --- a/Samples/HelloWorld/ui/helloworld.crow +++ b/Samples/HelloWorld/ui/helloworld.crow @@ -1,9 +1,6 @@ <?xml version="1.0"?> - - <VerticalStack> - <Label Text="Hello World" Font="mono, 20"/> - <Image Path="#Crow.Icons.crow.svg"/> - <CheckBox/> - </VerticalStack> - - +<VerticalStack> + <TextBox Text="{TestColor}"/> + <ColorPicker CurrentColor="{²TestColor}" /> +</VerticalStack> +<!--<ScrollBar Orientation="Vertical" Height="Stretched" Width="10" />-->
\ No newline at end of file |