aboutsummaryrefslogtreecommitdiffstatsci
path: root/Samples
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-03-29 12:18:38 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-03-29 12:18:38 +0200
commite5df4ae295d164042a91fb7f75cec4323d88833f (patch)
treed4e802987cc88d581454e7368fe7501fce2df3c9 /Samples
parentf0adbcc9e60ae871d667afb610c7b4718b73f292 (diff)
enumSelector for bitfields, CommandBase abstract class, numericControl onUp/down handler, dock window reload bug
Diffstat (limited to 'Samples')
-rw-r--r--Samples/BasicTests/BasicTests.cs24
-rw-r--r--Samples/ShowCase/ShowCase.cs67
-rw-r--r--Samples/ShowCase/ui/DebugLog.crow5
-rw-r--r--Samples/ShowCase/ui/ShowCase.style3
-rw-r--r--Samples/ShowCase/ui/showcase.crow15
-rw-r--r--Samples/common/SampleBase.cs17
-rw-r--r--Samples/common/ui/Interfaces/Experimental/menu.crow3
-rw-r--r--Samples/common/ui/Interfaces/Experimental/spinner.crow21
-rw-r--r--Samples/common/ui/Interfaces/Experimental/tabviewTest.crow11
9 files changed, 123 insertions, 43 deletions
diff --git a/Samples/BasicTests/BasicTests.cs b/Samples/BasicTests/BasicTests.cs
index dcf38db4..656c05a3 100644
--- a/Samples/BasicTests/BasicTests.cs
+++ b/Samples/BasicTests/BasicTests.cs
@@ -19,10 +19,10 @@ namespace tests
protected override void OnInitialized ()
{
Commands = new List<Crow.Command> (new Crow.Command [] {
- new Crow.Command(new Action(() => command1())) { Caption = "command1"},
- new Crow.Command(new Action(() => command2())) { Caption = "command2"},
- new Crow.Command(new Action(() => command3())) { Caption = "command3"},
- new Crow.Command(new Action(() => command4())) { Caption = "command4"},
+ new Crow.Command("command1", new Action(() => Console.WriteLine ("command1 triggered"))),
+ new Crow.Command("command2", new Action(() => Console.WriteLine ("command2 triggered"))),
+ new Crow.Command("command3", new Action(() => Console.WriteLine ("command3 triggered"))),
+ new Crow.Command("command4", new Action(() => Console.WriteLine ("command4 triggered"))),
});
// += KeyboardKeyDown1;
@@ -103,21 +103,5 @@ namespace tests
void OnLoadList (object sender, MouseButtonEventArgs e) => TestList =
null; //Color.ColorDic.Values.OrderBy (c => c.Hue).ToList ();
- void command1 ()
- {
- Console.WriteLine ("command1 triggered");
- }
- void command2 ()
- {
- Console.WriteLine ("command2 triggered");
- }
- void command3 ()
- {
- Console.WriteLine ("command3 triggered");
- }
- void command4 ()
- {
- Console.WriteLine ("command4 triggered");
- }
}
}
diff --git a/Samples/ShowCase/ShowCase.cs b/Samples/ShowCase/ShowCase.cs
index 0628695f..699e84ff 100644
--- a/Samples/ShowCase/ShowCase.cs
+++ b/Samples/ShowCase/ShowCase.cs
@@ -20,8 +20,9 @@ namespace ShowCase
{
static void Main ()
{
- DbgLogger.IncludeEvents = DbgEvtType.Widget;
- DbgLogger.DiscardEvents = DbgEvtType.Focus | DbgEvtType.IFace;
+ DbgLogger.IncludeEvents = DbgEvtType.None;
+ DbgLogger.DiscardEvents = DbgEvtType.Focus | DbgEvtType.IFace;
+ DbgLogger.ConsoleOutput = false;
Environment.SetEnvironmentVariable ("FONTCONFIG_PATH", @"C:\Users\Jean-Philippe\source\vcpkg\installed\x64-windows\tools\fontconfig\fonts");
@@ -31,6 +32,7 @@ namespace ShowCase
}
}
+
public Container crowContainer;
public string CurrentDir {
@@ -127,15 +129,15 @@ namespace ShowCase
void initCommands ()
{
- CMDNew = new Command (new Action (onNewFile)) { Caption = "New", Icon = "#Icons.blank-file.svg", CanExecute = true };
- CMDSave = new Command (new Action (onSave)) { Caption = "Save", Icon = "#Icons.save.svg", CanExecute = false };
- CMDSaveAs = new Command (new Action (onSaveAs)) { Caption = "Save As...", Icon = "#Icons.save.svg", CanExecute = true };
- CMDQuit = new Command (new Action (() => base.Quit ())) { Caption = "Quit", Icon = "#Icons.exit.svg", CanExecute = true };
- CMDUndo = new Command (new Action (undo)) { Caption = "Undo", Icon = "#Icons.undo.svg", CanExecute = false };
- CMDRedo = new Command (new Action (redo)) { Caption = "Redo", Icon = "#Icons.redo.svg", CanExecute = false };
- CMDCut = new Command (new Action (() => cut ())) { Caption = "Cut", Icon = "#Icons.scissors.svg", CanExecute = false };
- CMDCopy = new Command (new Action (() => copy ())) { Caption = "Copy", Icon = "#Icons.copy-file.svg", CanExecute = false };
- CMDPaste = new Command (new Action (() => paste ())) { Caption = "Paste", Icon = "#Icons.paste-on-document.svg", CanExecute = false };
+ CMDNew = new Command ("New", new Action (onNewFile), "#Icons.blank-file.svg");
+ CMDSave = new Command ("Save", new Action (onSave), "#Icons.save.svg", false);
+ CMDSaveAs = new Command ("Save As...", new Action (onSaveAs), "#Icons.save.svg");
+ CMDQuit = new Command ("Quit", new Action (() => base.Quit ()), "#Icons.exit.svg");
+ CMDUndo = new Command ("Undo", new Action (undo),"#Icons.undo.svg", false);
+ CMDRedo = new Command ("Redo", new Action (redo),"#Icons.redo.svg", false);
+ CMDCut = new Command ("Cut", new Action (() => cut ()), "#Icons.scissors.svg", false);
+ CMDCopy = new Command ("Copy", new Action (() => copy ()), "#Icons.copy-file.svg", false);
+ CMDPaste= new Command ("Paste", new Action (() => paste ()), "#Icons.paste-on-document.svg", false);
}
void onNewFile () {
@@ -345,5 +347,48 @@ namespace ShowCase
reloadChrono.Reset ();
}
+ DbgEvtType recordedEvents, discardedEvents;
+ public DbgEvtType RecordedEvents {
+ get => recordedEvents;
+ set {
+ if (recordedEvents == value)
+ return;
+ recordedEvents = value;
+ NotifyValueChanged(recordedEvents);
+ }
+ }
+ public DbgEvtType DiscardedEvents {
+ get => discardedEvents;
+ set {
+ if (discardedEvents == value)
+ return;
+ discardedEvents = value;
+ NotifyValueChanged(discardedEvents);
+ }
+ }
+
+ public override bool OnKeyDown (Key key) {
+
+ switch (key) {
+ case Key.F5:
+ Load ("#ShowCase.DebugLog.crow").DataSource = this;
+ return true;
+ case Key.F6:
+ if (DbgLogger.IncludeEvents == recordedEvents) {
+ DbgLogger.IncludeEvents = DbgEvtType.None;
+ DbgLogger.DiscardEvents = DbgEvtType.All;
+ } else {
+ DbgLogger.IncludeEvents = recordedEvents;
+ DbgLogger.DiscardEvents = discardedEvents;
+ }
+ return true;
+ case Key.F2:
+ if (IsKeyDown (Key.LeftShift))
+ DbgLogger.Reset ();
+ DbgLogger.Save (this);
+ return true;
+ }
+ return base.OnKeyDown (key);
+ }
}
} \ No newline at end of file
diff --git a/Samples/ShowCase/ui/DebugLog.crow b/Samples/ShowCase/ui/DebugLog.crow
new file mode 100644
index 00000000..db9528b1
--- /dev/null
+++ b/Samples/ShowCase/ui/DebugLog.crow
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<Window Caption="Debug Log" Background="0.1,0.1,0.1,0.8">
+ <ListBox Data="{DebugEvents}">
+ </ListBox>
+</Window> \ No newline at end of file
diff --git a/Samples/ShowCase/ui/ShowCase.style b/Samples/ShowCase/ui/ShowCase.style
index 0d688507..ce7572ab 100644
--- a/Samples/ShowCase/ui/ShowCase.style
+++ b/Samples/ShowCase/ui/ShowCase.style
@@ -1,4 +1,7 @@
IcoButton {
Template = "#ShowCase.Button.template";
Background = "Onyx";
+}
+CheckBox2 {
+ Width = "200";
} \ No newline at end of file
diff --git a/Samples/ShowCase/ui/showcase.crow b/Samples/ShowCase/ui/showcase.crow
index 3d589b3d..c1ecbaac 100644
--- a/Samples/ShowCase/ui/showcase.crow
+++ b/Samples/ShowCase/ui/showcase.crow
@@ -17,11 +17,22 @@
<Button Style="IcoButton" Command="{CMDNew}" />
<Button Style="IcoButton" Command="{CMDSave}" />
<Button Style="IcoButton" Command="{CMDSaveAs}" />
- <Button Style="IcoButton" Command="{CMDUndo}" />
+ <!--<Button Style="IcoButton" Command="{CMDUndo}" />
<Button Style="IcoButton" Command="{CMDRedo}" />
<Button Style="IcoButton" Command="{CMDCut}" />
<Button Style="IcoButton" Command="{CMDCopy}" />
- <Button Style="IcoButton" Command="{CMDPaste}" />
+ <Button Style="IcoButton" Command="{CMDPaste}" />-->
+ <EnumSelector RadioButtonStyle="CheckBox2" Caption="Recorded Events" EnumValue="{²RecordedEvents}">
+ <Template>
+ <Popper Caption="{./Caption}">
+ <Scroller Height="50%" Width="80%" Background="Jet">
+ <Wrapper Name="Content" Height="Fit" VerticalAlignment="Top" />
+ </Scroller>
+ </Popper>
+ </Template>
+ </EnumSelector>
+ <Label Text="{RecordedEvents}"/>
+ <!--<EnumSelector EnumValue="{²DiscardedEvents}"/>-->
<Widget Width="Stretched"/>
<Label Text="Line:" Foreground="Grey"/>
<Label Text="{../../tb.CurrentLine}" Margin="2"/>
diff --git a/Samples/common/SampleBase.cs b/Samples/common/SampleBase.cs
index 71fb65f1..79e018d0 100644
--- a/Samples/common/SampleBase.cs
+++ b/Samples/common/SampleBase.cs
@@ -35,7 +35,10 @@ namespace Crow
public Version CrowVersion => Assembly.GetAssembly (typeof (Widget)).GetName ().Version;
#region Test values for Binding
- public List<Command> Commands;
+ public CommandGroup Commands;
+ public CommandGroup EditCommands = new CommandGroup(
+ new Command("command 1", () => Console.WriteLine("command1 pressed")));
+
public int intValue = 500;
VerticalAlignment currentVAlign;
@@ -262,14 +265,16 @@ namespace Crow
}
}
+
+
#endregion
protected override void OnInitialized () {
- Commands = new List<Command> {
- new Command(() => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 1 clicked")) { Caption = "Action 1" },
- new Command(() => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 2 clicked")) { Caption = "Action 2" },
- new Command(() => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 3 clicked")) { Caption = "Action 3" }
- };
+ Commands = new CommandGroup (
+ new Command("Action 1", () => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 1 clicked")),
+ new Command("Action 2", () => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 2 clicked")),
+ new Command("Action 3", () => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 3 clicked"))
+ );
base.OnInitialized ();
}
diff --git a/Samples/common/ui/Interfaces/Experimental/menu.crow b/Samples/common/ui/Interfaces/Experimental/menu.crow
new file mode 100644
index 00000000..19db1943
--- /dev/null
+++ b/Samples/common/ui/Interfaces/Experimental/menu.crow
@@ -0,0 +1,3 @@
+<Menu>
+ <MenuItem Data="{EditsCommands}"/>
+</Menu> \ No newline at end of file
diff --git a/Samples/common/ui/Interfaces/Experimental/spinner.crow b/Samples/common/ui/Interfaces/Experimental/spinner.crow
new file mode 100644
index 00000000..ac32e78d
--- /dev/null
+++ b/Samples/common/ui/Interfaces/Experimental/spinner.crow
@@ -0,0 +1,21 @@
+<NumericControl Value="50" Height="Fit" Width="200" Background="DarkGrey">
+ <Template>
+ <Border Style="ControlBorder" Background="{./Background}" CornerRadius="{./CornerRadius}" Margin="0">
+ <VerticalStack Spacing="0">
+
+ <HorizontalStack Spacing="5">
+ <Label Text="{./Caption}" Style="ControlCaption" Margin="3"/>
+ <TextBox Style="ControlEditableText" Foreground="{./Foreground}" Font="{./Font}" Width="Stretched" Margin="3"
+ Text="{²./Value}" TextAlignment="Right" Background="Jet" />
+ <VerticalStack Width="16" Height="Stretched" Spacing="1" Margin="2">
+ <Shape KeepProportions="false" Margin="0" 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 F"/>
+ <Shape KeepProportions="false" Margin="0" 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 F"/>
+ </VerticalStack>
+ </HorizontalStack>
+ <Slider Background="Onyx" Foreground="Grey" Height="8" Value="{²./Value}"
+ MouseEnter="{Foreground=${ControlHighlight}}"
+ MouseLeave="{Foreground=Grey}" />
+ </VerticalStack>
+ </Border>
+ </Template>
+</NumericControl> \ No newline at end of file
diff --git a/Samples/common/ui/Interfaces/Experimental/tabviewTest.crow b/Samples/common/ui/Interfaces/Experimental/tabviewTest.crow
index f874a2c6..b876ab7f 100644
--- a/Samples/common/ui/Interfaces/Experimental/tabviewTest.crow
+++ b/Samples/common/ui/Interfaces/Experimental/tabviewTest.crow
@@ -7,8 +7,9 @@
<HorizontalStack Name="ItemsContainer" Background="{./Background}"/>
</Template>
<ItemTemplate>
- <ListItem Width="Fit" Background="Transparent" IsSelected="{IsVisible}"
- Selected="{.DataSource.Visible='true'};{Background=CornflowerBlue}"
+ <ListItem Width="Fit" Background="Transparent" IsSelected="{²IsVisible}"
+ Tooltip="{GetType}"
+ Selected="{DataSource.Visible='true'};{Background=CornflowerBlue}"
Unselected="{.DataSource.Visible='false'};{Background=Transparent}">
<Label Text="{Caption}" Margin="5" />
</ListItem>
@@ -17,8 +18,10 @@
<Group Name="ItemsContainer"/>
</VerticalStack>
</Template>
- <GroupBox Caption="item 1" IsVisible="false" Background="CornflowerBlue"/>
- <GroupBox Caption="item 2" IsVisible="true" Background="CornflowerBlue"/>
+ <GroupBox Caption="item 1" IsVisible="true" Background="CornflowerBlue">
+ <Label Text="{Caption}"/>
+ </GroupBox>
+ <GroupBox Caption="item 2" IsVisible="false" Background="CornflowerBlue"/>
<GroupBox Caption="item 3" IsVisible="false" Background="CornflowerBlue"/>
</ListBox>
<Label DataSource="{../lb.SelectedItem}" Text="{Caption}"/>