コード例 #1
0
ファイル: Draggable.razor.cs プロジェクト: sd37/BlazorTest
 protected void OnDragEnd(UIDragEventArgs args)
 {
     Console.WriteLine($"End");
     isBeingDragged  = false;
     isUnderDragItem = false;
     DragEnd?.Invoke();
 }
コード例 #2
0
        public override Selection MoveByKey(KeyEventArgs args)
        {
            if (args.Shift)
            {
                var newEnd = DragEnd.MoveByKey(new KeyEventArgs(args.KeyCode & ~Keys.ShiftKey)) as InsertionPoint;
                if (newEnd == null)
                {
                    return(null);
                }
                if (Anchor.SameLocation(newEnd))
                {
                    return(Anchor);
                }
                return(new RangeSelection(Anchor, newEnd));
            }
            switch (args.KeyCode)
            {
            case Keys.Left:
                return(Start);

            case Keys.Right:
                return(End);
            }
            return(base.MoveByKey(args));
        }
コード例 #3
0
 /// <summary>
 /// Handler para this.MouseDown
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MDown(object sender, MouseEventArgs e)
 {
     // Aqui invocamos nossos eventos custom para escapar da estrutura imposta pela framework
     // para checar o andamento de uma operação drag & drop
     if (DragStart != null)
     {
         DragStart.Invoke(this, e);
     }
     this.DoDragDrop(this.Tarefa, DragDropEffects.Move);
     if (DragEnd != null)
     {
         DragEnd.Invoke(this, e);
     }
 }
コード例 #4
0
        private void dragField_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                DragStart?.Invoke(this, EventArgs.Empty);
                DragDropEffects ef = DragDrop.DoDragDrop(this, Id + "\n" + BaseString + "\n" + TranslatedString, DragDropEffects.Move);
                DragEnd?.Invoke(this, EventArgs.Empty);

                if (ef == DragDropEffects.None)
                {
                    // no drop happened
                }
                else
                {
                    // drop happened
                }
            }
        }
コード例 #5
0
        private void Hook_EventReceived(WinEventEventArgs args)
        {
            try
            {
                switch (args.Event)
                {
                case WinEvent.EVENT_SYSTEM_MOVESIZESTART:
                    if (args.Window.Equals(Window))
                    {
                        IsDragging = true;
                        DragBegin?.Invoke(this, new EventArgs());
                    }
                    break;

                case WinEvent.EVENT_SYSTEM_MOVESIZEEND:
                    if (args.Window.Equals(Window))
                    {
                        OnWindowMoved();
                        DragEnd?.Invoke(this, new EventArgs());
                        IsDragging = false;
                    }
                    break;

                case WinEvent.EVENT_OBJECT_LOCATIONCHANGE:
                case WinEvent.EVENT_SYSTEM_FOREGROUND:
                    if (!IsDragging)
                    {
                        OnWindowMoved();
                    }
                    break;

                case WinEvent.EVENT_SYSTEM_MINIMIZEEND:
                case WinEvent.EVENT_SYSTEM_MINIMIZESTART:
                    OnWindowMoved();
                    break;
                }
            }
            catch (Exception ex)
            {
                this.Exception?.Invoke(this, new UnhandledExceptionEventArgs(ex, false));
            }
        }
コード例 #6
0
        private void Update()
        {
            if (EventSystem.current && EventSystem.current.currentSelectedGameObject)
            {
                return;
            }

            NormalizedDeltaInput = Vector3.zero;
            NormalizedGroundAlignedDeltaInput = Vector3.zero;
            var isInput = IsInput;

            switch (isInput)
            {
            case true:
                var inputPos = InputPos;
                if (_lastPos.HasValue)      // Continue Drag
                {
                    var delta           = inputPos - _lastPos.Value;
                    var normalizedDelta = delta / _screenWidth;

                    Drag?.Invoke(delta);
                    DragNormalized?.Invoke(normalizedDelta);

                    NormalizedDeltaInput = normalizedDelta;
                    NormalizedGroundAlignedDeltaInput = new Vector3(NormalizedDeltaInput.x, 0, NormalizedDeltaInput.y);
                }
                else        // Start Drag
                {
                    DragStart?.Invoke(inputPos);
                }

                _lastPos = inputPos;
                break;

            // Stop Drag
            case false when _lastPos.HasValue:
                _lastPos = null;
                DragEnd?.Invoke();
                break;
            }
        }
コード例 #7
0
ファイル: SnapDragger.cs プロジェクト: alpdogan1/GamePack
        private void PartDidEndDrag(Vector2 inputPos)
        {
            var inputDistanceToDrop = InputDistanceToDrop(inputPos);

            if (inputDistanceToDrop <= _snapDistance)
            {
                _dragObject.IsDragActive = false;
                _dragObject.SetPos(_dropPoint.transform.position);
                _dragObject.SetRotation(_dropPoint.rotation);
                _dragObject.SetLocalScale(_dropPoint.localScale);

                DragEnd?.Invoke(this, _dragObject, true);
            }
            else
            {
                _dragObject.CancelDrag();
                DragEnd?.Invoke(this, _dragObject, false);
            }

            _dropPoint.gameObject.SetActive(false);
        }
