コード例 #1
0
        void IEventPortal.PortalMouseUp(UIMouseEventArgs e)
        {
#if DEBUG
            if (this.dbugRootGraphics.dbugEnableGraphicInvalidateTrace)
            {
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("MOUSEUP");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
            }
#endif

            HitChain hitPointChain = GetFreeHitChain();
            HitTestCoreWithPrevChainHint(hitPointChain, this._previousChain, e.X, e.Y);
            int hitCount = hitPointChain.Count;
            if (hitCount > 0)
            {
                SetEventOrigin(e, hitPointChain);
                //---------------------------------------------------------------
                ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (portal) =>
                {
                    portal.PortalMouseUp(e);
                    return(true);
                });
                //---------------------------------------------------------------
                if (!e.CancelBubbling)
                {
                    ForEachEventListenerBubbleUp(e, hitPointChain, (listener) =>
                    {
                        listener.ListenMouseUp(e);
                        return(true);
                    });
                }
                //---------------------------------------------------------------
                if (!e.CancelBubbling)
                {
                    if (e.IsAlsoDoubleClick)
                    {
                        ForEachEventListenerBubbleUp(e, hitPointChain, listener =>
                        {
                            listener.ListenMouseDoubleClick(e);
                            //-------------------------------------------------------
                            //retrun true to stop this loop (no further bubble up)
                            //return false to bubble this to upper control
                            return(e.CancelBubbling || !listener.BypassAllMouseEvents);
                        });
                    }
                    else
                    {
                        ForEachEventListenerBubbleUp(e, hitPointChain, listener =>
                        {
                            listener.ListenMouseClick(e);
                            return(e.CancelBubbling || !listener.BypassAllMouseEvents);
                        });
                    }
                }
            }
            SwapHitChain(hitPointChain);
            e.StopPropagation();
        }
コード例 #2
0
        void IEventPortal.PortalMouseWheel(UIMouseEventArgs e)
        {
#if DEBUG
            if (this.dbugRootGraphics.dbugEnableGraphicInvalidateTrace)
            {
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("MOUSEWHEEL");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
            }
#endif
            HitChain hitPointChain = GetFreeHitChain();
#if DEBUG
            _dbugHitChainPhase = dbugHitChainPhase.MouseWheel;
#endif
            //find hit element
            HitTestCoreWithPrevChainHint(hitPointChain, _previousChain, e.X, e.Y);
            if (hitPointChain.Count > 0)
            {
                //------------------------------
                //1. origin object
                SetEventOrigin(e, hitPointChain);
                //------------------------------
                IUIEventListener currentMouseWheel = null;
                //portal
                ForEachOnlyEventPortalBubbleUp(e, hitPointChain, portal =>
                {
                    portal.PortalMouseWheel(e);
                    //*****
                    currentMouseWheel = e.CurrentContextElement;
                    return(true);
                });
                //------------------------------
                //use events
                if (!e.CancelBubbling)
                {
                    e.CurrentContextElement = currentMouseWheel = null; //clear
                    ForEachEventListenerBubbleUp(e, hitPointChain, listener =>
                    {
                        if (listener.BypassAllMouseEvents)
                        {
                            return(false);
                        }
                        currentMouseWheel = listener;
                        listener.ListenMouseWheel(e);
                        //-------------------------------------------------------
                        bool cancelMouseBubbling = e.CancelBubbling;
                        //-------------------------------------------------------
                        //retrun true to stop this loop (no further bubble up)
                        //return false to bubble this to upper control
                        return(e.CancelBubbling || !listener.BypassAllMouseEvents);
                    });
                }
            }

            SwapHitChain(hitPointChain);
            e.StopPropagation();
        }
