aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-08-20 17:40:01 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2016-09-01 12:44:39 +0200
commit417c7100b779d79a3bc71ec7adbf3528f9b05c92 (patch)
tree805d42323898f013485ed20adb19b32398600981
parentbefffb69eaebf2e607d88cd3ffc956a708d5734e (diff)
Can't pop is no submenu on node
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
-rw-r--r--Templates/MenuItem.template4
-rw-r--r--src/GraphicObjects/MenuItem.cs16
-rw-r--r--src/GraphicObjects/Popper.cs18
-rw-r--r--src/GraphicObjects/TemplatedGroup.cs8
4 files changed, 38 insertions, 8 deletions
diff --git a/Templates/MenuItem.template b/Templates/MenuItem.template
index 86b05be6..3d7d9211 100644
--- a/Templates/MenuItem.template
+++ b/Templates/MenuItem.template
@@ -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>
diff --git a/src/GraphicObjects/MenuItem.cs b/src/GraphicObjects/MenuItem.cs
index 591be2b0..2734377e 100644
--- a/src/GraphicObjects/MenuItem.cs
+++ b/src/GraphicObjects/MenuItem.cs
@@ -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 {
diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs
index 8d62f002..e0da0096 100644
--- a/src/GraphicObjects/Popper.cs
+++ b/src/GraphicObjects/Popper.cs
@@ -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)
diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs
index cee4adea..704b59af 100644
--- a/src/GraphicObjects/TemplatedGroup.cs
+++ b/src/GraphicObjects/TemplatedGroup.cs
@@ -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