コード例 #8
0
ファイル: Draggable.cs プロジェクト: notexplosive/machina
        public override void OnMouseButton(MouseButton button, Vector2 currentPosition, ButtonState buttonState)
        {
            if (button == MouseButton.Left)
            {
                if (buttonState == ButtonState.Pressed)
                {
                    if (this.hoverable.IsHovered && !IsDragging)
                    {
                        IsDragging = true;
                        this.accumulatedDragDelta = Vector2.Zero;
                        DragStart?.Invoke(currentPosition, this.accumulatedDragDelta);
                    }
                }
                else
                {
                    if (IsDragging)
                    {
                        DragEnd?.Invoke(currentPosition, this.accumulatedDragDelta);
                    }

                    IsDragging = false;
                }
            }
        }
コード例 #9
0
 /// <summary>
 /// Raises <see cref="DragEnd"/>
 /// </summary>
 private void OnDragEnd()
 {
     DragEnd?.Invoke(this, new TKGenericEventArgs <TKCustomMapPin>(_formsPin));
 }
コード例 #10
0
 public void OnEndDrag(PointerEventData eventData)
 {
     DragEnd?.Invoke();
 }
コード例 #11
0
 public void OnEndDrag(PointerEventData eventData)
 {
     _rectTransform.SetParent(_treasureGroupTransform);
     DragEnd?.Invoke(eventData, this);
 }
