コード例 #1
0
        private void TryHoldClick(IntPtr wParam, IntPtr lParam)
        {
            MSLLHOOKSTRUCT mouseHookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
            string         strEnd;

            switch ((int)wParam)
            {
            case WM_LBUTTONUP:
                strEnd = "[L]";
                break;

            case WM_RBUTTONUP:
                strEnd = "[R]";
                break;

            case WM_MBUTTONUP:
                strEnd = "[M]";
                break;

            case WM_XBUTTONUP:
                if (mouseHookStruct.mouseData >> 16 == 1)     // X1(戻るボタン)
                {
                    strEnd = "[X1]";
                }
                else      // X2(進むボタン)
                {
                    strEnd = "[X2]";
                }
                break;

            case WM_MOUSEWHEEL:
                if ((short)((mouseHookStruct.mouseData >> 16) & 0xffff) > 0)      // Wheel Up
                {
                    if (!stroke.EndsWith("[WU]"))
                    {
                        stroke = stroke + "[WU]";
                        StrokeChanged?.Invoke(this, new EventArgs());
                    }
                    strEnd = "[WU]";
                }
                else      // Wheel Down
                {
                    if (!stroke.EndsWith("[WD]"))
                    {
                        stroke = stroke + "[WD]";
                        StrokeChanged?.Invoke(this, new EventArgs());
                    }
                    strEnd = "[WD]";
                }
                break;

            default:
                return;
            }

            if (stroke.EndsWith(strEnd))
            {
                HoldClick?.Invoke(this, new EventArgs());
            }
        }
コード例 #2
0
ファイル: TouchInput.cs プロジェクト: nectx/TouchIME
        private void OnTouchMoved(object sender, RawTouchEventArgs e)
        {
            TouchStroke stroke = CurrentStroke;

            if (stroke != null)
            {
                stroke.AddPoint(e.Location);
                StrokeChanged?.Invoke(this, EventArgs.Empty);
            }
        }
コード例 #3
0
        private void Thumb_PointerReleased(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            var pointer = e.GetCurrentPoint(_container);

            m_pointerPositions.Remove(pointer.PointerId);

            ((UIElement)sender).ReleasePointerCapture(e.Pointer);

            _value = _current;
            StrokeChanged?.Invoke(this, EventArgs.Empty);

            UpdateThumb(pointer.Position, true, false);
            e.Handled = true;
        }
コード例 #4
0
        private IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (isActive && nCode >= HC_ACTION)
            {
                //Debug.WriteLine( "WMessage in HookProc  wParam:" + ( (int)wParam ).ToString() + "  lParam:" + ( (int)lParam ).ToString()  );

                // マウス移動時
                if ((int)wParam == WM_MOUSEMOVE)
                {
                    // 軌道のチェック
                    if (EnableDragGesture)
                    {
                        this.Test();
                    }

                    // 始動ボタンが離されていないかチェック
                    if (GetStartingButtonState() >= 0)
                    {
                        End();
                    }
                }

                // 始動ボタンが離されたらジェスチャ終了
                else if (IsWMParamMatchesStartingButtonUp(wParam, lParam))
                {
                    End();
                }

                else if (AllowHoldClick)
                {
                    // クリックストローク取得 (Mouse Button Down Message)
                    string cs = GetClickStroke(wParam, lParam);
                    if (cs.Length > 0 && !stroke.EndsWith(cs))  // 2重押下の防止
                    {
                        stroke = stroke + cs;
                        ResetDirection();
                        StrokeChanged?.Invoke(this, new EventArgs());
                    }

                    // ホールドクリック実行 (Mouse Button Up Message, Wheel Up Down Message)
                    if (cs.Length == 0 && (int)wParam != WMessageStartingButtonUp)
                    {
                        TryHoldClick(wParam, lParam);
                    }
                }
            }

            return(CallNextHookEx(hHook, nCode, wParam, lParam));
        }
コード例 #5
0
        /// <summary>
        /// マウスジェスチャの判定
        /// </summary>
        public void Test()
        {
            //有効なときだけ判定する。
            if (isActive)
            {
                double ox = oldPos.X, oy = oldPos.Y;
                Arrow  arrow = Arrow.None;

                // 現在のカーソル位置(スクリーン座標系)を取得
                Point pos = GetCursorPos();

                // 情報を入れ替えておく
                oldPos = pos;

                //移動量を判定して縦横どっちに動くかを判定
                if (Math.Abs(ox - pos.X) > Math.Abs(oy - pos.Y))
                {
                    if (ox > pos.X)
                    {
                        directionInfo[(int)Arrow.Left].Length += ox - pos.X;
                        directionInfo[(int)Arrow.Right].Length = 0;
                        arrow = Arrow.Left;
                    }
                    else if (pos.X > ox)
                    {
                        directionInfo[(int)Arrow.Right].Length += pos.X - ox;
                        directionInfo[(int)Arrow.Left].Length   = 0;
                        arrow = Arrow.Right;
                    }
                }
                else
                {
                    if (oy > pos.Y)
                    {
                        directionInfo[(int)Arrow.Up].Length  += oy - pos.Y;
                        directionInfo[(int)Arrow.Down].Length = 0;
                        arrow = Arrow.Up;
                    }
                    else if (pos.Y > oy)
                    {
                        directionInfo[(int)Arrow.Down].Length += pos.Y - oy;
                        directionInfo[(int)Arrow.Up].Length    = 0;
                        arrow = Arrow.Down;
                    }
                }

                //移動を検知したとき
                if (arrow != Arrow.None)
                {
                    if (directionInfo[(int)arrow].Enable && directionInfo[(int)arrow].Length > Range)
                    {
                        ResetDirection();

                        //同じ向きが2度入力されないようにする。
                        directionInfo[(int)arrow].Enable = false;

                        stroke += ArrowToString(arrow);
                        Debug.WriteLine("MouseGesture Stroke: " + stroke);
                        StrokeChanged?.Invoke(this, new EventArgs());
                    }
                }
            }
        }
コード例 #6
0
 private void Stroke()
 {
     StrokeChanged?.Invoke(StrokeStyle);
 }