コード例 #3
0
        void IEventPortal.PortalMouseMove(UIMouseEventArgs e)
        {
            HitChain hitPointChain = GetFreeHitChain();

#if DEBUG
            hitPointChain.dbugHitPhase = dbugHitChainPhase.MouseMove;
#endif
            HitTestCoreWithPrevChainHint(hitPointChain, this._previousChain, e.X, e.Y);
            this._previousChain.ClearAll();
            SetEventOrigin(e, hitPointChain);
            //-------------------------------------------------------
            ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (portal) =>
            {
                portal.PortalMouseMove(e);
                return(true);
            });
            //-------------------------------------------------------
            if (!e.CancelBubbling)
            {
                bool foundSomeHit = false;
                ForEachEventListenerBubbleUp(e, hitPointChain, (listener) =>
                {
                    foundSomeHit           = true;
                    bool isFirstMouseEnter = false;
                    if (e.CurrentMouseActive != null &&
                        e.CurrentMouseActive != listener)
                    {
                        e.CurrentMouseActive.ListenMouseLeave(e);
                        isFirstMouseEnter = true;
                    }

                    if (!e.IsCanceled)
                    {
                        e.CurrentMouseActive = listener;
                        e.IsFirstMouseEnter  = isFirstMouseEnter;
                        e.CurrentMouseActive.ListenMouseMove(e);
                        e.IsFirstMouseEnter = false;
                    }

                    return(true);//stop
                });
                if (!foundSomeHit && e.CurrentMouseActive != null)
                {
                    e.CurrentMouseActive.ListenMouseLeave(e);
                    if (!e.IsCanceled)
                    {
                        e.CurrentMouseActive = null;
                    }
                }
            }
            SwapHitChain(hitPointChain);
            e.StopPropagation();
        }
コード例 #4
0
        void IEventPortal.PortalMouseMove(UIMouseEventArgs e)
        {
            HitChain hitPointChain = GetFreeHitChain();

            HitTestCoreWithChain(hitPointChain, e.X, e.Y);
            SetEventOrigin(e, hitPointChain);
            //-------------------------------------------------------
            ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (portal) =>
            {
                portal.PortalMouseMove(e);
                return(true);
            });
            //-------------------------------------------------------
            if (!e.CancelBubbling)
            {
                bool foundSomeHit = false;
                ForEachEventListenerBubbleUp(e, hitPointChain, (listener) =>
                {
                    foundSomeHit           = true;
                    bool isFirstMouseEnter = false;
                    if (e.CurrentMouseActive != null &&
                        e.CurrentMouseActive != listener)
                    {
                        e.CurrentMouseActive.ListenMouseLeave(e);
                        isFirstMouseEnter = true;
                    }

                    if (!e.IsCanceled)
                    {
                        e.CurrentMouseActive = listener;
                        e.IsFirstMouseEnter  = isFirstMouseEnter;
                        e.CurrentMouseActive.ListenMouseMove(e);
                        e.IsFirstMouseEnter = false;
                    }

                    return(true);//stop
                });
                if (!foundSomeHit && e.CurrentMouseActive != null)
                {
                    e.CurrentMouseActive.ListenMouseLeave(e);
                    if (!e.IsCanceled)
                    {
                        e.CurrentMouseActive = null;
                    }
                }
            }
            ReleaseHitChain(hitPointChain);
            e.StopPropagation();
        }
コード例 #5
0
 protected override void OnMouseLeave(UIMouseEventArgs e)
 {
     if (e.IsDragging)
     {
         MoveWithSnapToGrid(this, e);
         e.MouseCursorStyle = MouseCursorStyle.Pointer;
         e.StopPropagation();
     }
     base.OnMouseLeave(e);
 }
コード例 #6
0
        void IEventPortal.PortalMouseDown(UIMouseEventArgs e)
        {
#if DEBUG
            if (this.dbugRootGraphics.dbugEnableGraphicInvalidateTrace)
            {
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("MOUSEDOWN");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
            }
            dbugMsgChainVersion = 1;
            int local_msgVersion = 1;
#endif


            HitChain hitPointChain = GetFreeHitChain();
            HitTestCoreWithPrevChainHint(hitPointChain, this._previousChain, e.X, e.Y);
            int           hitCount   = hitPointChain.Count;
            RenderElement hitElement = hitPointChain.TopMostElement;
            if (hitCount > 0)
            {
                //------------------------------
                //1. origin object
                SetEventOrigin(e, hitPointChain);
                //------------------------------
                var prevMouseDownElement          = e.PreviousMouseDown;
                IUIEventListener currentMouseDown = null;
                //portal
                ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (portal) =>
                {
                    portal.PortalMouseDown(e);
                    //*****
                    currentMouseDown = e.CurrentContextElement;
                    return(true);
                });
                //------------------------------
                //use events
                if (!e.CancelBubbling)
                {
                    e.CurrentContextElement = currentMouseDown = null; //clear
                    ForEachEventListenerBubbleUp(e, hitPointChain, (listener) =>
                    {
                        currentMouseDown = listener;
                        listener.ListenMouseDown(e);
                        //-------------------------------------------------------
                        bool cancelMouseBubbling = e.CancelBubbling;
                        if (prevMouseDownElement != null &&
                            prevMouseDownElement != listener)
                        {
                            prevMouseDownElement.ListenLostMouseFocus(e);
                            prevMouseDownElement = null;//clear
                        }
                        //-------------------------------------------------------
                        return(e.CancelBubbling || !listener.BypassAllMouseEvents);
                    });
                }

                if (prevMouseDownElement != currentMouseDown &&
                    prevMouseDownElement != null)
                {
                    prevMouseDownElement.ListenLostMouseFocus(e);
                    prevMouseDownElement = null;
                }
            }
            //---------------------------------------------------------------