コード例 #12
0
        private unsafe int HookFunc(IntPtr userdata, IntPtr ev)
        {
            SDL_Event *e = (SDL_Event *)ev;

            switch (e->type)
            {
            case SDL_EventType.SDL_WINDOWEVENT:

                switch (e->window.windowEvent)
                {
                case SDL_WindowEventID.SDL_WINDOWEVENT_ENTER:
                    Mouse.MouseInWindow = true;

                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_LEAVE:
                    Mouse.MouseInWindow = false;

                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
                    Plugin.OnFocusGained();
                    // SDL_CaptureMouse(SDL_bool.SDL_TRUE);
                    //Log.Message(LogTypes.Debug, "FOCUS");
                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
                    Plugin.OnFocusLost();
                    //Log.Message(LogTypes.Debug, "NO FOCUS");
                    //SDL_CaptureMouse(SDL_bool.SDL_FALSE);

                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_TAKE_FOCUS:

                    //Log.Message(LogTypes.Debug, "TAKE FOCUS");
                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_HIT_TEST:

                    break;
                }

                break;

            case SDL_EventType.SDL_SYSWMEVENT:

                break;

            case SDL_EventType.SDL_KEYDOWN:

                if (Plugin.ProcessHotkeys((int)e->key.keysym.sym, (int)e->key.keysym.mod, true))
                {
                    Keyboard.IgnoreNextTextInput = false;
                    KeyDown?.Raise(e->key);
                }
                else
                {
                    Keyboard.IgnoreNextTextInput = true;
                }

                break;

            case SDL_EventType.SDL_KEYUP:
                //if (Plugin.ProcessHotkeys((int)e->key.keysym.sym, (int)e->key.keysym.mod, false))
                KeyUp.Raise(e->key);

                break;

            case SDL_EventType.SDL_TEXTINPUT:

                if (Keyboard.IgnoreNextTextInput)
                {
                    break;
                }

                string s = StringHelper.ReadUTF8(e->text.text);

                if (!string.IsNullOrEmpty(s))
                {
                    TextInput.Raise(s);
                }

                break;

            case SDL_EventType.SDL_MOUSEMOTION:
                Mouse.Update();
                MouseMoving.Raise();
                if (Mouse.IsDragging)
                {
                    MouseDragging.Raise();
                }

                if (Mouse.IsDragging && !_dragStarted)
                {
                    DragBegin.Raise();
                    _dragStarted = true;
                }

                break;

            case SDL_EventType.SDL_MOUSEWHEEL:
                Mouse.Update();
                bool isup = e->wheel.y > 0;

                Plugin.ProcessMouse(0, e->wheel.y);
                MouseWheel.Raise(isup);

                break;

            case SDL_EventType.SDL_MOUSEBUTTONUP:
            case SDL_EventType.SDL_MOUSEBUTTONDOWN:
                Mouse.Update();
                bool isDown = e->type == SDL_EventType.SDL_MOUSEBUTTONDOWN;

                if (_dragStarted && !isDown)
                {
                    DragEnd.Raise();
                    _dragStarted = false;
                }

                SDL_MouseButtonEvent mouse = e->button;

                switch ((uint)mouse.button)
                {
                case SDL_BUTTON_LEFT:
                    if (isDown)
                    {
                        Mouse.Begin();
                        Mouse.LButtonPressed    = true;
                        Mouse.LDropPosition     = Mouse.Position;
                        Mouse.CancelDoubleClick = false;
                        uint ticks = SDL_GetTicks();

                        if (Mouse.LastLeftButtonClickTime + Mouse.MOUSE_DELAY_DOUBLE_CLICK >= ticks)
                        {
                            Mouse.LastLeftButtonClickTime = 0;

                            MouseDoubleClickEventArgs arg = new MouseDoubleClickEventArgs(Mouse.Position.X, Mouse.Position.Y, MouseButton.Left);

                            LeftMouseDoubleClick.Raise(arg);

                            if (!arg.Result)
                            {
                                LeftMouseButtonDown.Raise();
                            }
                            else
                            {
                                Mouse.LastLeftButtonClickTime = 0xFFFF_FFFF;
                            }

                            break;
                        }

                        LeftMouseButtonDown.Raise();
                        Mouse.LastLeftButtonClickTime = Mouse.CancelDoubleClick ? 0 : ticks;
                    }
                    else
                    {
                        if (Mouse.LastLeftButtonClickTime != 0xFFFF_FFFF)
                        {
                            LeftMouseButtonUp.Raise();
                        }
                        Mouse.LButtonPressed = false;
                        Mouse.End();
                    }

                    break;

                case SDL_BUTTON_MIDDLE:
                    if (isDown)
                    {
                        Mouse.Begin();
                        Mouse.MButtonPressed    = true;
                        Mouse.MDropPosition     = Mouse.Position;
                        Mouse.CancelDoubleClick = false;
                        uint ticks = SDL_GetTicks();

                        if (Mouse.LastMidButtonClickTime + Mouse.MOUSE_DELAY_DOUBLE_CLICK >= ticks)
                        {
                            MouseDoubleClickEventArgs arg = new MouseDoubleClickEventArgs(Mouse.Position.X, Mouse.Position.Y, MouseButton.Middle);

                            MidMouseDoubleClick.Raise(arg);

                            if (!arg.Result)
                            {
                                MidMouseButtonDown.Raise();
                            }
                            Mouse.LastMidButtonClickTime = 0;

                            break;
                        }

                        Plugin.ProcessMouse(e->button.button, 0);

                        MidMouseButtonDown.Raise();
                        Mouse.LastMidButtonClickTime = Mouse.CancelDoubleClick ? 0 : ticks;
                    }
                    else
                    {
                        MidMouseButtonUp.Raise();
                        Mouse.MButtonPressed = false;
                        Mouse.End();
                    }

                    break;

                case SDL_BUTTON_RIGHT:
                    if (isDown)
                    {
                        Mouse.Begin();
                        Mouse.RButtonPressed    = true;
                        Mouse.RDropPosition     = Mouse.Position;
                        Mouse.CancelDoubleClick = false;
                        uint ticks = SDL_GetTicks();

                        if (Mouse.LastRightButtonClickTime + Mouse.MOUSE_DELAY_DOUBLE_CLICK >= ticks)
                        {
                            Mouse.LastRightButtonClickTime = 0;

                            MouseDoubleClickEventArgs arg = new MouseDoubleClickEventArgs(Mouse.Position.X, Mouse.Position.Y, MouseButton.Middle);

                            RightMouseDoubleClick.Raise(arg);

                            if (!arg.Result)
                            {
                                RightMouseButtonDown.Raise();
                            }
                            else
                            {
                                Mouse.LastRightButtonClickTime = 0xFFFF_FFFF;
                            }

                            break;
                        }

                        RightMouseButtonDown.Raise();
                        Mouse.LastRightButtonClickTime = Mouse.CancelDoubleClick ? 0 : ticks;
                    }
                    else
                    {
                        if (Mouse.LastRightButtonClickTime != 0xFFFF_FFFF)
                        {
                            RightMouseButtonUp.Raise();
                        }
                        Mouse.RButtonPressed = false;
                        Mouse.End();
                    }

                    break;

                case SDL_BUTTON_X1:
                    if (isDown)
                    {
                        Plugin.ProcessMouse(e->button.button, 0);
                    }
                    break;

                case SDL_BUTTON_X2:
                    if (isDown)
                    {
                        Plugin.ProcessMouse(e->button.button, 0);
                    }
                    break;
                }

                break;
            }
            return(1);
        }
コード例 #13
0
 /// <summary>
 /// Event handler for <see cref="DragEnd"/> event callback.
 /// </summary>
 /// <param name="eventArgs">Supplies information about an drag event that is being raised.</param>
 /// <returns>A task that represents the asynchronous operation.</returns>
 protected virtual Task OnDragEndHandler(DragEventArgs eventArgs)
 {
     return(DragEnd.InvokeAsync(eventArgs));
 }
