]> O.S.I.I.S - jp/crow.git/commitdiff
IToggle for TemplatedGroup recursion, Popper without checkbox in template, commands...
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 22 Apr 2021 16:12:14 +0000 (18:12 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 22 Apr 2021 16:12:14 +0000 (18:12 +0200)
29 files changed:
Crow/Templates/ComboBox.template
Crow/Templates/Popper.template
Crow/src/Command.cs [deleted file]
Crow/src/Command/Command.cs [new file with mode: 0644]
Crow/src/Command/CommandBase.cs [new file with mode: 0644]
Crow/src/Command/CommandGroup.cs [new file with mode: 0644]
Crow/src/EventArgs/TreeExpandEventArg.cs
Crow/src/IToggle.cs [new file with mode: 0644]
Crow/src/Widgets/CheckBox.cs
Crow/src/Widgets/Expandable.cs
Crow/src/Widgets/GroupBase.cs
Crow/src/Widgets/Popper.cs
Crow/src/Widgets/PrivateContainer.cs
Crow/src/Widgets/TemplatedContainer.cs
Crow/src/Widgets/TemplatedControl.cs
Crow/src/Widgets/TemplatedGroup.cs
Crow/src/Widgets/TreeView.cs
Crow/src/Widgets/Widget.cs
Samples/DebugLogAnalyzer/ui/ComboBox.template [deleted file]
Samples/DebugLogAnalyzer/ui/EnumSelector.template
Samples/DebugLogAnalyzer/ui/dbg.style
Samples/common/SampleBase.cs
Samples/common/ui/Interfaces/Experimental/colorTable.crow
Samples/common/ui/Interfaces/Experimental/fitPopup.crow [new file with mode: 0644]
Samples/common/ui/Interfaces/Experimental/spinner.crow
Samples/common/ui/Interfaces/TemplatedGroup/1.crow
Samples/common/ui/Interfaces/menutest.crow
Samples/common/ui/Interfaces/menutest2.crow [new file with mode: 0644]
Samples/common/ui/templates/ColorPicker.template

index 8e13b6839b297f54c29f7d588d132b5e95a7a94b..8e818d58b50e2a66ccf3d1c54b9402a92a29fd05 100644 (file)
@@ -1,19 +1,15 @@
 <?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"
index d9b9f1ac12647dd34ab671a558b70868dbc84e10..2a0a0de5ceca796030f219e0d7dcc4692e5761ff 100644 (file)
@@ -1,14 +1,9 @@
 <?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>
diff --git a/Crow/src/Command.cs b/Crow/src/Command.cs
deleted file mode 100644 (file)
index a185e1a..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-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);
-               }
-       }
-}
diff --git a/Crow/src/Command/Command.cs b/Crow/src/Command/Command.cs
new file mode 100644 (file)
index 0000000..80bbf46
--- /dev/null
@@ -0,0 +1,84 @@
+// 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);
+               }
+       }
+}
diff --git a/Crow/src/Command/CommandBase.cs b/Crow/src/Command/CommandBase.cs
new file mode 100644 (file)
index 0000000..41aef60
--- /dev/null
@@ -0,0 +1,63 @@
+// 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);
+               }
+       }
+}
diff --git a/Crow/src/Command/CommandGroup.cs b/Crow/src/Command/CommandGroup.cs
new file mode 100644 (file)
index 0000000..ef4b0ef
--- /dev/null
@@ -0,0 +1,57 @@
+// 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();
+       }
+}
index 7641aa5df3d1c7c92391d9ca8a2fa9c7515c68cf..feb3bad09fd7a3882ce23b7182b1615549e217fe 100644 (file)
@@ -9,9 +9,8 @@ namespace Crow
                /// <summary>
                /// Source of the expand/collapse event
                /// </summary>
-               public Expandable SourceWidget;
-               public TreeExpandEventArg (Expandable sourceWidget)
-               {
+               public IToggle SourceWidget;
+               public TreeExpandEventArg (IToggle sourceWidget) {
 
                }
        }
