{
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)
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)
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
base.onMouseLeave (sender, e);
- //IsOpened = false;
+ AutomaticOpenning = false;
}
}
}
namespace Crow
{
- public class MenuItem : TemplatedGroup
+ public class MenuItem : Menu
{
#region CTOR
public MenuItem () : base() {}
isOpened = value;
NotifyValueChanged ("IsOpened", isOpened);
- if (isOpened)
+ if (isOpened) {
onOpen (this, null);
- else
+ (LogicalParent as Menu).AutomaticOpenning = true;
+ }else
onClose (this, null);
}
}
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);
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);
{
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)