1

これは私のコードです:

    private void MoveCursor(int x, int y)
    {
        // Set the Current cursor, move the cursor's Position,
        // and set its clipping rectangle to the form. 

        System.Windows.Forms.Cursor cursorMouse = new System.Windows.Forms.Cursor(System.Windows.Forms.Cursor.Current.Handle);
        cursorMouse.Position = new System.Drawing.Point(x, y);
        System.Windows.Forms.Cursor.Clip = new System.Drawing.Rectangle(cursorMouse.Position, cursorMouse.Size);
    }

これは私のコンソールが言うことです:

 Error  11  Member 'System.Windows.Forms.Cursor.Position.get' cannot be accessed with an instance reference; qualify it with a type name instead    F:\Win8\Kinect\InterfaceController\celmaibun\KinectToolbox\KinectToolbox\GesturesViewer\MainWindow.xaml.cs  1314    13  NkGesturesViewer
 Error  12  Member 'System.Windows.Forms.Cursor.Position.get' cannot be accessed with an instance reference; qualify it with a type name instead    F:\Win8\Kinect\InterfaceController\celmaibun\KinectToolbox\KinectToolbox\GesturesViewer\MainWindow.xaml.cs  1315    77  NkGesturesViewer

今、私はc#の初心者で、JavaとAndroidに慣れています。友人はそれがインスタンスと関係があると私に言いました。しかし、私は何をすべきか正確にはわかりません。

4

3 に答える 3

8

あなたはおそらくあなたの答えをすでに見つけたか、回避策を見つけましたが、私はこれと同じ問題を抱えていたので、私が発見したものを投稿すると思いました。

System.Windows.Forms.DataVisualization.Chartingへの参照を追加すると、エラーが表示されました。その参照でカーソルが機能する方法は通常とは異なり、通常のCursor.Positionをオーバーライドしているようです。

私の場合、「Cursor.Position」を「MousePosition」に置き換えるだけの簡単なものでした。

于 2013-08-30T21:27:54.520 に答える
1

このコードをお勧めします

var pc = new PointConverter();
var pt = new Point();
pt = (Point)pc.ConvertFromString(string.Format("{0}, {1}",x,y));
cursorMouse.Position = pt;

リンク: http: //msdn.microsoft.com/en-us/library/system.drawing.pointconverter.aspx

于 2013-03-25T16:28:47.260 に答える
0

問題が何であるかを知りました。Kinectは画面のパラメーターを0から表示幅まで送信せず、本体の左側に-、右側に+があるため、関数を作成する必要がありました。マウスを移動するコアクトポイントを計算します。

于 2013-09-02T07:01:59.870 に答える