#if DEBUG
            RootGraphic visualroot = this.dbugRootGraphics;
            if (visualroot.dbug_RecordHitChain)
            {
                visualroot.dbug_rootHitChainMsg.Clear();
                HitInfo hitInfo;
                for (int tt = hitPointChain.Count - 1; tt >= 0; --tt)
                {
                    hitInfo = hitPointChain.GetHitInfo(tt);
                    RenderElement ve = hitInfo.hitElement;
                    if (ve != null)
                    {
                        ve.dbug_WriteOwnerLayerInfo(visualroot, tt);
                        ve.dbug_WriteOwnerLineInfo(visualroot, tt);
                        string hit_info = new string('.', tt) + " [" + tt + "] "
                                          + "(" + hitInfo.point.X + "," + hitInfo.point.Y + ") "
                                          + ve.dbug_FullElementDescription();
                        visualroot.dbug_rootHitChainMsg.AddLast(new dbugLayoutMsg(ve, hit_info));
                    }
                }
            }
#endif
            SwapHitChain(hitPointChain);
            e.StopPropagation();
#if DEBUG
            if (local_msgVersion != dbugMsgChainVersion)
            {
                return;
            }
            visualroot.dbugHitTracker.Write("stop-mousedown");
            visualroot.dbugHitTracker.Play = false;
#endif
        }
コード例 #7
0
        void IEventPortal.PortalMouseUp(UIMouseEventArgs e)
        {
#if DEBUG

            if (this.dbugRootGraphics.dbugEnableGraphicInvalidateTrace)
            {
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("MOUSEUP");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
            }
#endif

            HitChain hitPointChain = GetFreeHitChain();
            HitTestCoreWithPrevChainHint(hitPointChain, this._previousChain, e.X, e.Y);
            int hitCount = hitPointChain.Count;
            if (hitCount > 0)
            {
                SetEventOrigin(e, hitPointChain);
                //--------------------------------------------------------------- 
                ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (portal) =>
                {
                    portal.PortalMouseUp(e);
                    return true;
                });
                //---------------------------------------------------------------
                if (!e.CancelBubbling)
                {
                    ForEachEventListenerBubbleUp(e, hitPointChain, (listener) =>
                    {
                        listener.ListenMouseUp(e);
                        return true;

                    });
                }
                //---------------------------------------------------------------
                if (!e.CancelBubbling)
                {
                    if (e.IsAlsoDoubleClick)
                    {
                        ForEachEventListenerBubbleUp(e, hitPointChain, listener =>
                        {
                            listener.ListenMouseDoubleClick(e);
                            //------------------------------------------------------- 
                            //retrun true to stop this loop (no further bubble up)
                            //return false to bubble this to upper control       
                            return e.CancelBubbling || !listener.BypassAllMouseEvents;
                        });
                    }
                    else
                    {
                        ForEachEventListenerBubbleUp(e, hitPointChain, listener =>
                        {
                            listener.ListenMouseClick(e);
                            return e.CancelBubbling || !listener.BypassAllMouseEvents;
                        });
                    }
                }
            }
            SwapHitChain(hitPointChain);
            e.StopPropagation();
        }