diff --git a/Crow/src/IToggle.cs b/Crow/src/IToggle.cs
new file mode 100644 (file)
index 0000000..54564be
--- /dev/null
@@ -0,0 +1,21 @@
+// 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;
+               }
+
+       }
+}
index ccd1ee756f62aa163d2638c77e89d7af24ce4e0a..a51ff18c1868a38c469c9bf01cfc1a260c2cb198 100644 (file)
@@ -46,6 +46,7 @@ namespace Crow
                public override void onMouseClick (object sender, MouseButtonEventArgs e)
                {
                        IsChecked = !IsChecked;
+                       e.Handled = true;
                        base.onMouseClick (sender, e);
                }
        }
index e656d7711eb672b582723594a3b1ce7b716dbe3c..e2a7818b5fcb2e43914a40f9dc9e9f02a67fda9e 100644 (file)
@@ -10,8 +10,8 @@ namespace Crow
        /// <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){}
@@ -33,6 +33,20 @@ namespace Crow
                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>
@@ -55,11 +69,11 @@ namespace Crow
                        }
                }
                [DefaultValue(false)]
-        public bool IsExpanded
-        {
+               public bool IsExpanded
+               {
                        get { return _isExpanded; }
-            set
-            {
+                       set
+                       {
                                if (value == _isExpanded)
                                        return;
 
@@ -68,16 +82,17 @@ namespace Crow
                                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 {
@@ -88,6 +103,7 @@ namespace Crow
                                }
                        }
                }
+
                #endregion
 
                public virtual void onExpand(object sender, EventArgs e)
@@ -96,6 +112,7 @@ namespace Crow
                                _contentContainer.IsVisible = true;
 
                        Expand.Raise (this, e);
+                       ToggleOn.Raise (this, null);
                }
                public virtual void onCollapse(object sender, EventArgs e)
                {
@@ -103,6 +120,7 @@ namespace Crow
                                _contentContainer.IsVisible = false;
 
                        Collapse.Raise (this, e);
+                       ToggleOff.Raise (this, null);
                }
        }
 }
index 4c0267f83996449746e7efef779760a8b763b96d..5784bc2951e20b12e7916848f9addadb4440fc9b 100644 (file)
@@ -175,11 +175,11 @@ namespace Crow
 
                        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 ();
 
index 3e2f37cfb07cf32c26b4eb184b94caeedd188c62..fff2729dc86c3d249229d3200b4a68a4dc2c9b77 100644 (file)
@@ -7,7 +7,7 @@ using System.ComponentModel;
 
 namespace Crow
 {
-       public class Popper : TemplatedContainer
+       public class Popper : TemplatedContainer, IToggle
     {
                #region CTOR
                protected Popper () {}
@@ -110,6 +110,7 @@ namespace Crow
                                _content.HorizontalAlignment = HorizontalAlignment.Left;
                                _content.VerticalAlignment = VerticalAlignment.Top;
                                _content.LayoutChanged += _content_LayoutChanged;
+                               _content.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
                        }
                }
                void positionContent(LayoutingType lt){
@@ -193,23 +194,24 @@ namespace Crow
 
                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)
@@ -220,5 +222,23 @@ namespace Crow
                        }
                        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              
        }
 }
index 22a34f1cb6e1eaacd13ea55e3aa481b20490c587..c7daad5783d5a7cdc4c477182528ba876db1b576 100644 (file)
@@ -81,12 +81,12 @@ namespace Crow
 
                        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)
                {
index b8d7a1286d2a7a8aa0980017024b9c55a1f6f770..c51ea3eba3821e28c81e065be258018231df5839 100644 (file)
@@ -63,12 +63,12 @@ namespace Crow
 
                        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)
                {
index 5110d941a56beb8a01d3849fcadcdbf15876d434..e971c20b409eaae9846e14d72c811c1ccd4714b4 100644 (file)
@@ -79,7 +79,7 @@ namespace Crow
                /// <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
index a1ac759c15054daabe009e25f10b207e1453f1d6..67c1f0dba6a877d5217f71a2d077529c43979802 100644 (file)
@@ -287,17 +287,17 @@ namespace Crow {
                        }
                        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)
                {
@@ -333,8 +333,10 @@ namespace Crow {
                        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());
                        }
 