コード例 #14
0
        public bool OnTouch(View view, MotionEvent motionEvent)
        {
            var action = motionEvent.Action;

            if (action == MotionEventActions.Down)
            {
                handler.PostDelayed(mLongPressed, 1000);
                var moveView = GetMovableView(view);
                downRawX = motionEvent.RawX;
                downRawY = motionEvent.RawY;
                dX       = moveView.GetX() - downRawX;
                dY       = moveView.GetY() - downRawY;
                DragStart?.Invoke(this, new FabDragEvent(dX, dY));
                moveView.Animate()
                .ScaleX(0.6f)
                .ScaleY(0.6f)
                .SetDuration(1000)
                .Start();
                return(true); // Consumed
            }

            if (action == MotionEventActions.Move)
            {
                handler.RemoveCallbacks(mLongPressed);
                var moveView   = GetMovableView(view);
                int viewWidth  = moveView.Width;
                int viewHeight = moveView.Height;

                View viewParent   = (View)moveView.Parent;
                int  parentWidth  = viewParent.Width;
                int  parentHeight = viewParent.Height;

                float newX = motionEvent.RawX + dX;
                newX = Java.Lang.Math.Max(0, newX);                       // Don't allow the FAB past the left hand side of the parent
                newX = Java.Lang.Math.Min(parentWidth - viewWidth, newX); // Don't allow the FAB past the right hand side of the parent

                float newY = motionEvent.RawY + dY;
                newY = Java.Lang.Math.Max(0, newY);                         // Don't allow the FAB past the top of the parent
                newY = Java.Lang.Math.Min(parentHeight - viewHeight, newY); // Don't allow the FAB past the bottom of the parent
                if (moveView.ScaleX == 1f)
                {
                    moveView.Animate()
                    .ScaleX(0.6f)
                    .ScaleY(0.6f)
                    .SetDuration(1000)
                    .Start();
                }
                moveView.Animate()
                .X(newX)
                .Y(newY)
                .SetDuration(0)
                .Start();
                Dragging?.Invoke(this, new FabDragEvent(newX + moveView.Width / 2, newY + moveView.Height / 2));
                return(true); // Consumed
            }

            if (action == MotionEventActions.Up)
            {
                handler.RemoveCallbacks(mLongPressed);
                var   moveView = GetMovableView(view);
                float upRawX   = motionEvent.RawX;
                float upRawY   = motionEvent.RawY;

                float upDX = upRawX - downRawX;
                float upDY = upRawY - downRawY;

                if (Java.Lang.Math.Abs(upDX) < CLICK_DRAG_TOLERANCE && Java.Lang.Math.Abs(upDY) < CLICK_DRAG_TOLERANCE)
                { // A click
                    moveView.Animate()
                    .ScaleX(1f)
                    .ScaleY(1f)
                    .SetDuration(1000)
                    .Start();
                    return(base.PerformClick());
                }

                // A drag
                DragEnd?.Invoke(this, new FabDragEvent(moveView.GetX() + moveView.Width / 2, moveView.GetY() + moveView.Height / 2));
                View viewParent = (View)moveView.Parent;
                moveView.Animate()
                .X(viewParent.Width - moveView.Width - 10)
                .Y(viewParent.Height - moveView.Height - 10)
                .SetDuration(1000)
                .Start();
                moveView.Animate()
                .ScaleX(1f)
                .ScaleY(1f)
                .SetDuration(1000)
                .Start();
                return(true); // Consumed
            }

            return(OnTouchEvent(motionEvent));
        }
コード例 #15
0
ファイル: GoogleMarkers.cs プロジェクト: alpozgur/google-maps
 /// <summary>
 /// Raises the <see cref="E:DragEnd"/> event.
 /// </summary>
 /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
 protected virtual void OnDragEnd(MarkerEventArgs e)
 {
     DragEnd?.Invoke(this, e);
 }
コード例 #16
0
ファイル: DragBox.cs プロジェクト: Kontort/OsuKyzer
 protected override bool OnDragEnd(DragEndEvent e)
 {
     this.FadeOut(250, Easing.OutQuint);
     DragEnd?.Invoke();
     return(true);
 }
