Width = Fit;
Background = Transparent;
Foreground = LightGray;
+ Open = {Background = Mantis;Foreground=Jet;}
+ Close = {Foreground=LightGray;Background=Transparent;}
}
MessageBox {
Width=200;
<?xml version="1.0"?>
<Popper Caption="{./Caption}" Background="{./Background}" PopDirection="{./PopDirection}"
Foreground = "{./Foreground}" CanPop="{./HasChildren}" MouseClick="./onMI_Click"
- Unpop = "{Foreground=LightGray;Background=Transparent}"
- Pop = "{Background = Mantis;Foreground=Jet}"
- >
+ IsPopped="{²./IsOpened}">
<Template>
<Border Name="border1"
MouseEnter="{Foreground=vgradient|0:White|0.2:Gray|0.9:Gray|1:Black}"
<MenuItem Caption="Save"/>
<MenuItem Caption="Quit"/>
</MenuItem>
- <MenuItem Caption="Edit">
+ <MenuItem Caption="Edit" Name="edit">
<MenuItem Caption="Cut"/>
<MenuItem Caption="Copy"/>
<MenuItem Caption="Paste"/>
- <MenuItem Caption="Special">
+ <MenuItem Caption="Special" Name="special">
+ <MenuItem Caption="Cut"/>
+ <MenuItem Caption="Copy"/>
+ <MenuItem Caption="Paste"/>
+ </MenuItem>
+ <MenuItem Caption="Special2" Name="special">
<MenuItem Caption="Cut"/>
<MenuItem Caption="Copy"/>
<MenuItem Caption="Paste"/>
Debug.WriteLine("MouseLeave => " + this.ToString());
#endif
MouseLeave.Raise (this, e);
-
- GraphicObject p = Parent as GraphicObject;
- CurrentInterface.HoverWidget = p;
-
- if (p == null)
- return;
-
- if (p.MouseIsIn (e.Position)&&e!=null)
- p.checkHoverWidget (e);
- else
- p.onMouseLeave (sender, e);
}
#endregion
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()
{
else
g.NotifyValueChanged ("PopDirection", Alignment.Right);
}
+ public override void onMouseLeave (object sender, MouseMoveEventArgs e)
+ {
+ base.onMouseLeave (sender, e);
+ IsOpened = false;
+ }
}
}
+
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 {
[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;
}
{
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;
+ }
}
}
namespace Crow
{
public class Popper : TemplatedContainer
- {
+ {
#region CTOR
public Popper() : base()
{
- }
+ }
#endregion
bool _isPopped, _canPop;
#region Public Properties
[XmlAttributeAttribute()][DefaultValue("Popper")]
public string Caption {
- get { return caption; }
+ get { return caption; }
set {
if (caption == value)
return;
- caption = value;
+ caption = value;
NotifyValueChanged ("Caption", caption);
}
}
public override GraphicObject Content {
get { return _content; }
- set {
+ set {
if (_content != null) {
_content.LogicalParent = null;
_content.LayoutChanged -= _content_LayoutChanged;
- _content.MouseLeave -= onMouseLeave;
}
-
- _content = value;
+
+ _content = value;
if (_content == null)
return;
_content.HorizontalAlignment = HorizontalAlignment.Left;
_content.VerticalAlignment = VerticalAlignment.Top;
_content.LayoutChanged += _content_LayoutChanged;
- _content.MouseLeave += onMouseLeave;
}
}
if (_content == null)
return;
-
+
if (layoutType == LayoutingType.Width)
- _content.MinimumSize = new Size (this.Slot.Width, _content.MinimumSize.Height);
+ _content.MinimumSize = new Size (this.Slot.Width, _content.MinimumSize.Height);
}
public override void ClearBinding ()
}
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
- base.onMouseLeave (sender, e);
- IsPopped = false;
+ if (!_isPopped || _content == null) {
+ base.onMouseLeave (sender, e);
+ System.Diagnostics.Debug.WriteLine ("NotPopped***popper mouse leave:"+ this.ToString());
+ return;
+ }
+
+ if (!_content.MouseIsIn (e.Position)) {
+ base.onMouseLeave (sender, e);
+ System.Diagnostics.Debug.WriteLine ("***popper mouse leave:"+ this.ToString());
+ IsPopped = false;
+ return;
+ }
}
#endregion
-
+
public virtual void onPop(object sender, EventArgs e)
{
if (Content != null) {
return Content == null ? null : Content.FindByName (nameToFind);
}
+ public override bool Contains (GraphicObject goToFind)
+ {
+ if (Content == null)
+ return base.Contains (goToFind);
+
+ if (Content == goToFind)
+ return true;
+ return Content.Contains (goToFind);
+ }
#endregion
#region IXmlSerialisation Overrides
//seek for template tag
using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
xr.Read ();
- base.ReadXml (xr);
+ base.ReadXml (xr);
}
//process content
using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
if (!xr.IsStartElement ())
continue;
-
+
if (xr.Name == "Template"){
xr.Skip ();
if (!xr.IsStartElement ())
}
if (t == null)
throw new Exception (xr.Name + " type not found");
-
- GraphicObject go = (GraphicObject)Activator.CreateInstance (t);
+
+ GraphicObject go = (GraphicObject)Activator.CreateInstance (t);
(go as IXmlSerializable).ReadXml (xr);
if (w.Contains (goToFind))
return true;
}
- return false;
+ return base.Contains(goToFind);
}
// public override void ClearBinding ()
// {
int i = 0;
while (i < idxhw) {
if (GraphicTree [i].MouseIsIn (e.Position)) {
- //set evtarg to null to force mouseLeave without checking mouse pos
- HoverWidget.onMouseLeave (HoverWidget, null);
+ while (HoverWidget != null) {
+ if (HoverWidget is Popper) {
+ if ((HoverWidget as Popper).Content == GraphicTree[i])
+ break;
+ }
+ HoverWidget.onMouseLeave (HoverWidget, e);
+ HoverWidget = HoverWidget.LogicalParent as GraphicObject;
+ }
+
GraphicTree [i].checkHoverWidget (e);
return true;
}
return true;
} else {
HoverWidget.onMouseLeave (HoverWidget, e);
- if (HoverWidget != null)
- return true;
+ //seek upward from last focused graph obj's
+ while (HoverWidget.LogicalParent as GraphicObject != null) {
+ HoverWidget = HoverWidget.LogicalParent as GraphicObject;
+ if (HoverWidget.MouseIsIn (e.Position)) {
+ HoverWidget.checkHoverWidget (e);
+ return true;
+ } else
+ HoverWidget.onMouseLeave (HoverWidget, e);
+ }
}
}