@@ -477,16 +479,17 @@ namespace Crow {
                        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);
                                }
                        }
 
@@ -565,11 +568,6 @@ namespace Crow {
                        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)
index 2993a12b5fd4e78d2667b03057b0e7106e8739b2..f01208e3cdb4e3d409071fce6c3b41cbd6b091fa 100644 (file)
@@ -33,7 +33,7 @@ namespace Crow
                }
 
 
-               void onExpandAll_MouseClick (object sender, MouseButtonEventArgs e)
+               /*void onExpandAll_MouseClick (object sender, MouseButtonEventArgs e)
                {
                        ExpandAll ();
                }
@@ -41,23 +41,22 @@ namespace Crow
                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;
+                                       }
                                }
                        }
-               }
+               }*/
        }
 }
 
index c38f373bd0c2fa258d71471cd5fd410a6e998f67..6f0cd6c2a265f5b8e18e1b969f00b93c6104769b 100644 (file)
@@ -252,7 +252,7 @@ namespace Crow
                        loadDefaultValues ();
                }
                #region private fields
-               LayoutingType registeredLayoutings;// = LayoutingType.All;
+               LayoutingType registeredLayoutings;// = LayoutingType.Sizing;
                ILayoutable logicalParent;
                ILayoutable parent;
                string name;
@@ -1304,13 +1304,10 @@ namespace Crow
                }
 #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;
                }
diff --git a/Samples/DebugLogAnalyzer/ui/ComboBox.template b/Samples/DebugLogAnalyzer/ui/ComboBox.template
deleted file mode 100644 (file)
index 1b8e439..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?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>
index 2fffa3f833a1d5755bd5227a44112b43dcd9e59e..01d043835bec433c387a0e91b0262d5275c79a91 100644 (file)
@@ -1,14 +1,10 @@
 <?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
index 90ec61dab2ebede705a8c60f0c210b6138b6b6ac..33a5e9f4d76f374d0750940087b5daa1ba5c7e0d 100644 (file)
@@ -22,10 +22,6 @@ DbgEventView {
        Height="Fit";
        Width="150";
 }
-ComboBox {
-       Template="#Dbg.ComboBox.template";
-       Background="Jet";
-}
 labWidgetRecordList {
        Font="mono, 11";
        Background="Grey";
index 22d1fb0b1beded916155dcb53eabc6b45bf62225..1e849d6fadc3e263b33daddf68e3e00916d3738e 100644 (file)
@@ -47,26 +47,27 @@ namespace Crow
                #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"))
                        );
                }
index 6da2b04a8d5d2abce60e2ca8b6fda97974c19508..297902611704c2d60770e7d74eb291ab76a09e50 100644 (file)
@@ -1,6 +1,8 @@
-<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>
diff --git a/Samples/common/ui/Interfaces/Experimental/fitPopup.crow b/Samples/common/ui/Interfaces/Experimental/fitPopup.crow
new file mode 100644 (file)
index 0000000..44eef9f
--- /dev/null
@@ -0,0 +1,11 @@
+<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
index ac32e78d5c21a974133ea04f912e5821c051004c..4b5e66f0dc2137b03345709530c4b498d092bb6f 100644 (file)
@@ -1,6 +1,6 @@
 <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">
index c74bcedd031abc9ba11390d523b8026e118ac73b..9823da4d5559f4ee1878eb7be623fb5404eeb1cb 100644 (file)
@@ -3,28 +3,24 @@
        <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>     
index 6498f644b77433751dd1f4801342b9ab0adcb6bd..eca923e5db5e4fff439bd7b082d2f99d851fc5c2 100644 (file)
@@ -1,31 +1,58 @@
-<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
diff --git a/Samples/common/ui/Interfaces/menutest2.crow b/Samples/common/ui/Interfaces/menutest2.crow
new file mode 100644 (file)
index 0000000..32e841e
--- /dev/null
@@ -0,0 +1,59 @@
+<?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
index 81f1f7cacf2c728463fce9d87a36de3381c63b7b..ca7ddda4d0c27a0ce05aa5fa71cf361737be8c77 100644 (file)
@@ -1,34 +1,30 @@
 <?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