コード例 #17
0
        //private unsafe int HookFunc(IntPtr userdata, IntPtr ev)
        public unsafe void EventHandler(ref SDL_Event e)
        {
            // SDL_Event* e = (SDL_Event*) ev;

            switch (e.type)
            {
            case SDL_EventType.SDL_AUDIODEVICEADDED:
                Console.WriteLine("AUDIO ADDED: {0}", e.adevice.which);

                break;

            case SDL_EventType.SDL_AUDIODEVICEREMOVED:
                Console.WriteLine("AUDIO REMOVED: {0}", e.adevice.which);

                break;


            case SDL_EventType.SDL_WINDOWEVENT:

                switch (e.window.windowEvent)
                {
                case SDL_WindowEventID.SDL_WINDOWEVENT_ENTER:
                    Mouse.MouseInWindow = true;

                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_LEAVE:
                    Mouse.MouseInWindow = false;

                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
                    Plugin.OnFocusGained();

                    // SDL_CaptureMouse(SDL_bool.SDL_TRUE);
                    //Log.Message(LogTypes.Debug, "FOCUS");
                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
                    Plugin.OnFocusLost();
                    //Log.Message(LogTypes.Debug, "NO FOCUS");
                    //SDL_CaptureMouse(SDL_bool.SDL_FALSE);

                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_TAKE_FOCUS:

                    //Log.Message(LogTypes.Debug, "TAKE FOCUS");
                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_HIT_TEST:

                    break;
                }

                break;

            case SDL_EventType.SDL_SYSWMEVENT:

                break;

            case SDL_EventType.SDL_KEYDOWN:

                if (Plugin.ProcessHotkeys((int)e.key.keysym.sym, (int)e.key.keysym.mod, true))
                {
                    _ignoreNextTextInput = false;
                    Engine.SceneManager.CurrentScene.OnKeyDown(e.key);

                    KeyDown?.Raise(e.key);
                }
                else
                {
                    _ignoreNextTextInput = true;
                }

                break;

            case SDL_EventType.SDL_KEYUP:

                Engine.SceneManager.CurrentScene.OnKeyUp(e.key);
                KeyUp.Raise(e.key);

                break;

            case SDL_EventType.SDL_TEXTINPUT:

                if (_ignoreNextTextInput)
                    break;

                fixed(SDL_Event *ev = &e)
                {
                    string s = StringHelper.ReadUTF8(ev->text.text);

                    if (!string.IsNullOrEmpty(s))
                    {
                        Engine.SceneManager.CurrentScene.OnTextInput(s);
                        TextInput.Raise(s);
                    }
                }

                break;

            case SDL_EventType.SDL_MOUSEMOTION:
                Mouse.Update();

                if (Mouse.IsDragging)
                {
                    Engine.SceneManager.CurrentScene.OnMouseDragging();
                    MouseDragging.Raise();
                }

                if (Mouse.IsDragging && !_dragStarted)
                {
                    DragBegin.Raise();
                    _dragStarted = true;
                }

                break;

            case SDL_EventType.SDL_MOUSEWHEEL:
                Mouse.Update();
                bool isup = e.wheel.y > 0;

                Plugin.ProcessMouse(0, e.wheel.y);
                Engine.SceneManager.CurrentScene.OnMouseWheel(isup);
                MouseWheel.Raise(isup);

                break;

            case SDL_EventType.SDL_MOUSEBUTTONUP:
            case SDL_EventType.SDL_MOUSEBUTTONDOWN:
                Mouse.Update();
                bool isDown = e.type == SDL_EventType.SDL_MOUSEBUTTONDOWN;

                if (_dragStarted && !isDown)
                {
                    DragEnd.Raise();
                    _dragStarted = false;
                }

                SDL_MouseButtonEvent mouse = e.button;

                switch ((uint)mouse.button)
                {
                case SDL_BUTTON_LEFT:

                    if (isDown)
                    {
                        Mouse.Begin();
                        Mouse.LButtonPressed    = true;
                        Mouse.LDropPosition     = Mouse.Position;
                        Mouse.CancelDoubleClick = false;
                        uint ticks = SDL_GetTicks();

                        if (Mouse.LastLeftButtonClickTime + Mouse.MOUSE_DELAY_DOUBLE_CLICK >= ticks)
                        {
                            Mouse.LastLeftButtonClickTime = 0;

                            var res = Engine.SceneManager.CurrentScene.OnLeftMouseDoubleClick();

                            MouseDoubleClickEventArgs arg = new MouseDoubleClickEventArgs(Mouse.Position.X, Mouse.Position.Y, MouseButton.Left);

                            LeftMouseDoubleClick.Raise(arg);

                            if (!arg.Result && !res)
                            {
                                Engine.SceneManager.CurrentScene.OnLeftMouseDown();
                                LeftMouseButtonDown.Raise();
                            }
                            else
                            {
                                Mouse.LastLeftButtonClickTime = 0xFFFF_FFFF;
                            }

                            break;
                        }

                        Engine.SceneManager.CurrentScene.OnLeftMouseDown();
                        LeftMouseButtonDown.Raise();
                        Mouse.LastLeftButtonClickTime = Mouse.CancelDoubleClick ? 0 : ticks;
                    }
                    else
                    {
                        if (Mouse.LastLeftButtonClickTime != 0xFFFF_FFFF)
                        {
                            Engine.SceneManager.CurrentScene.OnLeftMouseUp();
                            LeftMouseButtonUp.Raise();
                        }
                        Mouse.LButtonPressed = false;
                        Mouse.End();

                        Mouse.LastClickPosition = Mouse.Position;
                    }

                    break;

                case SDL_BUTTON_MIDDLE:

                    if (isDown)
                    {
                        Mouse.Begin();
                        Mouse.MButtonPressed    = true;
                        Mouse.MDropPosition     = Mouse.Position;
                        Mouse.CancelDoubleClick = false;
                        uint ticks = SDL_GetTicks();

                        if (Mouse.LastMidButtonClickTime + Mouse.MOUSE_DELAY_DOUBLE_CLICK >= ticks)
                        {
                            Mouse.LastMidButtonClickTime = 0;
                            var res = Engine.SceneManager.CurrentScene.OnMiddleMouseDoubleClick();

                            MouseDoubleClickEventArgs arg = new MouseDoubleClickEventArgs(Mouse.Position.X, Mouse.Position.Y, MouseButton.Middle);

                            MidMouseDoubleClick.Raise(arg);

                            if (!arg.Result && !res)
                            {
                                Engine.SceneManager.CurrentScene.OnMiddleMouseDown();

                                MidMouseButtonDown.Raise();
                            }

                            break;
                        }

                        Plugin.ProcessMouse(e.button.button, 0);

                        Engine.SceneManager.CurrentScene.OnMiddleMouseDown();
                        MidMouseButtonDown.Raise();
                        Mouse.LastMidButtonClickTime = Mouse.CancelDoubleClick ? 0 : ticks;
                    }
                    else
                    {
                        MidMouseButtonUp.Raise();
                        Mouse.MButtonPressed = false;
                        Mouse.End();
                    }

                    break;

                case SDL_BUTTON_RIGHT:

                    if (isDown)
                    {
                        Mouse.Begin();
                        Mouse.RButtonPressed    = true;
                        Mouse.RDropPosition     = Mouse.Position;
                        Mouse.CancelDoubleClick = false;
                        uint ticks = SDL_GetTicks();

                        if (Mouse.LastRightButtonClickTime + Mouse.MOUSE_DELAY_DOUBLE_CLICK >= ticks)
                        {
                            Mouse.LastRightButtonClickTime = 0;

                            var res = Engine.SceneManager.CurrentScene.OnRightMouseDoubleClick();

                            MouseDoubleClickEventArgs arg = new MouseDoubleClickEventArgs(Mouse.Position.X, Mouse.Position.Y, MouseButton.Right);

                            RightMouseDoubleClick.Raise(arg);

                            if (!arg.Result && !res)
                            {
                                Engine.SceneManager.CurrentScene.OnRightMouseDown();
                                RightMouseButtonDown.Raise();
                            }
                            else
                            {
                                Mouse.LastRightButtonClickTime = 0xFFFF_FFFF;
                            }

                            break;
                        }

                        Engine.SceneManager.CurrentScene.OnRightMouseDown();
                        RightMouseButtonDown.Raise();
                        Mouse.LastRightButtonClickTime = Mouse.CancelDoubleClick ? 0 : ticks;
                    }
                    else
                    {
                        if (Mouse.LastRightButtonClickTime != 0xFFFF_FFFF)
                        {
                            Engine.SceneManager.CurrentScene.OnRightMouseUp();
                            RightMouseButtonUp.Raise();
                        }
                        Mouse.RButtonPressed = false;
                        Mouse.End();
                    }

                    break;

                case SDL_BUTTON_X1:

                    if (isDown)
                    {
                        Plugin.ProcessMouse(e.button.button, 0);
                    }

                    break;

                case SDL_BUTTON_X2:

                    if (isDown)
                    {
                        Plugin.ProcessMouse(e.button.button, 0);
                    }

                    break;
                }

                break;
            }
        }