コード例 #8
0
        void IEventPortal.PortalMouseMove(UIMouseEventArgs e)
        {
            HitChain hitPointChain = GetFreeHitChain();
            HitTestCoreWithPrevChainHint(hitPointChain, this._previousChain, e.X, e.Y);
            this._previousChain.ClearAll();
            SetEventOrigin(e, hitPointChain);
            //-------------------------------------------------------
            ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (portal) =>
            {
                portal.PortalMouseMove(e);
                return true;
            });
            //-------------------------------------------------------  
            if (!e.CancelBubbling)
            {
                bool foundSomeHit = false;
                ForEachEventListenerBubbleUp(e, hitPointChain, (listener) =>
                {
                    foundSomeHit = true;
                    bool isFirstMouseEnter = false;
                    if (e.CurrentMouseActive != null &&
                        e.CurrentMouseActive != listener)
                    {
                        e.CurrentMouseActive.ListenMouseLeave(e);
                        isFirstMouseEnter = true;
                    }

                    if (!e.IsCanceled)
                    {
                        e.CurrentMouseActive = listener;
                        e.IsFirstMouseEnter = isFirstMouseEnter;
                        e.CurrentMouseActive.ListenMouseMove(e);
                        e.IsFirstMouseEnter = false;
                    }

                    return true;//stop
                });
                if (!foundSomeHit && e.CurrentMouseActive != null)
                {
                    e.CurrentMouseActive.ListenMouseLeave(e);
                    if (!e.IsCanceled)
                    {
                        e.CurrentMouseActive = null;
                    }
                }
            }
            SwapHitChain(hitPointChain);
            e.StopPropagation();
        }
コード例 #9
0
        void IEventPortal.PortalMouseDown(UIMouseEventArgs e)
        {
#if DEBUG
            if (this.dbugRootGraphics.dbugEnableGraphicInvalidateTrace)
            {
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("MOUSEDOWN");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
            }
            dbugMsgChainVersion = 1;
            int local_msgVersion = 1;
#endif


            HitChain hitPointChain = GetFreeHitChain();
            HitTestCoreWithPrevChainHint(hitPointChain, this._previousChain, e.X, e.Y);
            int hitCount = hitPointChain.Count;
            RenderElement hitElement = hitPointChain.TopMostElement;
            if (hitCount > 0)
            {
                //------------------------------
                //1. origin object 
                SetEventOrigin(e, hitPointChain);
                //------------------------------ 
                var prevMouseDownElement = e.PreviousMouseDown;
                IEventListener currentMouseDown = null;
                //portal                
                ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (portal) =>
                {
                    portal.PortalMouseDown(e);
                    //*****
                    currentMouseDown = e.CurrentContextElement;
                    return true;
                });
                //------------------------------
                //use events
                if (!e.CancelBubbling)
                {
                    e.CurrentContextElement = currentMouseDown = null; //clear 
                    ForEachEventListenerBubbleUp(e, hitPointChain, (listener) =>
                    {
                        currentMouseDown = listener;
                        listener.ListenMouseDown(e);
                        //------------------------------------------------------- 
                        bool cancelMouseBubbling = e.CancelBubbling;
                        if (prevMouseDownElement != null &&
                            prevMouseDownElement != listener)
                        {
                            prevMouseDownElement.ListenLostMouseFocus(e);
                            prevMouseDownElement = null;//clear
                        }
                        //------------------------------------------------------- 
                        return e.CancelBubbling || !listener.BypassAllMouseEvents;

                    });
                }

                if (prevMouseDownElement != currentMouseDown &&
                    prevMouseDownElement != null)
                {
                    prevMouseDownElement.ListenLostMouseFocus(e);
                    prevMouseDownElement = null;
                }
            }
            //---------------------------------------------------------------

#if DEBUG
            RootGraphic visualroot = this.dbugRootGraphics;
            if (visualroot.dbug_RecordHitChain)
            {
                visualroot.dbug_rootHitChainMsg.Clear();
                HitInfo hitInfo;
                for (int tt = hitPointChain.Count - 1; tt >= 0; --tt)
                {
                    hitInfo = hitPointChain.GetHitInfo(tt);
                    RenderElement ve = hitInfo.hitElement;
                    if (ve != null)
                    {
                        ve.dbug_WriteOwnerLayerInfo(visualroot, tt);
                        ve.dbug_WriteOwnerLineInfo(visualroot, tt);
                        string hit_info = new string('.', tt) + " [" + tt + "] "
                            + "(" + hitInfo.point.X + "," + hitInfo.point.Y + ") "
                            + ve.dbug_FullElementDescription();
                        visualroot.dbug_rootHitChainMsg.AddLast(new dbugLayoutMsg(ve, hit_info));
                    }
                }
            }
#endif
            SwapHitChain(hitPointChain);
            e.StopPropagation();
#if DEBUG
            if (local_msgVersion != dbugMsgChainVersion)
            {
                return;
            }
            visualroot.dbugHitTracker.Write("stop-mousedown");
            visualroot.dbugHitTracker.Play = false;
#endif
        }