aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2017-01-04 20:18:18 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2017-01-04 20:18:18 +0100
commit193e21872b5bfe25224405753ca78e4e880f4ef8 (patch)
tree5974361ce776cc78da3a28e09bd1e6164bdee034
parent0a309c9271d09893e682bd2568151f81036eae13 (diff)
menuItem derived from Menu + automatic opening when sibling opens
-rw-r--r--src/GraphicObjects/Menu.cs26
-rw-r--r--src/GraphicObjects/MenuItem.cs29
2 files changed, 24 insertions, 31 deletions
diff --git a/src/GraphicObjects/Menu.cs b/src/GraphicObjects/Menu.cs
index 5726afdf..1a7a3f95 100644
--- a/src/GraphicObjects/Menu.cs
+++ b/src/GraphicObjects/Menu.cs
@@ -26,10 +26,14 @@ namespace Crow
{
public class Menu : TemplatedGroup
{
+ #region CTOR
+ public Menu () : base() {}
+ #endregion
+
Orientation orientation;
[XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)]
- public virtual Orientation Orientation {
+ public Orientation Orientation {
get { return orientation; }
set {
if (orientation == value)
@@ -38,23 +42,15 @@ namespace Crow
NotifyValueChanged ("Orientation", orientation);
}
}
- bool isOpened = false;
- public bool IsOpened
- {
- get { return isOpened; }
- set
- {
- isOpened = value;
- System.Diagnostics.Debug.WriteLine ("is opened = " + isOpened);
- }
- }
-
- public Menu () : base()
+ bool autoOpen = false;
+ [XmlIgnore]public bool AutomaticOpenning
{
+ get { return autoOpen; }
+ set { autoOpen = value; }
}
public override void AddItem (GraphicObject g)
- {
+ {
base.AddItem (g);
if (orientation == Orientation.Horizontal)
@@ -65,7 +61,7 @@ namespace Crow
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
base.onMouseLeave (sender, e);
- //IsOpened = false;
+ AutomaticOpenning = false;
}
}
}
diff --git a/src/GraphicObjects/MenuItem.cs b/src/GraphicObjects/MenuItem.cs
index 87744ef9..80b5759d 100644
--- a/src/GraphicObjects/MenuItem.cs
+++ b/src/GraphicObjects/MenuItem.cs
@@ -24,7 +24,7 @@ using System.ComponentModel;
namespace Crow
{
- public class MenuItem : TemplatedGroup
+ public class MenuItem : Menu
{
#region CTOR
public MenuItem () : base() {}
@@ -47,9 +47,10 @@ namespace Crow
isOpened = value;
NotifyValueChanged ("IsOpened", isOpened);
- if (isOpened)
+ if (isOpened) {
onOpen (this, null);
- else
+ (LogicalParent as Menu).AutomaticOpenning = true;
+ }else
onClose (this, null);
}
}
@@ -75,19 +76,7 @@ namespace Crow
NotifyValueChanged ("Caption", caption);
}
}
-
- [XmlIgnore]Menu MenuRoot {
- get {
- ILayoutable tmp = LogicalParent;
- while (tmp != null) {
- if (tmp is Menu)
- return tmp as Menu;
- tmp = tmp.LogicalParent;
- }
- return null;
- }
- }
-
+
public override void AddItem (GraphicObject g)
{
base.AddItem (g);
@@ -97,6 +86,8 @@ namespace Crow
void onMI_Click (object sender, MouseButtonEventArgs e)
{
Execute.Raise (this, null);
+ if(!IsOpened)
+ (LogicalParent as Menu).AutomaticOpenning = false;
}
protected virtual void onOpen (object sender, EventArgs e){
Open.Raise (this, null);
@@ -108,6 +99,12 @@ namespace Crow
{
return base.MouseIsIn (m) || child.MouseIsIn (m);
}
+ public override void onMouseEnter (object sender, MouseMoveEventArgs e)
+ {
+ base.onMouseEnter (sender, e);
+ if ((LogicalParent as Menu).AutomaticOpenning && items.Children.Count>0)
+ IsOpened = true;
+ }
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
if (IsOpened)