From: jpbruyere Date: Sat, 20 Aug 2016 15:40:01 +0000 (+0200) Subject: Can't pop is no submenu on node X-Git-Tag: v0.5~7^2~10 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=417c7100b779d79a3bc71ec7adbf3528f9b05c92;p=jp%2Fcrow.git 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 --- 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 @@  - + 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