aboutsummaryrefslogtreecommitdiffstatsci
path: root/Samples
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2020-02-11 10:49:09 +0100
committerj-p <jp_bruyere@hotmail.com>2020-05-10 00:50:02 +0200
commit701e6c825abbfb431bda3f6692e32a5f12e7307b (patch)
tree6cfc0e63453fd235dfe81967094c3357a692c67b /Samples
parent2774a37e0a20412971e17571e152768b299318db (diff)
wip
Diffstat (limited to 'Samples')
-rw-r--r--Samples/HelloWorld/HelloWorld.csproj6
-rw-r--r--Samples/HelloWorld/ILView.cs15
-rw-r--r--Samples/HelloWorld/main.cs58
-rw-r--r--Samples/HelloWorld/ui/helloworld.crow13
-rw-r--r--Samples/common/ui/Interfaces/Divers/0.crow168
5 files changed, 140 insertions, 120 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
diff --git a/Samples/common/ui/Interfaces/Divers/0.crow b/Samples/common/ui/Interfaces/Divers/0.crow
index d083946c..4b6c50fb 100644
--- a/Samples/common/ui/Interfaces/Divers/0.crow
+++ b/Samples/common/ui/Interfaces/Divers/0.crow
@@ -1,162 +1,108 @@
-<?xml version="1.0"?>
-<Window Caption="Showcase" Height="90%" Width="90%">
- <HorizontalStack >
+<?xml version="1.0" encoding="UTF-8"?>
+<Window Caption="Showcase" Height="90%" Width="90%" Background="Jet">
+ <HorizontalStack>
<VerticalStack Width="30%" Margin="5">
<GroupBox Caption="Performance" Height="Fit">
- <VerticalStack DataSource="{drawingMeasure}" Width="90%" Height="Fit" Spacing="2" >
+ <VerticalStack DataSource="{drawingMeasure}" Width="90%" Height="Fit" Spacing="2">
<HorizontalStack Height="Fit" Tooltip="Frame per second">
- <Label Text="Fps:" Style="FpsLabel"/>
- <Label Text="{minimum}" Style="FpsDisp"/>
+ <Label Style="FpsLabel" Text="Fps:" />
+ <Label Style="FpsDisp" Text="{minimum}" />
</HorizontalStack>
<HorizontalStack Height="Fit" Tooltip="Minimum Frame per second">
- <Label Text="Min:" Style="FpsLabel"/>
- <Label Text="{fpsMin}" Style="FpsDisp"/>
+ <Label Style="FpsLabel" Text="Min:" />
+ <Label Style="FpsDisp" Text="{fpsMin}" />
</HorizontalStack>
<HorizontalStack Height="Fit" Tooltip="Maximum Frame per second">
- <Label Text="Max:" Style="FpsLabel"/>
- <Label Text="{fpsMax}" Style="FpsDisp"/>
+ <Label Style="FpsLabel" Text="Max:" />
+ <Label Style="FpsDisp" Text="{fpsMax}" />
</HorizontalStack>
<HorizontalStack Height="Fit" Tooltip="Update loop duration">
- <Label Text="Update:" Style="FpsLabel"/>
- <Label Text="{update}" Style="FpsDisp"/>
+ <Label Style="FpsLabel" Text="Update:" />
+ <Label Style="FpsDisp" Text="{update}" />
</HorizontalStack>
<HorizontalStack Height="Fit" Tooltip="Layouting process duration">
- <Label Text="Layouting:" Style="FpsLabel"/>
- <Label Text="{layouting}" Style="FpsDisp"/>
+ <Label Style="FpsLabel" Text="Layouting:" />
+ <Label Style="FpsDisp" Text="{layouting}" />
</HorizontalStack>
<HorizontalStack Height="Fit" Tooltip="Clipping duration">
- <Label Text="Clipping:" Style="FpsLabel"/>
- <Label Text="{clipping}" Style="FpsDisp"/>
+ <Label Style="FpsLabel" Text="Clipping:" />
+ <Label Style="FpsDisp" Text="{clipping}" />
</HorizontalStack>
<HorizontalStack Height="Fit">
- <Label Text="Drawing:" Style="FpsLabel"/>
- <Label Text="{drawing}" Style="FpsDisp"/>
+ <Label Style="FpsLabel" Text="Drawing:" />
+ <Label Style="FpsDisp" Text="{drawing}" />
</HorizontalStack>
</VerticalStack>
</GroupBox>
- <Label Width="Stretched" Margin="3" Background="DimGrey"/>
- <TextBox Text="TextBox" Multiline="true" Margin="3"/>
+ <Label Width="Stretched" Margin="3" Background="DimGrey" />
+ <TextBox Text="TextBox" Multiline="true" Margin="3" />
<HorizontalStack Height="Fit" Margin="5" Background="DimGrey" CornerRadius="10">
<VerticalStack Spacing="5" Width="50%">
- <CheckBox Fit="true" Caption="test"/>
- <CheckBox Fit="true"/>
- <CheckBox Fit="true"/>
- <CheckBox Fit="true" IsChecked="true"/>
+ <CheckBox Fit="true" Caption="test" />
+ <CheckBox Fit="true" />
+ <CheckBox Fit="true" />
+ <CheckBox Fit="true" IsChecked="true" />
</VerticalStack>
<VerticalStack Spacing="5" Width="50%">
- <RadioButton Fit="true"/>
- <RadioButton Fit="true" IsChecked="true"/>
- <RadioButton Fit="true"/>
- <RadioButton Fit="true"/>
+ <RadioButton Fit="true" />
+ <RadioButton Fit="true" IsChecked="true" />
+ <RadioButton Fit="true" />
+ <RadioButton Fit="true" />
</VerticalStack>
</HorizontalStack>
<HorizontalStack Height="Fit" Margin="5">
- <Label Text="MouseEvents" Width="50%" Margin="3" Focusable="true"
- Background="Jet"
- Foreground="DimGrey"
- TextAlignment="Center"
- MouseEnter="{Foreground=White}"
- MouseLeave="{Foreground=DimGrey}"
- MouseDown="{Background=DarkRed}"
- MouseClick="{Foreground=Green}"
- MouseDoubleClick="{Foreground=Yellow}"
- MouseUp="{Background=Jet}"/>
- <Label Text="MouseEvents" Width="50%" Margin="3"
- Background="Jet"
- Foreground="DimGrey"
- TextAlignment="Center"
- MouseClick="{Foreground=Green}"
- MouseDoubleClick="{Foreground=Yellow}"
- MouseEnter="{Foreground=White}"
- MouseLeave="{Foreground=DimGrey}"
- MouseDown="{Background=SeaGreen}"
- MouseUp="{Background=DimGrey}"/>
+ <Label Text="MouseEvents" Width="50%" Margin="3" Focusable="true" Background="Jet" Foreground="DimGrey" TextAlignment="Center" MouseEnter="{Foreground=White}" MouseLeave="{Foreground=DimGrey}" MouseDown="{Background=DarkRed}" MouseClick="{Foreground=Green}" MouseDoubleClick="{Foreground=Yellow}" MouseUp="{Background=Jet}" />
+ <Label Text="MouseEvents" Width="50%" Margin="3" Background="Jet" Foreground="DimGrey" TextAlignment="Center" MouseClick="{Foreground=Green}" MouseDoubleClick="{Foreground=Yellow}" MouseEnter="{Foreground=White}" MouseLeave="{Foreground=DimGrey}" MouseDown="{Background=SeaGreen}" MouseUp="{Background=DimGrey}" />
</HorizontalStack>
<GroupBox Caption="Templated controls" Height="Fit" Margin="5">
<HorizontalStack Height="Fit">
<VerticalStack Width="50%">
- <CheckBox IsChecked="true" Style="CheckBox2"/>
- <CheckBox Style="CheckBox2"/>
- <CheckBox Style="CheckBox2"/>
- <CheckBox Style="CheckBox2"/>
+ <CheckBox Style="CheckBox2" IsChecked="true" />
+ <CheckBox Style="CheckBox2" />
+ <CheckBox Style="CheckBox2" />
+ <CheckBox Style="CheckBox2" />
</VerticalStack>
- <Splitter/>
+ <Splitter />
<VerticalStack Width="50%">
- <RadioButton Style="RadioButton2"/>
- <RadioButton Style="RadioButton2"/>
- <RadioButton Style="RadioButton2"/>
- <RadioButton Style="RadioButton2"/>
+ <RadioButton Style="RadioButton2" />
+ <RadioButton Style="RadioButton2" />
+ <RadioButton Style="RadioButton2" />
+ <RadioButton Style="RadioButton2" />
</VerticalStack>
</HorizontalStack>
</GroupBox>
<HorizontalStack Height="Fit">
- <Label Text="Spinner"/>
- <Spinner Fit="true"/>
+ <Label Text="Spinner" />
+ <Spinner Fit="true" />
</HorizontalStack>
<HorizontalStack Height="Fit">
- <Button Caption="Button"/>
- <Button Caption="Button" IsEnabled="false"/>
+ <Button Caption="Button">
+ <Label Font="{./Font}" Name="caption" Margin="3" Foreground="LightGrey" Text="{./Caption}" />
+ </Button>
+ <Button Caption="Button" IsEnabled="false">
+ <Label Font="{./Font}" Name="caption" Margin="3" Foreground="LightGrey" Text="{./Caption}" />
+ </Button>
</HorizontalStack>
</VerticalStack>
- <Splitter/>
+ <Splitter />
<VerticalStack Width="40%" Margin="5" Spacing="5">
<Expandable>
- <Image Path="#Crow.Icons.crow.svg"/>
+ <Image Path="#Crow.Icons.crow.svg" />
</Expandable>
- <Popper>
- <Border Fit="True" Background="DimGrey" CornerRadius="0" BorderWidth="1">
- <Image Path="#Crow.Icons.crow.svg" Width="100" Height="100" Margin="10"
- MouseEnter="{Background=LightGrey}"
- MouseLeave="{Background=Transparent}"/>
- </Border>
- </Popper>
- <Slider Height="10" Width="90%"/>
+ <Popper />
+ <Slider Height="10" Width="90%" />
<Container Height="Fit" Width="200" Background="DimGrey" Margin="2" CornerRadius="5">
- <ProgressBar Background="DimGrey" Height="10" Value="50"/>
+ <ProgressBar Background="DimGrey" Height="10" Value="50" />
</Container>
<Image Path="#Crow.Icons.crow.svg" Width="60" Height="60" Background="LightGrey" />
-<!-- <TabView Name="tabview1"
- Height="120" Orientation="Horizontal" Spacing="15">
- <TabItem Name="TabItem1" Caption="Tab 1" Margin="0">
- <VerticalStack Fit="true">
- <CheckBox/>
- <CheckBox/>
- <CheckBox/>
- <CheckBox/>
- </VerticalStack>
- </TabItem>
- <TabItem Name="TabItem2" Caption="Tab 2" Background="Grey">
- <VerticalStack Fit="true">
- <RadioButton/>
- <RadioButton/>
- <RadioButton/>
- <RadioButton/>
- </VerticalStack>
- </TabItem>
- <TabItem Name="TabItem3" Caption="Tab 3" Background="Grey">
- <Container Margin="5" CornerRadius="2">
- <TextBox Height="Stretched" Margin="5" Multiline="true" TextAlignment="TopLeft"/>
- </Container>
- </TabItem>
- </TabView>-->
- <MessageBox Movable="false"/>
+ <MessageBox Movable="false" />
<ColorPicker CurrentColor="{²../go.Background}" Name="colorPicker" Margin="5" />
- <Widget Name="go" Width="100" Height="60" Background="{../../colorList.SelectedItem}"/>
- <Label Text="{../colorPicker.CurrentColor}"/>
+ <Widget Name="go" Width="100" Height="60" Background="{../../colorList.SelectedItem}" />
+ <Label Text="{../colorPicker.CurrentColor}" />
</VerticalStack>
- <Splitter/>
+ <Splitter />
<VerticalStack Width="30%" Margin="5">
-<!-- <Border Margin="5" Height="Fit">
- <Label Width="Stretched" Margin="1" Text="{../../dv.SelectedItem}"/>
- </Border>
- <Border Margin="5" Height="30%">
- <DirectoryView Name="dv" CurrentDirectory="/" Margin="1"/>
- </Border>
- <Splitter/>-->
- <ListBox Name="colorList" Data="{TestList}" Margin="5"
- ItemTemplate="Interfaces/colorItem.crow"
- Template="#Crow.ScrollingListBox.template"
- />
+ <ListBox Name="colorList" Data="{TestList}" Margin="5" ItemTemplate="Interfaces/colorItem.crow" />
</VerticalStack>
</HorizontalStack>
</Window> \ No newline at end of file