Exemplo n.º 1
0
        public void MouseMove(MouseEventArgs e)
        {
            LastMouseEventArgs = e;
            if (Capturer != null)
                Capturer.OnMouseMove(e);
            // ReSharper disable TooWideLocalVariableScope
            float d;
            // ReSharper restore TooWideLocalVariableScope
            var und = new HashSet<IReactiveShape>(Reactives.Where(s => s.IsSenseMouse).Where(s =>
                {
                    d = s.DistanceTo2(e.Location);
                    Debug.WriteLine(d);
                    return (d < 0 && s.InternalDistanceSense2 >= -d) || (d >= 0 && s.ExternalDistanceSense2 >= d);
                }));
            foreach (var item in und.Except(SenseCursor))
                item.OnMouseSenseEnter(e);
            foreach (var item in SenseCursor.Except(und))
                item.OnMouseSenseLeave();
            foreach (var item in und)
                item.OnMouseSense(e);
            SenseCursor = und;

            und = new HashSet<IReactiveShape>(Reactives.Where(s => s.Contains(e.Location)));
            var sdea = new SimpleDragEventArgs(Capturer, e.X, e.Y);

            foreach (var item in UnderCursor.Except(und))
                item.OnMouseLeave();
            if (Capturer != null && Capturer.IsDrag)
                foreach (var item in UnderCursor.Except(und)
                        .Where(s => s.AllowDrop)
                        .Where(s => s != Capturer))
                    item.OnDragLeave(sdea);

            foreach (var item in und.Except(UnderCursor))
                item.OnMouseEnter();
            if (Capturer != null && Capturer.IsDrag)
                foreach (var item in und.Except(UnderCursor)
                    .Where(s => s.AllowDrop)
                    .Where(s => s != Capturer))
                    item.OnDragEnter(sdea);


            foreach (var item in und)
                item.OnMouseMove(e);
            if (Capturer != null && Capturer.IsDrag)
                foreach (var item in und
                    .Where(s => s.AllowDrop)
                    .Where(s => s != Capturer))
                    item.OnDragOver(sdea);

            UnderCursor = und;
        }
Exemplo n.º 2
0
        public void MouseUp(MouseEventArgs e)
        {
            LastMouseEventArgs = e;
            if (Capturer != null)
            {
                var sdea = new SimpleDragEventArgs(Capturer, e.X, e.Y);
                foreach (var item in UnderCursor
                    .Where(s => s.AllowDrop)
                    .Where(s => s != Capturer))
                {
                    item.OnDragDrop(sdea);
                    if (sdea.Handled) break;
                }

                if (clickTimer.ElapsedMilliseconds <= SystemInformation.DoubleClickTime)
                    ++countClicks;
                else
                    countClicks = 1;
                var sizeClicks = new Size(Math.Abs(firstMouseDown.X - e.Location.X),
                                          Math.Abs(firstMouseDown.Y - e.Location.Y));
                if (countClicks > 1 && (SystemInformation.DoubleClickSize.Width < sizeClicks.Width
                                        || SystemInformation.DoubleClickSize.Height < sizeClicks.Height))
                    countClicks = 1;
                Capturer.OnMouseUp(e);
                if (Capturer.Contains(e.Location))
                    if (countClicks == 2)
                    {
                        Capturer.OnMouseDoubleClick(e);
                        countClicks = 0;
                        clickTimer.Stop();
                    }
                    else
                        Capturer.OnMouseClick(e);
                Capturer = null;
            }
        }
Exemplo n.º 3
0
 public void OnDragCancel(SimpleDragEventArgs e)
 {
     if (DragCancel != null)
         DragCancel(Owner, e);
 }
Exemplo n.º 4
0
 public virtual void OnDragDrop(SimpleDragEventArgs e)
 {
     if (DragDrop != null)
         DragDrop(Owner, e);
 }
Exemplo n.º 5
0
 public void OnDragOver(SimpleDragEventArgs e)
 {
     if (DragOver != null)
         DragOver(Owner, e);
 }
Exemplo n.º 6
0
 public virtual void OnDragLeave(SimpleDragEventArgs e)
 {
     if (DragLeave != null)
         DragLeave(Owner, e);
 }
Exemplo n.º 7
0
 public virtual void OnDragEnter(SimpleDragEventArgs e)
 {
     if (DragEnter != null)
         DragEnter(Owner, e);
 }