ControlBackground = "Transparent";
+ControlForeground = "Grey";
+ControlHighlight = "RoyalBlue";
ControlBorderColor = "DimGrey";
ControlBorderWidth = "1";
-ControlCaptionColor = "LightGrey";
ControlCaptionHoverColor = "White";
ControlCornerRadius = "0";
ControlInsideMargin = "1";
-ControlHighlight = "RoyalBlue";
+
IconSize = "11";
IconMargin = "1";
ToggleIconSize = "16";
Margin = "${ControlInsideMargin}";
}
ControlCaption {
- Foreground = "${ControlCaptionColor}";
+ Foreground = "${ControlForeground}";
MouseEnter = "{Foreground=${ControlCaptionHoverColor}}";
- MouseLeave = "{Foreground=${ControlCaptionColor}}";
+ MouseLeave = "{Foreground=${ControlForeground}}";
}
ControlEditableText {
- Foreground = "${ControlCaptionColor}";
+ Foreground = "${ControlForeground}";
Background = "Transparent";
MinimumSize = "40,10";
Margin = "1";
Width = "Stretched";
Height = "Fit";
Background = "${MenuBackground}";
- Foreground = "${ControlCaptionColor}";
+ Foreground = "${ControlForeground}";
MouseEnter = "{Background=${ControlHighlight}}";
MouseLeave = "{Background=${MenuBackground}}";
//SelectionBackground = "${ControlHighlight}";
}
ArrowBut {
- MouseRepeat="true";
- //Focusable="true";
+ MouseRepeat="true";
Foreground="Grey";
Background="Transparent";
-
- //MouseUp="{Background=Transparent}";
- //MouseDown="{Background=Grey}";
-
- MouseEnter="{Foreground=CornflowerBlue}";
+
+ MouseEnter="{Foreground=${ControlHighlight}}";
MouseLeave="{Foreground=Grey}";
Margin="2";
--- /dev/null
+<?xml version="1.0"?>
+<Border Style="ControlBorder" Background="{./Background}" CornerRadius="{./CornerRadius}">
+ <HorizontalStack Spacing="1">
+ <TextBox Style="ControlEditableText" Foreground="{./Foreground}" Font="{./Font}" Width="Stretched"
+ Text="{²./Value}" TextAlignment="Right" />
+ <VerticalStack Width="16" Height="Stretched" Spacing="0" Margin="0">
+ <Shape KeepProportions="false" Margin="1" 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="1" 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>
+</Border>
\ No newline at end of file
<?xml version="1.0"?>
<VerticalStack Spacing="0" >
- <ListBox Data="{./Items}" Fit="true" HorizontalAlignment="Left" VerticalAlignment="Top">
+ <ListBox Data="{./Items}" Fit="true" HorizontalAlignment="Left" VerticalAlignment="Top" SelectedItem="{²./SelectedItem}">
<Template>
<HorizontalStack Name="ItemsContainer" Background="{./Background}" />
</Template>
</ListItem>
</ItemTemplate>
</ListBox>
- <Group Name="ItemsContainer" Background="Grey" Margin="10"/>
+ <Group Name="ItemsContainer" Background="Grey"/>
</VerticalStack>
-// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+using System.Runtime.InteropServices.ComTypes;
+// Copyright (c) 2013-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 System.ComponentModel;
using System.Threading.Tasks;
+using System.Collections;
namespace Crow {
- public class CommandGroup : ObservableList<Command>, IValueChange
- {
- string caption;
- string icon;
+ public abstract class CommandBase : IValueChange {
+ #region IValueChange implementation
+ public event EventHandler<ValueChangeEventArgs> ValueChanged;
+ public virtual void NotifyValueChanged(string MemberName, object _value)
+ {
+ ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
+ }
+ #endregion
+
+ #region CTOR
+ protected CommandBase() {}
+ protected CommandBase (string _caption, string _icon)
+ {
+ caption = _caption;
+ icon = _icon;
+ }
+ #endregion
+
+ string caption, icon;
/// <summary>
/// label to display in the bound control
/// </summary>
- [DefaultValue ("Unamed Command Group")]
+ [DefaultValue("Unamed Command")]
public virtual string Caption {
- get { return caption; }
+ get => caption;
set {
if (caption == value)
return;
/// Icon to display in the bound control
/// </summary>
public string Icon {
- get { return icon; }
+ get => icon;
set {
if (icon == value)
return;
NotifyValueChanged ("Icon", icon);
}
}
+ internal virtual void raiseAllValuesChanged() {
+ NotifyValueChanged ("Icon", icon);
+ NotifyValueChanged ("Caption", caption);
+ }
+ }
+ public class CommandGroup : CommandBase, IEnumerable
+ {
+ public ObservableList<CommandBase> Commands = new ObservableList<CommandBase>();
public CommandGroup () { }
- public CommandGroup (params Command[] commands) {
- AddRange (commands);
+ public CommandGroup (string caption, string icon, params CommandBase[] commands) :
+ base (caption, icon) {
+ Commands.AddRange (commands);
}
+ public CommandGroup (params CommandBase[] commands) {
+ Commands.AddRange (commands);
+ }
+
+ public IEnumerator GetEnumerator() => Commands.GetEnumerator ();
}
/// <summary>
/// helper class to bind in one step icon, caption, action, and validity tests to a controls
/// </summary>
- public class Command : IValueChange
+ public class Command : CommandBase
{
- #region IValueChange implementation
- public event EventHandler<ValueChangeEventArgs> ValueChanged;
- public virtual void NotifyValueChanged(string MemberName, object _value)
- {
- ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value));
- }
- #endregion
#region CTOR
public Command () {}
{
execute = _executeAction;
}
+ public Command (string caption, Action executeAction, string icon = null, bool _canExecute = true)
+ :base (caption, icon)
+ {
+ execute = executeAction;
+ canExecute = _canExecute;
+ }
+
#endregion
- Action execute;
-
- string caption;
- string icon;
+ Action execute;
bool canExecute = true;
-
- #region Public properties
+
/// <summary>
/// if true, action defined in this command may be executed,
/// </summary>
canExecute = value;
NotifyValueChanged ("CanExecute", canExecute);
}
- }
-
- /// <summary>
- /// label to display in the bound control
- /// </summary>
- [DefaultValue("Unamed Command")]
- public virtual string Caption {
- get { return caption; }
- set {
- if (caption == value)
- return;
- caption = value;
- NotifyValueChanged ("Caption", caption);
-
- }
- }
- /// <summary>
- /// Icon to display in the bound control
- /// </summary>
- public string Icon {
- get { return icon; }
- set {
- if (icon == value)
- return;
- icon = value;
- NotifyValueChanged ("Icon", icon);
- }
- }
- #endregion
+ }
/// <summary>
/// trigger the execution of the command
/// </summary>
- public void Execute(){
+ public virtual void Execute(){
if (execute != null && CanExecute){
Task task = new Task(execute);
task.Start();
}
}
- internal void raiseAllValuesChanged(){
+ internal override void raiseAllValuesChanged()
+ {
+ base.raiseAllValuesChanged();
NotifyValueChanged ("CanExecute", CanExecute);
- NotifyValueChanged ("Icon", icon);
- NotifyValueChanged ("Caption", caption);
}
-
}
}
[DefaultValue (null)]
public virtual Command Command {
- get { return command; }
+ get => command;
set {
if (command == value)
return;
[DefaultValue ("#Crow.Icons.crow.svg")]
public string Icon {
- get { return Command == null ? icon : Command.Icon; ; }
+ get => Command == null ? icon : Command.Icon;
set {
if (icon == value)
return;
}
}
public override bool IsEnabled {
- get { return Command == null ? base.IsEnabled : Command.CanExecute; }
- set { base.IsEnabled = value; }
+ get => Command == null ? base.IsEnabled : Command.CanExecute;
+ set => base.IsEnabled = value;
}
public override string Caption {
- get { return Command == null ? base.Caption : Command.Caption; }
- set { base.Caption = value; }
+ get => Command == null ? base.Caption : Command.Caption;
+ set => base.Caption = value;
}
[DefaultValue (false)]
public bool IsPressed
{
- get { return isPressed; }
+ get => isPressed;
set
{
if (isPressed == value)
[DefaultValue(false)]
public bool IsChecked
{
- get { return isChecked; }
+ get => isChecked;
set
{
if (isChecked == value)
dw.DockingPosition = FastEnum.Parse<Alignment> (getConfAttrib (conf, ref i));
dw.savedSlot = Rectangle.Parse (getConfAttrib (conf, ref i));
dw.wasResizable = Boolean.Parse (getConfAttrib (conf, ref i));
+ dw.Resizable = false;
dw.IsDocked = true;
dw.DataSource = dataSource;
-// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
-// Copyright (c) 2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com
+using System.Linq;
+using System.Xml.Linq;
+// Copyright (c) 2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
#region private fields
Enum enumValue;
Type enumType;
- string rbStyle, iconsPrefix, iconsExtension;
- IML.Instantiator radioButtonITor;
+ bool enumTypeIsBitsfield;
+ string rbStyle, iconsPrefix, iconsExtension;
#endregion
#region public properties
set {
if (rbStyle == value)
return;
- rbStyle = value;
- radioButtonITor = null;
+ rbStyle = value;
forceRefresh ();
NotifyValueChangedAuto (rbStyle);
}
/// </summary>
[DefaultValue(null)]
public virtual Enum EnumValue {
- get { return enumValue; }
+ get => enumValue;
set {
if (enumValue == value)
return;
- enumValue = value;
- if (radioButtonITor == null)
- radioButtonITor = IFace.CreateITorFromIMLFragment ($"<RadioButton Style='{rbStyle}'/>");
+ enumValue = value;
if (enumValue != null) {
+
if (enumType != enumValue.GetType ()) {
enumValueContainer.ClearChildren ();
- enumType = enumValue.GetType ();
- foreach (string en in enumType.GetEnumNames ()) {
-
- RadioButton rb = radioButtonITor.CreateInstance<RadioButton> ();
- rb.Caption = en;
- rb.LogicalParent = this;
- rb.Tag = $"{iconsPrefix}{en}{IconsExtension}";
- if (enumValue.ToString () == en)
- rb.IsChecked = true;
- rb.Checked += (sender, e) => (((RadioButton)sender).LogicalParent as EnumSelector).EnumValue = (Enum)Enum.Parse (enumType, (sender as RadioButton).Caption);
- enumValueContainer.AddChild (rb);
+ enumType = enumValue.GetType ();
+
+ enumTypeIsBitsfield = enumType.CustomAttributes.Any (ca => ca.AttributeType == typeof(FlagsAttribute));
+
+ if (enumTypeIsBitsfield) {
+ IML.Instantiator iTor = IFace.CreateITorFromIMLFragment ($"<CheckBox Style='{rbStyle}'/>");
+ UInt32 currentValue = Convert.ToUInt32 (EnumValue);
+
+ foreach (Enum en in enumType.GetEnumValues()) {
+ CheckBox rb = iTor.CreateInstance<CheckBox> ();
+ rb.Caption = en.ToString();
+ rb.LogicalParent = this;
+ rb.Tag = $"{iconsPrefix}{en}{IconsExtension}";
+
+ UInt32 eni = Convert.ToUInt32 (en);
+ rb.Tooltip = $"0x{eni:x8}";
+ if (eni == 0) {
+ rb.IsChecked = currentValue == 0;
+ rb.Checked += (sender, e) => EnumValue = (Enum)Enum.ToObject(enumType, 0);
+ } else {
+ rb.IsChecked = currentValue == 0 ? false : EnumValue.HasFlag (en);
+ rb.Checked += onChecked;
+ rb.Unchecked += onUnchecked;
+ }
+ /*rb.Checked += (sender, e) => (((CheckBox)sender).LogicalParent as EnumSelector).EnumValue = (Enum)(object)
+ (Convert.ToUInt32 ((((CheckBox)sender).LogicalParent as EnumSelector).EnumValue) | Convert.ToUInt32 (en));
+ rb.Unchecked += (sender, e) => (((CheckBox)sender).LogicalParent as EnumSelector).EnumValue = (Enum)(object)
+ (Convert.ToUInt32 ((((CheckBox)sender).LogicalParent as EnumSelector).EnumValue) & ~Convert.ToUInt32 (en)); */
+
+ enumValueContainer.AddChild (rb);
+ }
+
+ } else {
+ IML.Instantiator iTor = IFace.CreateITorFromIMLFragment ($"<RadioButton Style='{rbStyle}'/>");
+ foreach (var en in enumType.GetEnumValues ()) {
+ RadioButton rb = iTor.CreateInstance<RadioButton> ();
+ rb.Caption = en.ToString();
+ rb.LogicalParent = this;
+ rb.Tag = $"{iconsPrefix}{en}{IconsExtension}";
+ if (enumValue == en)
+ rb.IsChecked = true;
+ rb.Checked += (sender, e) => (((RadioButton)sender).LogicalParent as EnumSelector).EnumValue = (Enum)en;
+ enumValueContainer.AddChild (rb);
+ }
}
+
+
+ } else if (enumTypeIsBitsfield) {
+ UInt32 currentValue = Convert.ToUInt32 (EnumValue);
+ if (currentValue == 0) {
+ foreach (CheckBox rb in enumValueContainer.Children) {
+ Enum en = (Enum)Enum.Parse(enumType, rb.Caption);
+ UInt32 eni = Convert.ToUInt32 (en);
+ if (eni == 0)
+ rb.IsChecked = true;
+ else
+ rb.IsChecked = false;
+ }
+ } else {
+ foreach (CheckBox rb in enumValueContainer.Children) {
+ Enum en = (Enum)Enum.Parse(enumType, rb.Caption);
+ UInt32 eni = Convert.ToUInt32 (en);
+ if (eni == 0)
+ rb.IsChecked = false;
+ else
+ rb.IsChecked = EnumValue.HasFlag (en);
+ }
+ }
} else {
foreach (RadioButton rb in enumValueContainer.Children) {
if (rb.Caption == enumValue.ToString ())
rb.IsChecked = true;
- else if (rb.IsChecked)
+ else
rb.IsChecked = false;
}
}
}
#endregion
+ void onChecked (object sender, EventArgs e) {
+ Enum en =(Enum)Enum.Parse (enumType, (sender as CheckBox).Caption);
+ UInt32 newVal = Convert.ToUInt32 (en);
+ if (newVal == 0)
+ EnumValue = (Enum)Enum.ToObject(enumType, 0);
+ else
+ EnumValue = (Enum)Enum.ToObject(enumType, newVal | Convert.ToUInt32 (EnumValue));
+ }
+ void onUnchecked (object sender, EventArgs e) {
+ Enum en =(Enum)Enum.Parse (enumType, (sender as CheckBox).Caption);
+ EnumValue = (Enum)Enum.ToObject(enumType, Convert.ToUInt32 (EnumValue) & ~Convert.ToUInt32 (en));
+ }
+
//force refresh to use new template if values are already displayed
void forceRefresh ()
{
public virtual void onExpand(object sender, EventArgs e)
{
if (_contentContainer != null)
- _contentContainer.Visible = true;
+ _contentContainer.IsVisible = true;
Expand.Raise (this, e);
}
public virtual void onCollapse(object sender, EventArgs e)
{
if (_contentContainer != null)
- _contentContainer.Visible = false;
+ _contentContainer.IsVisible = false;
Collapse.Raise (this, e);
}
layoutType &= (~LayoutingType.Y);
}
public override int measureRawSize (LayoutingType lt) {
- int totSpace = Math.Max (0, Spacing * (Children.Count (c => c.Visible) - 1));
+ int totSpace = Math.Max (0, Spacing * (Children.Count (c => c.IsVisible) - 1));
if (lt == LayoutingType.Width) {
if (Orientation == Orientation.Horizontal)
return contentSize.Width + totSpace + 2 * Margin;
int d = 0;
if (Orientation == Orientation.Horizontal) {
foreach (Widget c in Children) {
- if (!c.Visible)
+ if (!c.IsVisible)
continue;
c.Slot.X = d;
d += c.Slot.Width + Spacing;
}
} else {
foreach (Widget c in Children) {
- if (!c.Visible)
+ if (!c.IsVisible)
continue;
c.Slot.Y = d;
d += c.Slot.Height + Spacing;
}
public override bool IsEnabled {
- get { return Command == null ? base.IsEnabled : Command.CanExecute; }
- set { base.IsEnabled = value; }
+ get => Command == null ? base.IsEnabled : Command.CanExecute;
+ set => base.IsEnabled = value;
}
public override string Caption {
- get { return Command == null ? base.Caption : Command.Caption; }
- set { base.Caption = value; }
+ get => Command == null ? base.Caption : Command.Caption;
+ set => base.Caption = value;
}
public string Icon {
- get { return Command == null ? icon : Command.Icon;; }
+ get => Command == null ? icon : Command.Icon;
set {
if (icon == value)
return;
}
[DefaultValue("Fit")]
public virtual Measure PopWidth {
- get { return popWidth; }
+ get => popWidth;
set {
if (popWidth == value)
return;
}
[DefaultValue("Fit")]
public virtual Measure PopHeight {
- get { return popHeight; }
+ get => popHeight;
set {
if (popHeight == value)
return;
protected virtual void onOpen (object sender, EventArgs e){
Open.Raise (this, null);
}
- protected virtual void onClose (object sender, EventArgs e){
- System.Diagnostics.Debug.WriteLine ("close: " + this.ToString());
+ protected virtual void onClose (object sender, EventArgs e){
Close.Raise (this, null);
}
public override bool MouseIsIn (Point m)
[DefaultValue(2)]
public int Decimals
{
- get { return decimals; }
+ get => decimals;
set
{
if (value == decimals)
}
[DefaultValue(0.0)]
public virtual double Minimum {
- get { return minValue; }
+ get => minValue;
set {
if (minValue == value)
return;
[DefaultValue(100.0)]
public virtual double Maximum
{
- get { return maxValue; }
+ get => maxValue;
set {
if (maxValue == value)
return;
[DefaultValue(1.0)]
public virtual double SmallIncrement
{
- get { return smallStep; }
+ get => smallStep;
set {
if (smallStep == value)
return;
[DefaultValue(5.0)]
public virtual double LargeIncrement
{
- get { return bigStep; }
+ get => bigStep;
set {
if (bigStep == value)
return;
[DefaultValue(0.0)]
public virtual double Value
{
- get { return actualValue; }
+ get => actualValue;
set
{
if (value == actualValue)
protected virtual void registerUpdate ()
=> RegisterForRedraw ();
+
+ protected virtual void onUp (object sender, MouseButtonEventArgs e)
+ {
+ if (IFace.Ctrl)
+ Value += SmallIncrement;
+ else
+ Value += LargeIncrement;
+ }
+ protected virtual void onDown (object sender, MouseButtonEventArgs e)
+ {
+ if (IFace.Ctrl)
+ Value -= SmallIncrement;
+ else
+ Value -= LargeIncrement;
+ }
}
}
}
protected virtual void HandleCursorContainerLayoutChanged (object sender, LayoutingEventArgs e)
- {
+ {
computeCursorPosition ();
}
#endregion
}
void computeCursorPosition ()
{
- if (cursor == null)
+ if (cursor?.Parent == null)
return;
if (Maximum <= Minimum) {
- cursor.Visible = false;
+ cursor.IsVisible = false;
return;
}
- cursor.Visible = true;
+ cursor.IsVisible = true;
Rectangle r = cursor.Parent.ClientRectangle;
if (_orientation == Orientation.Horizontal) {
unity = (r.Width - cursorSize) / (Maximum - Minimum);
protected Spinner() {}
public Spinner (Interface iface, string style = null) : base (iface, style) { }
#endregion
-
- public override void onMouseClick (object sender, MouseButtonEventArgs e)
- {
- e.Handled = true;
- base.onMouseClick (sender, e);
- }
- void onUp (object sender, MouseButtonEventArgs e)
- {
- if (IFace.Ctrl)
- Value += SmallIncrement;
- else
- Value += LargeIncrement;
- }
- void onDown (object sender, MouseButtonEventArgs e)
- {
- if (IFace.Ctrl)
- Value -= SmallIncrement;
- else
- Value -= LargeIncrement;
- }
-
}
}
//void expandable_expandevent (object sender, EventHandler )
void Li_Selected (object sender, EventArgs e)
{
+ if (sender == selectedItemContainer)
+ return;
if (selectedItemContainer is ISelectable li)
li.IsSelected = false;
selectedItemContainer = sender as Widget;
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;
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");
- }
}
}
{
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");
}
}
+
public Container crowContainer;
public string CurrentDir {
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 () {
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
--- /dev/null
+<?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
IcoButton {
Template = "#ShowCase.Button.template";
Background = "Onyx";
+}
+CheckBox2 {
+ Width = "200";
}
\ No newline at end of file
<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"/>
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;
}
}
+
+
#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 ();
}
--- /dev/null
+<Menu>
+ <MenuItem Data="{EditsCommands}"/>
+</Menu>
\ No newline at end of file
--- /dev/null
+<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
<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>
<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}"/>