<?xml version="1.0"?>
<Popper Caption="{./SelectedItem}" Name="popper" PopDirection="Bottom" Foreground="{./Foreground}" Background="{./Background}">
<Template>
- <CheckBox Caption="{./Caption}" IsChecked="{²./IsPopped}" Foreground="{./Foreground}" Background="{./Background}">
- <Template>
- <Border Style="ControlBorder" >
- <HorizontalStack Margin="0" Spacing="1">
- <TextBox Style="ControlEditableText" Text="{./Caption}"/>
- <Shape Style="ArrowBut" MouseDown="./onScrollForth" Width="10" Height="Stretched"
- Size="10,10" Path="M 0.5,0.5 L 9.5,0.5 L 4.5,9.5 Z F"/>
- </HorizontalStack>
- </Border>
- </Template>
- </CheckBox>
+ <Border Style="ControlBorder" Background="{./Background}">
+ <HorizontalStack Margin="0" Spacing="1">
+ <TextBox Style="ControlEditableText" Text="{./Caption}"/>
+ <Shape Style="ArrowBut" MouseDown="./onScrollForth" Width="10" Height="Stretched"
+ Size="10,10" Path="M 0.5,0.5 L 9.5,0.5 L 4.5,9.5 Z F"/>
+ </HorizontalStack>
+ </Border>
</Template>
- <Border Background="Onyx" Foreground="DimGrey" BorderWidth="1" Margin="1" Height="Fit" Width="1"
+ <Border Background="Onyx" Foreground="DimGrey" BorderWidth="1" Margin="1" Fit="true"
MinimumSize="{../../MinimumPopupSize}" >
<Scroller Name="scroller1" Margin="1"
MaximumSize="0,200"
<?xml version="1.0"?>
-<CheckBox Caption="{./Caption}" IsChecked="{²./IsPopped}" Foreground="{./Foreground}" Background="{./Background}">
- <Template>
- <Border Style="ControlBorder" Background="{./Background}" CornerRadius="{./CornerRadius}">
- <HorizontalStack Spacing="1">
- <Image Style="Icon"
- MouseEnter="{Background=White}" MouseLeave="{Background=Transparent}"
- Background="{./Background}"
- Path="#Crow.Icons.expandable.svg" SvgSub="{./IsChecked}"/>
- <Label Style="ControlCaption" Text="{./Caption}" />
- </HorizontalStack>
- </Border>
- </Template>
-</CheckBox>
+<Border Style="ControlBorder" Background="{./Background}" CornerRadius="{./CornerRadius}">
+ <HorizontalStack Spacing="1">
+ <Image Style="Icon"
+ MouseEnter="{Background=White}" MouseLeave="{Background=Transparent}"
+ Path="#Crow.Icons.expandable.svg" SvgSub="{./IsPopped}"/>
+ <Label Style="ControlCaption" Text="{./Caption}" Foreground="{./Foreground}"/>
+ </HorizontalStack>
+</Border>
+++ /dev/null
-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;
-using System.Collections.Generic;
-
-namespace Crow {
- 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 = null)
- {
- caption = _caption;
- icon = _icon;
- }
- #endregion
-
- string caption, icon;
-
- /// <summary>
- /// label to display in the bound control
- /// </summary>
- [DefaultValue("Unamed Command")]
- public virtual string Caption {
- get => caption;
- set {
- if (caption == value)
- return;
- caption = value;
- NotifyValueChanged ("Caption", caption);
-
- }
- }
- /// <summary>
- /// Icon to display in the bound control
- /// </summary>
- public string Icon {
- get => icon;
- set {
- if (icon == value)
- return;
- icon = value;
- NotifyValueChanged ("Icon", icon);
- }
- }
- internal virtual void raiseAllValuesChanged() {
- NotifyValueChanged ("Icon", icon);
- NotifyValueChanged ("Caption", caption);
- }
- }
- public class CommandGroup : CommandBase, IEnumerable, IList<CommandBase>
- {
- public ObservableList<CommandBase> Commands = new ObservableList<CommandBase>();
-
- public CommandGroup () { }
- public CommandGroup (string caption, string icon, params CommandBase[] commands) :
- base (caption, icon) {
- Commands.AddRange (commands);
- }
- public CommandGroup (string caption, params CommandBase[] commands) :
- base (caption) {
- Commands.AddRange (commands);
- }
- public CommandGroup (params CommandBase[] commands) {
- Commands.AddRange (commands);
- }
-
-
- public int Count => Commands.Count;
-
- public bool IsReadOnly => false;
-
- public CommandBase this[int index] { get => Commands[index]; set => Commands[index] = value; }
-
- public IEnumerator GetEnumerator() => Commands.GetEnumerator ();
-
- public int IndexOf(CommandBase item) => Commands.IndexOf (item);
-
- public void Insert(int index, CommandBase item) => Commands.Insert(index, item);
-
- public void RemoveAt(int index) => Commands.RemoveAt(index);
-
- public void Add(CommandBase item) => Commands.Add (item);
-
- public void Clear() => Commands.Clear();
-
- public bool Contains(CommandBase item) => Commands.Contains (item);
-
- public void CopyTo(CommandBase[] array, int arrayIndex) => Commands.CopyTo (array, arrayIndex);
-
- public bool Remove(CommandBase item) {
- Commands.Remove (item);
- return true;
- }
-
- IEnumerator<CommandBase> IEnumerable<CommandBase>.GetEnumerator()
- => Commands.GetEnumerator();
- }
-
-
- /// <summary>
- /// helper class to bind in one step icon, caption, action, and validity tests to a controls
- /// </summary>
- public class Command : CommandBase
- {
-
- #region CTOR
- public Command () {}
- /// <summary>
- /// Initializes a new instance of Command with the action passed as argument.
- /// </summary>
- /// <param name="_executeAction">action to excecute when command is triggered</param>
- public Command (Action _executeAction) {
- execute = _executeAction;
- }
- /// <summary>
- /// Initializes a new instance of Command with the action<object> passed as argument.
- /// </summary>
- /// <param name="_executeAction">action to excecute when command is triggered</param>
- public Command (Action<object> _executeAction) {
- execute = _executeAction;
- }
- public Command (string caption, Action executeAction, string icon = null, bool _canExecute = true)
- :base (caption, icon)
- {
- execute = executeAction;
- canExecute = _canExecute;
- }
- public Command (string caption, Action<object> executeAction, string icon = null, bool _canExecute = true)
- :base (caption, icon)
- {
- execute = executeAction;
- canExecute = _canExecute;
- }
-
- #endregion
-
- Delegate execute;
-
- bool canExecute = true;
-
- /// <summary>
- /// if true, action defined in this command may be executed,
- /// </summary>
- [DefaultValue(true)]
- public virtual bool CanExecute {
- get => canExecute;
- set {
- if (canExecute == value)
- return;
- canExecute = value;
- NotifyValueChanged ("CanExecute", canExecute);
- }
- }
-
- /// <summary>
- /// trigger the execution of the command
- /// </summary>
- public virtual void Execute (object sender = null){
- if (execute != null && CanExecute){
- Task task = (execute is Action a) ?
- task = new Task(a) :
- (execute is Action<object> o) ?
- task = new Task(o, sender) : throw new Exception("Invalid Delegate type in Crow.Command, expecting Action or Action<object>");
- task.Start();
- }
- }
-
- internal override void raiseAllValuesChanged()
- {
- base.raiseAllValuesChanged();
- NotifyValueChanged ("CanExecute", CanExecute);
- }
- }
-}
--- /dev/null
+// 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)
+
+using System;
+using System.ComponentModel;
+using System.Threading.Tasks;
+
+namespace Crow {
+ /// <summary>
+ /// helper class to bind in one step icon, caption, action, and validity tests to a controls
+ /// </summary>
+ public class Command : CommandBase
+ {
+
+ #region CTOR
+ public Command () {}
+ /// <summary>
+ /// Initializes a new instance of Command with the action passed as argument.
+ /// </summary>
+ /// <param name="_executeAction">action to excecute when command is triggered</param>
+ public Command (Action _executeAction) {
+ execute = _executeAction;
+ }
+ /// <summary>
+ /// Initializes a new instance of Command with the action<object> passed as argument.
+ /// </summary>
+ /// <param name="_executeAction">action to excecute when command is triggered</param>
+ public Command (Action<object> _executeAction) {
+ execute = _executeAction;
+ }
+ public Command (string caption, Action executeAction, string icon = null, bool _canExecute = true)
+ :base (caption, icon)
+ {
+ execute = executeAction;
+ canExecute = _canExecute;
+ }
+ public Command (string caption, Action<object> executeAction, string icon = null, bool _canExecute = true)
+ :base (caption, icon)
+ {
+ execute = executeAction;
+ canExecute = _canExecute;
+ }
+
+ #endregion
+
+ Delegate execute;
+
+ bool canExecute = true;
+
+ /// <summary>
+ /// if true, action defined in this command may be executed,
+ /// </summary>
+ [DefaultValue(true)]
+ public virtual bool CanExecute {
+ get => canExecute;
+ set {
+ if (canExecute == value)
+ return;
+ canExecute = value;
+ NotifyValueChanged ("CanExecute", canExecute);
+ }
+ }
+
+ /// <summary>
+ /// trigger the execution of the command
+ /// </summary>
+ public virtual void Execute (object sender = null){
+ if (execute != null && CanExecute){
+ Task task = (execute is Action a) ?
+ task = new Task(a) :
+ (execute is Action<object> o) ?
+ task = new Task(o, sender) : throw new Exception("Invalid Delegate type in Crow.Command, expecting Action or Action<object>");
+ task.Start();
+ }
+ }
+
+ internal override void raiseAllValuesChanged()
+ {
+ base.raiseAllValuesChanged();
+ NotifyValueChanged ("CanExecute", CanExecute);
+ }
+ }
+}
--- /dev/null
+// 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)
+
+using System;
+using System.ComponentModel;
+
+namespace Crow {
+ /// <summary>
+ /// Base class for Command and CommandGroup.
+ /// </summary>
+ 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 = null)
+ {
+ caption = _caption;
+ icon = _icon;
+ }
+ #endregion
+
+ string caption, icon;
+
+ /// <summary>
+ /// label to display in the bound control
+ /// </summary>
+ [DefaultValue("Unamed Command")]
+ public virtual string Caption {
+ get => caption;
+ set {
+ if (caption == value)
+ return;
+ caption = value;
+ NotifyValueChanged ("Caption", caption);
+
+ }
+ }
+ /// <summary>
+ /// Icon to display in the bound control
+ /// </summary>
+ public string Icon {
+ get => icon;
+ set {
+ if (icon == value)
+ return;
+ icon = value;
+ NotifyValueChanged ("Icon", icon);
+ }
+ }
+ internal virtual void raiseAllValuesChanged() {
+ NotifyValueChanged ("Icon", icon);
+ NotifyValueChanged ("Caption", caption);
+ }
+ }
+}
--- /dev/null
+// 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)
+
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Crow {
+ public class CommandGroup : CommandBase, IEnumerable, IList<CommandBase>
+ {
+ public List<CommandBase> Commands = new List<CommandBase>();
+
+ public CommandGroup () { }
+ public CommandGroup (string caption, string icon, params CommandBase[] commands) :
+ base (caption, icon) {
+ Commands.AddRange (commands);
+ }
+ public CommandGroup (string caption, params CommandBase[] commands) :
+ base (caption) {
+ Commands.AddRange (commands);
+ }
+ public CommandGroup (params CommandBase[] commands) {
+ Commands.AddRange (commands);
+ }
+
+
+ public int Count => Commands.Count;
+
+ public bool IsReadOnly => false;
+
+ public CommandBase this[int index] { get => Commands[index]; set => Commands[index] = value; }
+
+ public IEnumerator GetEnumerator() => Commands.GetEnumerator ();
+
+ public int IndexOf(CommandBase item) => Commands.IndexOf (item);
+
+ public void Insert(int index, CommandBase item) => Commands.Insert(index, item);
+
+ public void RemoveAt(int index) => Commands.RemoveAt(index);
+
+ public void Add(CommandBase item) => Commands.Add (item);
+
+ public void Clear() => Commands.Clear();
+
+ public bool Contains(CommandBase item) => Commands.Contains (item);
+
+ public void CopyTo(CommandBase[] array, int arrayIndex) => Commands.CopyTo (array, arrayIndex);
+
+ public bool Remove(CommandBase item) {
+ Commands.Remove (item);
+ return true;
+ }
+
+ IEnumerator<CommandBase> IEnumerable<CommandBase>.GetEnumerator()
+ => Commands.GetEnumerator();
+ }
+}
/// <summary>
/// Source of the expand/collapse event
/// </summary>
- public Expandable SourceWidget;
- public TreeExpandEventArg (Expandable sourceWidget)
- {
+ public IToggle SourceWidget;
+ public TreeExpandEventArg (IToggle sourceWidget) {
}
}
--- /dev/null
+// Copyright (c) 2020-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+using System;
+
+namespace Crow
+{
+ public interface IToggle
+ {
+ event EventHandler ToggleOn;
+ event EventHandler ToggleOff;
+ BooleanTestOnInstance IsToggleable { get; set; }
+
+ bool IsToggled {
+ get;
+ set;
+ }
+
+ }
+}
public override void onMouseClick (object sender, MouseButtonEventArgs e)
{
IsChecked = !IsChecked;
+ e.Handled = true;
base.onMouseClick (sender, e);
}
}
/// <summary>
/// templated control whose content can be hidden and shown on demand
/// </summary>
- public class Expandable : TemplatedContainer
- {
+ public class Expandable : TemplatedContainer, IToggle
+ {
#region CTOR
protected Expandable() : base(){}
public Expandable (Interface iface) : base(iface){}
public event EventHandler Collapse;
#endregion
+ #region IToggle implementation
+ public event EventHandler ToggleOn;
+ public event EventHandler ToggleOff;
+ public BooleanTestOnInstance IsToggleable { get; set; }
+ public bool IsToggled {
+ get => _isExpanded;
+ set {
+ if (value == _isExpanded)
+ return;
+ IsExpanded = value;
+ }
+ }
+ #endregion
+
public BooleanTestOnInstance GetIsExpandable;
/// <summary>
}
}
[DefaultValue(false)]
- public bool IsExpanded
- {
+ public bool IsExpanded
+ {
get { return _isExpanded; }
- set
- {
+ set
+ {
if (value == _isExpanded)
return;
bool isExp = IsExpandable;
NotifyValueChanged ("IsExpandable", isExp);
if (!isExp)
- _isExpanded = false;
+ _isExpanded = false;
NotifyValueChangedAuto (_isExpanded);
+ NotifyValueChanged ("IsToggled",_isExpanded);
if (_isExpanded)
onExpand (this, null);
else
onCollapse (this, null);
- }
- }
+ }
+ }
[XmlIgnore]public bool IsExpandable {
get {
try {
}
}
}
+
#endregion
public virtual void onExpand(object sender, EventArgs e)
_contentContainer.IsVisible = true;
Expand.Raise (this, e);
+ ToggleOn.Raise (this, null);
}
public virtual void onCollapse(object sender, EventArgs e)
{
_contentContainer.IsVisible = false;
Collapse.Raise (this, e);
+ ToggleOff.Raise (this, null);
}
}
}
return tmp;
}
- public override Widget FindByType<T> ()
+ public override T FindByType<T> ()
{
- if (this is T)
- return this;
- Widget tmp = null;
+ if (this is T t)
+ return t;
+ T tmp = default(T);
childrenRWLock.EnterReadLock ();
namespace Crow
{
- public class Popper : TemplatedContainer
+ public class Popper : TemplatedContainer, IToggle
{
#region CTOR
protected Popper () {}
_content.HorizontalAlignment = HorizontalAlignment.Left;
_content.VerticalAlignment = VerticalAlignment.Top;
_content.LayoutChanged += _content_LayoutChanged;
+ _content.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
}
}
void positionContent(LayoutingType lt){
public virtual void onPop(object sender, EventArgs e)
{
- if (Content != null) {
- Content.IsVisible = true;
+ if (Content != null) {
if (Content.Parent == null)
IFace.AddWidget (Content);
+ Content.IsVisible = true;
//if (Content.LogicalParent != this)
Content.LogicalParent = this;
IFace.PutOnTop (Content, true);
- _content_LayoutChanged (this, new LayoutingEventArgs (LayoutingType.Sizing));
+ //_content_LayoutChanged (this, new LayoutingEventArgs (LayoutingType.Sizing));
}
Popped.Raise (this, e);
+ ToggleOn.Raise (this, null);
}
public virtual void onUnpop(object sender, EventArgs e)
{
- if (Content != null) {
- Content.IsVisible = false;
- }
+ if (Content != null)
+ Content.IsVisible = false;
Unpoped.Raise (this, e);
+ ToggleOff.Raise (this, null);
}
protected override void Dispose (bool disposing)
}
base.Dispose (disposing);
}
+ public override void onMouseClick (object sender, MouseButtonEventArgs e)
+ {
+ IsPopped = !IsPopped;
+ base.onMouseClick (sender, e);
+ }
+ #region IToggle implementation
+ public event EventHandler ToggleOn;
+ public event EventHandler ToggleOff;
+ public BooleanTestOnInstance IsToggleable { get; set; }
+ public bool IsToggled {
+ get => _isPopped;
+ set {
+ if (value == _isPopped)
+ return;
+ IsPopped = value;
+ }
+ }
+ #endregion
}
}
return child == null ? null : child.FindByName (nameToFind);
}
- public override Widget FindByType<T> ()
+ public override T FindByType<T> ()
{
- if (this is T)
- return this;
+ if (this is T t)
+ return t;
- return child == null ? null : child.FindByType<T> ();
+ return child == null ? default(T) : child.FindByType<T> ();
}
public override bool Contains (Widget goToFind)
{
return Content == null ? null : Content.FindByName (nameToFind);
}
- public override Widget FindByType<T> ()
+ public override T FindByType<T> ()
{
- if (this is T)
- return this;
+ if (this is T t)
+ return t;
- return Content == null ? null : Content.FindByType<T> ();
+ return Content == null ? default(T) : Content.FindByType<T> ();
}
public override bool Contains (Widget goToFind)
{
/// <returns>widget identified by name, or null if not found</returns>
/// <param name="nameToFind">widget's name to find</param>
public override Widget FindByName (string nameToFind) => nameToFind == this.Name ? this : null;
- public override Widget FindByType<T> () => this is TemplatedControl ? this : null;
+ //public override T FindByType<T> () => this is TemplatedControl tg ? tg : default (T);
public Widget FindByNameInTemplate (string nameToFind) => child?.FindByName (nameToFind);
/// <summary>
///onDraw is overrided to prevent default drawing of background, template top container
}
return null;
}
- public override Widget FindByType<T> ()
+ public override T FindByType<T> ()
{
- if (this is T)
- return this;
+ if (this is T t)
+ return t;
foreach (Widget w in Items) {
- Widget r = w.FindByType<T> ();
+ T r = w.FindByType<T> ();
if (r != null)
return r;
}
- return null;
+ return default(T);
}
public override bool Contains (Widget goToFind)
{
try {
loadPage (data, itemsContainer, dataTest);
} catch (Exception ex) {
- if (Monitor.IsEntered (IFace.LayoutMutex))
- Monitor.Exit (IFace.LayoutMutex);
+ while (Monitor.IsEntered (IFace.UpdateMutex))
+ Monitor.Exit (IFace.UpdateMutex);
+ while (Monitor.IsEntered (IFace.LayoutMutex))
+ Monitor.Exit (IFace.LayoutMutex);
System.Diagnostics.Debug.WriteLine ("loading thread aborted: " + ex.ToString());
}
Monitor.Exit (IFace.UpdateMutex);
if (iTemp.Expand != null) {
- Expandable e = g as Expandable;
- if (e == null)
- e = g.FindByType<Expandable> () as Expandable;
+ IToggle toggle = g as IToggle;
+
+ if (toggle == null)
+ toggle = g.FindByType<IToggle> ();
- if (e != null) {
- e.Expand += iTemp.Expand;
- if ((o as ICollection) == null)
- e.GetIsExpandable = new BooleanTestOnInstance ((instance) => true);
+ if (toggle != null) {
+ toggle.ToggleOn += iTemp.Expand;
+ if (o is ICollection)
+ toggle.IsToggleable = iTemp.HasSubItems;
else
- e.GetIsExpandable = iTemp.HasSubItems;
+ toggle.IsToggleable = new BooleanTestOnInstance ((instance) => true);
}
}
base.Dispose (disposing);
}
- public override void OnDataSourceChanged (object sender, DataSourceChangeEventArgs e)
- {
- base.OnDataSourceChanged (sender, e);
- }
-
public void OnInsertClick (object sender, MouseEventArgs e)
{
if (data is IObservableList)
}
- void onExpandAll_MouseClick (object sender, MouseButtonEventArgs e)
+ /*void onExpandAll_MouseClick (object sender, MouseButtonEventArgs e)
{
ExpandAll ();
}
public void ExpandAll(){
foreach (Group grp in itemsContainer.Children) {
foreach (Widget go in grp.Children) {
- Expandable exp = go as Expandable;
- if (exp == null)
- continue;
- TreeView subTV = exp.FindByName ("List") as TreeView;
- if (subTV == null)
- continue;
- EventHandler handler = null;
- handler = delegate(object sender, EventArgs e) {
- TreeView tv = sender as TreeView;
- tv.Loaded -= handler;
- tv.ExpandAll ();
- };
- subTV.Loaded += handler;
- exp.IsExpanded = true;
+ if (go is IToggle exp) {
+ TreeView subTV = exp.FindByName ("List") as TreeView;
+ if (subTV == null)
+ continue;
+ EventHandler handler = null;
+ handler = delegate(object sender, EventArgs e) {
+ TreeView tv = sender as TreeView;
+ tv.Loaded -= handler;
+ tv.ExpandAll ();
+ };
+ subTV.Loaded += handler;
+ exp.IsToggled = true;
+ }
}
}
- }
+ }*/
}
}
loadDefaultValues ();
}
#region private fields
- LayoutingType registeredLayoutings;// = LayoutingType.All;
+ LayoutingType registeredLayoutings;// = LayoutingType.Sizing;
ILayoutable logicalParent;
ILayoutable parent;
string name;
}
#endregion
- public virtual Widget FindByName(string nameToFind){
- return string.Equals(nameToFind, name, StringComparison.Ordinal) ? this : null;
- }
- public virtual Widget FindByType<T> ()
- {
- return this is T ? this : null;
- }
+ public virtual Widget FindByName(string nameToFind)
+ => string.Equals(nameToFind, name, StringComparison.Ordinal) ? this : null;
+ public virtual T FindByType<T> () //where T : Widget
+ => this is T t? t : default(T);
public virtual bool Contains(Widget goToFind){
return false;
}
+++ /dev/null
-<?xml version="1.0"?>
-<HorizontalStack Spacing="5" Background="{./Background}">
- <Label Text="{./Caption}"/>
- <Popper Caption="{./SelectedItem}" Name="popper" PopDirection="Bottom" Foreground="{./Foreground}" Background="{./Background}">
- <Template>
- <CheckBox Caption="{./Caption}" IsChecked="{²./IsPopped}" Foreground="{./Foreground}" Background="{./Background}">
- <Template>
- <Border Style="ControlBorder" Background="{./Background}">
- <HorizontalStack Margin="0" Spacing="1">
- <TextBox Style="ControlEditableText" Text="{./Caption}"/>
- <Shape Style="ArrowBut" MouseDown="./onScrollForth" Width="10" Height="Stretched"
- Size="10,10" Path="M 0.5,0.5 L 9.5,0.5 L 4.5,9.5 Z F"/>
- </HorizontalStack>
- </Border>
- </Template>
- </CheckBox>
- </Template>
- <Border Background="Onyx" Foreground="DimGrey" BorderWidth="1" Margin="1" Height="Fit" Width="Fit"
- MinimumSize="{../../MinimumPopupSize}" >
- <Scroller Name="scroller1" Margin="1"
- MaximumSize="0,200"
- HorizontalAlignment="Left">
- <VerticalStack
- Height="Fit" Name="ItemsContainer" Margin="0"
- HorizontalAlignment="Left"
- VerticalAlignment="Top"/>
- </Scroller>
- </Border>
- </Popper>
-</HorizontalStack>
<?xml version="1.0"?>
<Popper >
<Template>
- <CheckBox IsChecked="{²./IsPopped}">
- <Template>
- <HorizontalStack Background="{../../../Background}" Margin="5" Spacing="10">
- <Label Text="{../../../../Caption}" Width="Stretched"/>
- <Label Background="SeaGreen" Text="{../../../../EnumValue}" Margin="3"/>
- </HorizontalStack>
- </Template>
- </CheckBox>
+ <HorizontalStack Background="{../../Background}" Margin="5" Spacing="10">
+ <Label Text="{../../../Caption}" Width="Stretched"/>
+ <Label Background="SeaGreen" Text="{../../../EnumValue}" Margin="3"/>
+ </HorizontalStack>
</Template>
<Wrapper Name="Content" Height="Fit" Width="{../PopWidth}" Background="Jet" />
</Popper>
\ No newline at end of file
Height="Fit";
Width="150";
}
-ComboBox {
- Template="#Dbg.ComboBox.template";
- Background="Jet";
-}
labWidgetRecordList {
Font="mono, 11";
Background="Grey";
#region Test values for Binding
public CommandGroup Commands, AllCommands;
public CommandGroup EditCommands = new CommandGroup("Edit Commands",
- new Command("Edit command 1", () => Console.WriteLine("edit command1 pressed")),
- new Command("Edit command 2", () => Console.WriteLine("edit command2 pressed")),
- new Command("Edit command 3", () => Console.WriteLine("edit command3 pressed"))
+ new Command("Edit command 1", (sender) => MessageBox.ShowModal((sender as Widget).IFace, MessageBox.Type.Information, "Edit comand 1 clicked")),
+ new Command("Edit command 2 a bit longer", (sender) => MessageBox.ShowModal((sender as Widget).IFace, MessageBox.Type.Information, "Edit comand 2 clicked"), null, false),
+ new Command("Edit command three", (sender) => MessageBox.ShowModal((sender as Widget).IFace, MessageBox.Type.Information, "Edit comand 3 clicked"))
);
public CommandGroup FileCommands = new CommandGroup("File Commands",
- new Command("File command 1", () => Console.WriteLine("File command1 pressed")),
- new Command("File command 2", () => Console.WriteLine("File command2 pressed")),
- new Command("File command 3", () => Console.WriteLine("File command3 pressed"))
+ new Command("File command 1", (sender) => MessageBox.ShowModal((sender as Widget).IFace, MessageBox.Type.Information, "File comand 1 clicked")),
+ new Command("File command 2 a bit longer", (sender) => MessageBox.ShowModal((sender as Widget).IFace, MessageBox.Type.Information, "File comand 2 clicked")),
+ new Command("File command three", (sender) => MessageBox.ShowModal((sender as Widget).IFace, MessageBox.Type.Information, "File comand 3 clicked"))
);
void initCommands()
{
Commands = new CommandGroup("commands msg boxes",
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"))
+ new Command("Action two", () => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 2 clicked"), null, false),
+ new Command("Action three", () => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 3 clicked"))
);
AllCommands = new CommandGroup ("All Commands",
- EditCommands,
FileCommands,
+ EditCommands,
+ new CommandGroup ("Combined commands", FileCommands, EditCommands),
new Command("Action A", () => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu A clicked"))
);
}
-<ListBox Data="{TestList}" >
+<ListBox Data="{TestList}" >
<Template>
- <Table Name="ItemsContainer" Columns="name,Stretched;color,100"/>
+ <Scroller>
+ <Table Name="ItemsContainer" Columns="name,Fit;color,100" Height="Fit" Width="Stretched" VerticalAlignment="Top"/>
+ </Scroller>
</Template>
<ItemTemplate>
<TableRow>
--- /dev/null
+<Popper Width="Fit">
+ <Template>
+ <Label Text="{./Caption}"/>
+ </Template>
+ <VerticalStack Width="Fit" Height="Fit" Background="Grey">
+ <Label Width="Stretched"/>
+ <Label Text="mljdqslfkj" Width="Stretched"/>
+ <Label Width="Stretched"/>
+ <Label Text="mljdqslfkjqsdfhjsdqfkljhsdqfkljhs" Width="Stretched"/>
+ </VerticalStack>
+</Popper>
\ No newline at end of file
<NumericControl Value="50" Height="Fit" Width="200" Background="DarkGrey">
<Template>
- <Border Style="ControlBorder" Background="{./Background}" CornerRadius="{./CornerRadius}" Margin="0">
+ <Border Style="ControlBorder" Background="{./Background}" CornerRadius="{./CornerRadius}" Margin="1">
<VerticalStack Spacing="0">
<HorizontalStack Spacing="5">
<MenuItem Caption="File" Fit="true">
<MenuItem Caption="New">
<Template>
-<Popper Font="{./Font}" Caption="{./Caption}" Background="{./Background}" PopDirection="{./PopDirection}"
- Foreground = "{./Foreground}" CanPop="{./HasChildren}"
- IsPopped="{²./IsOpened}" PopWidth="{./PopWidth}" PopHeight="{./PopHeight}">
- <Template>
- <CheckBox IsChecked="{²./IsPopped}" Caption="{./Caption}" Background="{./Background}" Foreground="{./Foreground}">
- <Template>
- <Border Name="border1"
- MinimumSize = "60,0"
- Foreground="Transparent"
- Background="{./Background}">
- <Label Text="{./Caption}"
- Foreground="{./Foreground}"
- Margin="2" HorizontalAlignment="Left"
- Font="{./Font}" />
- </Border>
- </Template>
- </CheckBox>
- </Template>
- <Border Foreground="DimGrey" Width="{../PopWidth}" Height="{../PopHeight}" Background="${MenuBackground}">
- <VerticalStack Name="ItemsContainer"/>
- </Border>
-</Popper>
+ <Popper Font="{./Font}" Caption="{./Caption}" Background="{./Background}" PopDirection="{./PopDirection}"
+ Foreground = "{./Foreground}" CanPop="{./HasChildren}"
+ IsPopped="{²./IsOpened}" PopWidth="{./PopWidth}" PopHeight="{./PopHeight}">
+ <Template>
+ <Border Name="border1"
+ MinimumSize = "60,0"
+ Foreground="Transparent"
+ Background="{./Background}">
+ <Label Text="{./Caption}"
+ Foreground="{./Foreground}"
+ Margin="2" HorizontalAlignment="Left"
+ Font="{./Font}" />
+ </Border>
+ </Template>
+ <Border Foreground="DimGrey" Width="{../PopWidth}" Height="{../PopHeight}" Background="${MenuBackground}">
+ <VerticalStack Name="ItemsContainer"/>
+ </Border>
+ </Popper>
</Template>
</MenuItem>
</MenuItem>
-<Menu Data="{Commands}">
- <ItemTemplate>
-<MenuItem Command="{}" Width="150" PopWidth="120" IsEnabled="{CanExecute}">
+<?xml version="1.0"?>
+<Menu Data="{AllCommands}">
+ <ItemTemplate DataType="Crow.Command">
+ <Button Command="{}">
<Template>
- <Popper Font="{./Font}" Caption="{./Caption}" Background="{./Background}" PopDirection="{./PopDirection}"
- Foreground = "{./Foreground}" CanPop="{./HasChildren}" MouseDown="./onMI_Click"
- IsPopped="{²./IsOpened}" PopWidth="{./PopWidth}" PopHeight="{./PopHeight}">
+ <Label Text="{./Caption}" Width="Stretched" Height="Stretched" Margin="3"
+ MouseEnter="{Background=${ControlHighlight}}"
+ MouseLeave="{Background=Transparent}"/>
+ </Template>
+ </Button>
+ </ItemTemplate>
+ <ItemTemplate DataType="Crow.CommandGroup" >
+ <MenuItem Data="{Commands}" Width="Fit" IsEnabled="{CanExecute}">
+ <Template>
+ <Popper PopDirection="Bottom" Caption="{Caption}"
+ MouseEnter="{Background=${ControlHighlight}}"
+ MouseLeave="{Background=Transparent}">
<Template>
- <Border Name="border1"
- CornerRadius="0"
- MouseEnter="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black}"
- MouseLeave="{Foreground=Transparent}"
- MouseDown="{Foreground=vgradient|0:Black|0.05:Grey|0.85:Grey|1:White}"
- MouseUp="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black}"
- MinimumSize = "60,0"
- Foreground="Transparent"
- Background="{./Background}">
- <Label Text="{./Caption}"
- Foreground="{./Foreground}"
- Margin="1" HorizontalAlignment="Left"
- Font="{./Font}" />
- </Border>
+ <Label Text="{./Caption}" Width="Stretched" Height="Fit" Margin="3"
+ Background="{./Background}"/>
</Template>
- <Border Foreground="DimGrey" Width="{../PopWidth}" Height="{../PopHeight}" Background="DimGrey">
- <VerticalStack Name="ItemsContainer"/>
- </Border>
+ <VerticalStack Name="ItemsContainer" Fit="true" Background="Jet"/>
</Popper>
</Template>
+ <ItemTemplate DataType="Crow.Command">
+ <Label Text="{Caption}" HorizontalAlignment="Left" Width="Stretched" Height="Fit" Margin="0"
+ MouseEnter="{Background=${ControlHighlight}}"
+ MouseLeave="{Background=Transparent}"/>
+ </ItemTemplate>
+ <ItemTemplate DataType="Crow.CommandGroup" >
+ <MenuItem Data="{Commands}" Width="Stretched" IsEnabled="{CanExecute}">
+ <Template>
+ <Popper PopDirection="Right" Caption="{Caption}"
+ MouseEnter="{Background=${ControlHighlight}}"
+ MouseLeave="{Background=Transparent}">
+ <Template>
+ <Label Text="{./Caption}" Width="Stretched" Height="Stretched" Margin="3"
+ Background="{./Background}"/>
+ </Template>
+ <Border Foreground="DimGrey" Width="{../PopWidth}" Height="{../PopHeight}" Background="DarkGrey">
+ <VerticalStack Name="ItemsContainer"/>
+ </Border>
+ </Popper>
+ </Template>
+ <ItemTemplate DataType="Crow.Command">
+ <Button Command="{}" Width="Stretched">
+ <Template>
+ <Label Text="{./Caption}" Width="Stretched" Height="Stretched" Margin="3"
+ MouseEnter="{Background=${ControlHighlight}}"
+ MouseLeave="{Background=Transparent}"/>
+ </Template>
+ </Button>
+ </ItemTemplate>
+ </MenuItem>
+ </ItemTemplate>
</MenuItem>
</ItemTemplate>
</Menu>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<Menu Data="{AllCommands}">
+ <ItemTemplate DataType="CommandGroup" >
+ <MenuItem Data="{Commands}" Width="Fit" IsEnabled="{CanExecute}">
+ <Template>
+ <Popper PopDirection="Bottom" Caption="{Caption}"
+ PopWidth="{./PopWidth}" PopHeight="{./PopHeight}"
+ MouseEnter="{Background=${ControlHighlight}}"
+ MouseLeave="{Background=Transparent}">
+ <Template>
+ <Label Text="{./Caption}" Width="Stretched" Height="Stretched" Margin="3"
+ Background="{./Background}"/>
+ </Template>
+ <VerticalStack Name="ItemsContainer" Fit="true" Background="DarkGrey"/>
+ </Popper>
+ </Template>
+ <ItemTemplate DataType="Command" >
+ <Button Command="{}" Width="Stretched">
+ <Template>
+ <HorizontalStack Margin="3" HorizontalAlignment="Left"
+ MouseEnter="{Background=${ControlHighlight}}"
+ MouseLeave="{Background=Transparent}">
+ <Image Width="10" Height="10" Margin="1" Path="{./Icon}" />
+ <Label Text="{./Caption}" />
+ </HorizontalStack>
+ </Template>
+ </Button>
+ </ItemTemplate>
+ <ItemTemplate DataType="CommandGroup" >
+ <MenuItem Data="{Commands}" Width="Stretched" IsEnabled="{CanExecute}">
+ <Template>
+ <Popper PopDirection="Right" Caption="{Caption}"
+ PopWidth="{./PopWidth}" PopHeight="{./PopHeight}"
+ MouseEnter="{Background=${ControlHighlight}}"
+ MouseLeave="{Background=Transparent}">
+ <Template>
+ <Label Text="{./Caption}" Width="Stretched" Height="Stretched" Margin="3"
+ Background="{./Background}"/>
+ </Template>
+ <VerticalStack Name="ItemsContainer" Fit="true" Background="DarkGrey"/>
+ </Popper>
+ </Template>
+ <ItemTemplate DataType="Command">
+ <Button Command="{}" Width="Stretched">
+ <Template>
+ <HorizontalStack Margin="3" HorizontalAlignment="Left"
+ MouseEnter="{Background=${ControlHighlight}}"
+ MouseLeave="{Background=Transparent}">
+ <Image Width="10" Height="10" Margin="1" Path="{./Icon}" />
+ <Label Text="{./Caption}" />
+ </HorizontalStack>
+ </Template>
+ </Button>
+ </ItemTemplate>
+ </MenuItem>
+ </ItemTemplate>
+ </MenuItem>
+ </ItemTemplate>
+</Menu>
\ No newline at end of file
<?xml version="1.0"?>
<Popper Margin="0" Caption="{./CurrentColor}" Background="{./Background}" >
- <Template>
- <CheckBox Margin="0" Caption="{./Caption}" IsChecked="{²./IsPopped}" Background="{./Background}">
- <Template>
- <HorizontalStack Margin="3" Spacing="3" Background="{./Background}">
- <Border Width="18" Height="12" CornerRadius="3"
- Background="{../../../../CurrentColor}">
- </Border>
- <Label Width="Stretched" Text="{./Caption}" />
- </HorizontalStack>
- </Template>/>{}
- </CheckBox>
- </Template>
- <TabView MinimumSize="{../../MinimumPopupSize}" Width="Fit" Height="Fit" >
- <ColorPicker Name="HSV" CurrentColor="{²../../../CurrentColor}" Background="Onyx"/>
- <ColorPicker IsVisible="false" Name="Names" CurrentColor="{²../../../CurrentColor}" Height="Stretched" Background="Onyx">
- <Template>
- <ListBox Width="Stretched" Data="{./AvailableColors}" SelectedItemChanged="./onSelectedItemChanged">
- <Template>
- <Scroller Name="scroller1" Margin="5" ClipToClientRect="true" Background="Onyx">
- <Wrapper Name="ItemsContainer" Height="Fit" VerticalAlignment="Top"/>
- </Scroller>
- </Template>
- <ItemTemplate>
- <Border Width="16" Height="16" Background="{}" Foreground="Transparent" Tooltip="{}"
- MouseEnter="{Foreground=Black}"
- MouseLeave="{Foreground=Transparent}"/>
- </ItemTemplate>
- </ListBox>
- </Template>
- </ColorPicker>
- </TabView>
- </Popper>
\ No newline at end of file
+ <Template>
+ <HorizontalStack Margin="3" Spacing="3" Background="{./Background}">
+ <Border Width="18" Height="12" CornerRadius="3"
+ Background="{../../../CurrentColor}">
+ </Border>
+ <Label Width="Stretched" Text="{./Caption}" />
+ </HorizontalStack>
+ </Template>
+ <TabView MinimumSize="{../../MinimumPopupSize}" Width="Fit" Height="Fit" >
+ <ColorPicker Name="HSV" CurrentColor="{²../../../CurrentColor}" Background="Onyx"/>
+ <ColorPicker IsVisible="false" Name="Names" CurrentColor="{²../../../CurrentColor}" Height="Stretched" Background="Onyx">
+ <Template>
+ <ListBox Width="Stretched" Data="{./AvailableColors}" SelectedItemChanged="./onSelectedItemChanged">
+ <Template>
+ <Scroller Name="scroller1" Margin="5" ClipToClientRect="true" Background="Onyx">
+ <Wrapper Name="ItemsContainer" Height="Fit" VerticalAlignment="Top"/>
+ </Scroller>
+ </Template>
+ <ItemTemplate>
+ <Border Width="16" Height="16" Background="{}" Foreground="Transparent" Tooltip="{}"
+ MouseEnter="{Foreground=Black}"
+ MouseLeave="{Foreground=Transparent}"/>
+ </ItemTemplate>
+ </ListBox>
+ </Template>
+ </ColorPicker>
+ </TabView>
+</Popper>
\ No newline at end of file