]> O.S.I.I.S - jp/crow.git/commitdiff
Can't pop is no submenu on node
authorjpbruyere <jp.bruyere@hotmail.com>
Sat, 20 Aug 2016 15:40:01 +0000 (17:40 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Thu, 1 Sep 2016 10:44:39 +0000 (12:44 +0200)
modifié :         Templates/MenuItem.template
modifié :         src/GraphicObjects/MenuItem.cs
  add CanPop property
modifié :         src/GraphicObjects/Popper.cs
  add 'HasChildren' propertyless binding
modifié :         src/GraphicObjects/TemplatedGroup.cs

Templates/MenuItem.template
src/GraphicObjects/MenuItem.cs
src/GraphicObjects/Popper.cs
src/GraphicObjects/TemplatedGroup.cs

index 86b05be6dad697cc51edb7814f41ac1900f1408a..3d7d9211fad6d7fc7d827ea853363c10ec65b9a3 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <Popper Caption="{./Caption}"  Background="{./Background}" PopDirection="{./Orientation}"
-       Foreground = "{./Foreground}"
+       Foreground = "{./Foreground}" CanPop="{./HasChildren}"
        Unpop = "{Foreground=LightGray;Background=Transparent}">
        <Template>
                <Label Text="{./Caption}"
@@ -11,7 +11,7 @@
                        Background="{./Background}"
                        Foreground="{./Foreground}"/>
        </Template>
-       <Border Foreground="LightGray" Fit="true">
+       <Border Foreground="DimGray" Fit="true">
                <VerticalStack Name="ItemsContainer" Margin="2" Fit="true" Background="Onyx"/>
        </Border>
 </Popper>
index 591be2b06fbe25fa4ccc398f1a68dd3c4c9f5888..2734377e995149b5cf69e779a067edb9fbc9845e 100644 (file)
@@ -34,6 +34,18 @@ namespace Crow
 //             public event EventHandler Unpop;
 
                string caption;
+               Command command;
+
+               [XmlAttributeAttribute()][DefaultValue(null)]
+               public virtual Command Command {
+                       get { return command; }
+                       set {
+                               if (command == value)
+                                       return;
+                               command = value;
+                               NotifyValueChanged ("Command", command);
+                       }
+               }
 
                [XmlAttributeAttribute][DefaultValue("MenuItem")]
                public string Caption {
@@ -45,10 +57,6 @@ namespace Crow
                                NotifyValueChanged ("Caption", caption);
                        }
                }
-//             [XmlIgnore]
-//             public virtual Alignment Orientation {
-//                     get { return Parent is Menu ? (Parent as Menu).Orientation : (Parent as MenuItem); }
-//             }
 
                Menu MenuRoot {
                        get {
index 8d62f002eb4ab23f6cb456ab872654639bc9e2d4..e0da009674a22a5bc087a2a18b31aa598258c3e3 100644 (file)
@@ -34,7 +34,7 @@ namespace Crow
                }       
                #endregion
 
-               bool _isPopped;
+               bool _isPopped, _canPop;
                string caption;
                Alignment popDirection;
                GraphicObject _content;
@@ -72,6 +72,19 @@ namespace Crow
 
                        }
                }
+               [XmlAttributeAttribute()][DefaultValue(true)]
+               public bool CanPop
+               {
+                       get { return _canPop; }
+                       set
+                       {
+                               if (value == _canPop)
+                                       return;
+
+                               _canPop = value;
+                               NotifyValueChanged ("CanPop", _canPop);
+                       }
+               }
                [XmlAttributeAttribute()][DefaultValue(Alignment.Bottom)]
                public virtual Alignment PopDirection {
                        get { return popDirection; }
@@ -182,7 +195,8 @@ namespace Crow
 
                public override void onMouseClick (object sender, MouseButtonEventArgs e)
                {
-                       IsPopped = !IsPopped;
+                       if (_canPop)
+                               IsPopped = !IsPopped;
                        base.onMouseClick (sender, e);
                }
                public override void onMouseLeave (object sender, MouseMoveEventArgs e)
index cee4adea8ea048960845aee1fc9d1dc1e2abe79a..704b59af24e0b888e445dd25b9a7b8db9570e9b8 100644 (file)
@@ -38,16 +38,20 @@ namespace Crow
 
                public virtual void AddItem(GraphicObject g){
                        items.AddChild (g);
+                       NotifyValueChanged ("HasChildren", true);
                        //g.LogicalParent = this;
                }
                public virtual void RemoveItem(GraphicObject g)
                {
                        items.RemoveChild (g);
+                       if (items.Children.Count == 0)
+                               NotifyValueChanged ("HasChildren", false);
                }
 
                public virtual void ClearItems()
                {
                        items.ClearChildren ();
+                       NotifyValueChanged ("HasChildren", false);
                }
 
                protected override void loadTemplate(GraphicObject template = null)
@@ -57,6 +61,10 @@ namespace Crow
                        items = this.child.FindByName ("ItemsContainer") as Group;
                        if (items == null)
                                throw new Exception ("TemplatedGroup template Must contain a Group named 'ItemsContainer'");
+                       if (items.Children.Count == 0)
+                               NotifyValueChanged ("HasChildren", false);
+                       else
+                               NotifyValueChanged ("HasChildren", true);
                }
 
                #region GraphicObject overrides