コード例 #18
0
        private unsafe int HookFunc(IntPtr userdata, IntPtr ev)
        {
            SDL_Event *e = (SDL_Event *)ev;

            switch (e->type)
            {
            case SDL_EventType.SDL_WINDOWEVENT:
                switch (e->window.windowEvent)
                {
                case SDL_WindowEventID.SDL_WINDOWEVENT_ENTER:
                    Mouse.MouseInWindow = true;
                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_LEAVE:
                    Mouse.MouseInWindow = false;
                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
                    // SDL_CaptureMouse(SDL_bool.SDL_TRUE);
                    //Log.Message(LogTypes.Debug, "FOCUS");
                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
                    //Log.Message(LogTypes.Debug, "NO FOCUS");
                    //SDL_CaptureMouse(SDL_bool.SDL_FALSE);

                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_TAKE_FOCUS:
                    //Log.Message(LogTypes.Debug, "TAKE FOCUS");
                    break;

                case SDL_WindowEventID.SDL_WINDOWEVENT_HIT_TEST:

                    break;
                }

                break;

            case SDL_EventType.SDL_SYSWMEVENT:
                break;

            case SDL_EventType.SDL_KEYDOWN:
                KeyDown?.Raise(e->key);

                break;

            case SDL_EventType.SDL_KEYUP:
                KeyUp.Raise(e->key);

                break;

            case SDL_EventType.SDL_TEXTINPUT:
                string s = StringHelper.ReadUTF8(e->text.text);

                if (!string.IsNullOrEmpty(s))
                {
                    TextInput.Raise(s);
                }

                break;

            case SDL_EventType.SDL_MOUSEMOTION:
                Mouse.Update();
                if (Mouse.IsDragging)
                {
                    MouseDragging.Raise();
                }

                if (Mouse.IsDragging && !_dragStarted)
                {
                    DragBegin.Raise();
                    _dragStarted = true;
                }

                break;

            case SDL_EventType.SDL_MOUSEWHEEL:
                Mouse.Update();
                bool isup = e->wheel.y > 0;
                MouseWheel.Raise(isup);

                break;

            case SDL_EventType.SDL_MOUSEBUTTONUP:
            case SDL_EventType.SDL_MOUSEBUTTONDOWN:
                Mouse.Update();
                bool isDown = e->type == SDL_EventType.SDL_MOUSEBUTTONDOWN;

                if (_dragStarted && !isDown)
                {
                    DragEnd.Raise();
                    _dragStarted = false;
                }

                SDL_MouseButtonEvent mouse = e->button;

                switch ((uint)mouse.button)
                {
                case SDL_BUTTON_LEFT:
                    Mouse.LButtonPressed = isDown;

                    if (isDown)
                    {
                        Mouse.Begin();
                        Mouse.LDropPosition     = Mouse.Position;
                        Mouse.CancelDoubleClick = false;
                        uint ticks = SDL_GetTicks();

                        if (Mouse.LastLeftButtonClickTime + Mouse.MOUSE_DELAY_DOUBLE_CLICK >= ticks)
                        {
                            Mouse.LastLeftButtonClickTime = 0;

                            if (LeftMouseDoubleClick != null && !LeftMouseDoubleClick.Invoke())
                            {
                                LeftMouseButtonDown.Raise();
                            }
                            else
                            {
                                Mouse.LastLeftButtonClickTime = 0xFFFF_FFFF;
                            }

                            break;
                        }

                        LeftMouseButtonDown.Raise();
                        Mouse.LastLeftButtonClickTime = Mouse.CancelDoubleClick ? 0 : ticks;
                    }
                    else
                    {
                        if (Mouse.LastLeftButtonClickTime != 0xFFFF_FFFF)
                        {
                            LeftMouseButtonUp.Raise();
                        }
                        Mouse.End();
                    }

                    break;

                case SDL_BUTTON_MIDDLE:
                    Mouse.MButtonPressed = isDown;

                    if (isDown)
                    {
                        Mouse.Begin();
                        Mouse.MDropPosition     = Mouse.Position;
                        Mouse.CancelDoubleClick = false;
                        uint ticks = SDL_GetTicks();

                        if (Mouse.LastMidButtonClickTime + Mouse.MOUSE_DELAY_DOUBLE_CLICK >= ticks)
                        {
                            if (MidMouseDoubleClick != null && !MidMouseDoubleClick.Invoke())
                            {
                                MidMouseButtonDown.Raise();
                            }
                            Mouse.LastMidButtonClickTime = 0;

                            break;
                        }

                        MidMouseButtonDown.Raise();
                        Mouse.LastMidButtonClickTime = Mouse.CancelDoubleClick ? 0 : ticks;
                    }
                    else
                    {
                        MidMouseButtonUp.Raise();
                        Mouse.End();
                    }

                    break;

                case SDL_BUTTON_RIGHT:
                    Mouse.RButtonPressed = isDown;

                    if (isDown)
                    {
                        Mouse.Begin();
                        Mouse.RDropPosition     = Mouse.Position;
                        Mouse.CancelDoubleClick = false;
                        uint ticks = SDL_GetTicks();

                        if (Mouse.LastRightButtonClickTime + Mouse.MOUSE_DELAY_DOUBLE_CLICK >= ticks)
                        {
                            Mouse.LastRightButtonClickTime = 0;

                            if (RightMouseDoubleClick != null && !RightMouseDoubleClick.Invoke())
                            {
                                RightMouseButtonDown.Raise();
                            }
                            else
                            {
                                Mouse.LastRightButtonClickTime = 0xFFFF_FFFF;
                            }

                            break;
                        }

                        RightMouseButtonDown.Raise();
                        Mouse.LastRightButtonClickTime = Mouse.CancelDoubleClick ? 0 : ticks;
                    }
                    else
                    {
                        if (Mouse.LastRightButtonClickTime != 0xFFFF_FFFF)
                        {
                            RightMouseButtonUp.Raise();
                        }
                        Mouse.End();
                    }

                    break;

                case SDL_BUTTON_X1:

                    break;

                case SDL_BUTTON_X2:

                    break;
                }

                break;
            }

            //switch (e->type)
            //{
            //    // KEYBOARD
            //    case SDL_EventType.SDL_KEYDOWN:
            //        OnKeyDown(new InputKeyboardEvent(KeyboardEvent.Down, e->key.keysym.sym, 0, e->key.keysym.mod));

            //        break;
            //    case SDL_EventType.SDL_KEYUP:
            //        OnKeyUp(new InputKeyboardEvent(KeyboardEvent.Up, e->key.keysym.sym, 0, e->key.keysym.mod));

            //        break;
            //    case SDL_EventType.SDL_TEXTINPUT:
            //        string s = StringHelper.ReadUTF8(e->text.text);

            //        if (!string.IsNullOrEmpty(s))
            //            OnTextInput(new InputKeyboardEvent(KeyboardEvent.TextInput, SDL_Keycode.SDLK_UNKNOWN, 0, SDL_Keymod.KMOD_NONE) {KeyChar = s});

            //        break;

            //    // MOUSE
            //    case SDL_EventType.SDL_MOUSEBUTTONDOWN:
            //        MouseDown.Raise();
            //        OnMouseDown(new InputMouseEvent(MouseEvent.Down, CovertMouseButton(e->button.button), e->button.clicks, e->button.x, e->button.y, 0, SDL_Keymod.KMOD_NONE));

            //        break;
            //    case SDL_EventType.SDL_MOUSEBUTTONUP:
            //        MouseUp.Raise();
            //        OnMouseUp(new InputMouseEvent(MouseEvent.Up, CovertMouseButton(e->button.button), e->button.clicks, e->button.x, e->button.y, 0, SDL_Keymod.KMOD_NONE));

            //        switch (e->button.clicks)
            //        {
            //            case 1:
            //                MouseClick.Raise();
            //                break;
            //            case 2:
            //                MouseDoubleClick.Raise();
            //                break;
            //        }

            //        break;
            //    case SDL_EventType.SDL_MOUSEMOTION:
            //        MouseMove.Raise();
            //        OnMouseMove(new InputMouseEvent(MouseEvent.Move, CovertMouseButton(e->button.button), 0, e->motion.x, e->motion.y, 0, SDL_Keymod.KMOD_NONE));

            //        break;
            //    case SDL_EventType.SDL_MOUSEWHEEL:
            //        OnMouseWheel(new InputMouseEvent(MouseEvent.WheelScroll, MouseButton.Middle, 0, e->wheel.x, e->wheel.y, 0, SDL_Keymod.KMOD_NONE));

            //        break;
            //}

            return(1);
        }
