public override bool ProcessMouseMove(int x, int y) { int deltaX = x - Mouse.X; int deltaY = y - Mouse.Y; Mouse.X = x; Mouse.Y = y; MouseMoveEventArgs e = new MouseMoveEventArgs(x, y, deltaX, deltaY); e.Mouse = Mouse; if (ActiveWidget != null) { //TODO, ensure object is still in the graphic tree //send move evt even if mouse move outside bounds ActiveWidget.onMouseMove(this, e); if (!ActiveWidget.IsDragged) //if active is dragged, process mouse move as it was not visible. { return(true); } } if (HoverWidget != null) { //check topmost graphicobject first GraphicObject tmp = HoverWidget; GraphicObject topc = null; while (tmp is GraphicObject) { topc = tmp; tmp = tmp.LogicalParent as GraphicObject; } int idxhw = GraphicTree.IndexOf(topc); if (idxhw != 0) { int i = 0; while (i < idxhw) { if (GraphicTree [i].localLogicalParentIsNull) { if (GraphicTree [i].MouseIsIn(e.Position)) { while (HoverWidget != null) { HoverWidget.onMouseLeave(HoverWidget, e); HoverWidget = HoverWidget.LogicalParent as GraphicObject; } GraphicTree [i].checkHoverWidget(e); return(true); } } i++; } } if (HoverWidget.MouseIsIn(e.Position)) { if (!(HoverWidget is TemplatedControl)) { HoverWidget.checkHoverWidget(e); } return(true); } else { HoverWidget.onMouseLeave(HoverWidget, e); //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); } } } } //top level graphic obj's parsing lock (GraphicTree) { for (int i = 0; i < GraphicTree.Count; i++) { GraphicObject g = GraphicTree [i]; if (g.MouseIsIn(e.Position)) { if (!(HoverWidget is TemplatedControl)) { g.checkHoverWidget(e); } if (g is Window) { PutOnTop(g); } return(true); } } } HoverWidget = null; return(false); }
public bool ProcessMouseMove(int x, int y) { int deltaX = x - imlVE.Mouse.X; int deltaY = y - imlVE.Mouse.Y; imlVE.Mouse.X = x; imlVE.Mouse.Y = y; MouseMoveEventArgs e = new MouseMoveEventArgs(x, y, deltaX, deltaY); e.Mouse = imlVE.Mouse; if (imlVE.ActiveWidget != null) { //TODO, ensure object is still in the graphic tree //send move evt even if mouse move outside bounds imlVE.ActiveWidget.onMouseMove(this, e); return(true); } if (imlVE.HoverWidget != null) { //TODO, ensure object is still in the graphic tree //check topmost graphicobject first GraphicObject tmp = imlVE.HoverWidget; GraphicObject topc = null; while (tmp is GraphicObject) { topc = tmp; tmp = tmp.LogicalParent as GraphicObject; } int idxhw = imlVE.GraphicTree.IndexOf(topc); if (idxhw != 0) { int i = 0; while (i < idxhw) { if (imlVE.GraphicTree [i].LogicalParent == imlVE.GraphicTree [i].Parent) { if (imlVE.GraphicTree [i].MouseIsIn(e.Position)) { while (imlVE.HoverWidget != null) { imlVE.HoverWidget.onMouseLeave(imlVE.HoverWidget, e); imlVE.HoverWidget = imlVE.HoverWidget.LogicalParent as GraphicObject; } imlVE.GraphicTree [i].checkHoverWidget(e); return(true); } } i++; } } if (imlVE.HoverWidget.MouseIsIn(e.Position)) { imlVE.HoverWidget.checkHoverWidget(e); return(true); } else { imlVE.HoverWidget.onMouseLeave(imlVE.HoverWidget, e); //seek upward from last focused graph obj's while (imlVE.HoverWidget.LogicalParent as GraphicObject != null) { imlVE.HoverWidget = imlVE.HoverWidget.LogicalParent as GraphicObject; if (imlVE.HoverWidget.MouseIsIn(e.Position)) { imlVE.HoverWidget.checkHoverWidget(e); return(true); } else { imlVE.HoverWidget.onMouseLeave(imlVE.HoverWidget, e); } } } } //top level graphic obj's parsing lock (imlVE.GraphicTree) { for (int i = 0; i < imlVE.GraphicTree.Count; i++) { GraphicObject g = imlVE.GraphicTree [i]; if (g.MouseIsIn(e.Position)) { g.checkHoverWidget(e); if (g is Window) { imlVE.PutOnTop(g); } return(true); } } } imlVE.HoverWidget = null; return(false); }