diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-31 12:26:16 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-09-01 12:44:39 +0200 |
| commit | 8d1e0c98e1efac4f9ee133634251a48fa6547ce6 (patch) | |
| tree | 3553d3999ae82e16936cbb07d51067559affc38c /src/GraphicObjects/MenuItem.cs | |
| parent | e68f66a334bd37c60416615d8314a62dd9d05740 (diff) | |
debug mouse leave, move recursive test back into interface instead of go.MouseLeave
Menu IsOpen handling
MenuItem Open and Close events
Diffstat (limited to 'src/GraphicObjects/MenuItem.cs')
| -rw-r--r-- | src/GraphicObjects/MenuItem.cs | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/src/GraphicObjects/MenuItem.cs b/src/GraphicObjects/MenuItem.cs index 9055fc5b..60233361 100644 --- a/src/GraphicObjects/MenuItem.cs +++ b/src/GraphicObjects/MenuItem.cs @@ -30,12 +30,34 @@ namespace Crow public MenuItem () : base() {} #endregion + public event EventHandler Open; + public event EventHandler Close; public event EventHandler Execute; string caption; Command command;//TODO + bool isOpened; - [XmlAttributeAttribute()][DefaultValue(null)] + [XmlAttributeAttribute][DefaultValue(false)] + public bool IsOpened { + //get { return MenuRoot == null ? false : MenuRoot.IsOpened; } + get { return isOpened; } + set { + if (isOpened == value) + return; + isOpened = value; + NotifyValueChanged ("IsOpened", isOpened); + + if (isOpened) { + onOpen (this, null); + if (MenuRoot != null) + MenuRoot.IsOpened = true; + }else + onClose (this, null); + } + } + + [XmlAttributeAttribute][DefaultValue(null)] public virtual Command Command { get { return command; } set { @@ -59,11 +81,11 @@ namespace Crow [XmlIgnore]Menu MenuRoot { get { - ILayoutable tmp = Parent; + ILayoutable tmp = LogicalParent; while (tmp != null) { if (tmp is Menu) return tmp as Menu; - tmp = tmp.Parent; + tmp = tmp.LogicalParent; } return null; } @@ -79,6 +101,21 @@ namespace Crow { Execute.Raise (this, null); } + void onOpen (object sender, EventArgs e){ + MenuRoot.IsOpened = true; + Open.Raise (this, null); + } + void onClose (object sender, EventArgs e){ + //MenuRoot.IsOpened = true; + Close.Raise (this, null); + } + public override void onMouseEnter (object sender, MouseMoveEventArgs e) + { + base.onMouseEnter (sender, e); + if (MenuRoot == null || Items.Count == 0) + return; + IsOpened = MenuRoot.IsOpened; + } } } |