コード例 #19
0
            private void SomeTextCodeInit(Point p, string title, UIElement element)
            {
                this.Background = Brushes.WhiteSmoke;
                this.BorderThickness = new Thickness(2);
                this.BorderBrush = Brushes.GhostWhite;
                this.CornerRadius = new CornerRadius(2);

                mainpanel = new StackPanel();
                bclose = new Button();
                bedit = new Button();
                toppanel = new DockPanel();
                titleblock = new TextBlock();

                mainpanel.Orientation = Orientation.Vertical;
                toppanel.Background = Brushes.AliceBlue;
                toppanel.Name = "DragnDropPanel";

                StackPanel buttonPanel = new StackPanel();
                buttonPanel.HorizontalAlignment = HorizontalAlignment.Right;
                buttonPanel.Orientation = Orientation.Horizontal;

                bclose.Content = "x";
                bclose.Click += new RoutedEventHandler(bclose_Click);
                bclose.Margin = new Thickness(2);

                bedit.Click += new RoutedEventHandler(bedit_Click);
                bedit.Margin = new Thickness(2);

                buttonPanel.Children.Add(bedit);
                buttonPanel.Children.Add(bclose);

                titleblock.Text = title;
                titleblock.HorizontalAlignment = HorizontalAlignment.Left;

                toppanel.Children.Add(titleblock);
                toppanel.Children.Add(buttonPanel);

                mainpanel.Children.Add(toppanel);
                mainpanel.Children.Add(element);
                this.Child = mainpanel;
                Canvas.SetLeft(this, p.X); Canvas.SetTop(this, p.Y);

                ITheoryElement theoryElement = GetTheoryElement();
                visualinfo = new EVisualInfo();
                visualinfo.Updated += new Protsenko.TheoryEditor.Core.Events.Updated(visualinfo_Updated);

                toppanel.MouseLeftButtonDown += new MouseButtonEventHandler(toppanel_MouseLeftButtonDown);
                toppanel.MouseLeftButtonUp += new MouseButtonEventHandler(toppanel_MouseLeftButtonUp);

                DragStart += new DragStart(TheoryVisualDecorator_DragStart);
                DragEnd += new DragEnd(TheoryVisualDecorator_DragEnd);
                WantsToBeEdited += new Protsenko.TheoryEditor.Core.Events.Updated(TheoryVisualDecorator_WantsToBeEdited);
                LanguageResource.Updated +=new Protsenko.TheoryEditor.Core.Events.Updated(LanguageResource_Updated);
                LanguageResource_Updated(null);
            }