0

我正在制作一个 cosmos os 项目并想做一个鼠标光标,但它在运行前继续崩溃

        canvas = FullScreenCanvas.GetFullScreenCanvas();
        canvas.Clear(System.Drawing.Color.Aqua);
        Sys.MouseManager.ScreenWidth = (uint)canvas.Mode.Columns;
        Sys.MouseManager.ScreenHeight = (uint)canvas.Mode.Rows;
        Pen pen = new Pen(System.Drawing.Color.Red);
        uint X = Sys.MouseManager.X;
        uint Y = Sys.MouseManager.Y;
        canvas.DrawLine(pen, X, Y, X + 5, Y);
        canvas.DrawLine(pen, X, Y, X, Y - 5);
        canvas.DrawLine(pen, X, Y, X + 5, Y - 5);
    }

我希望它能够运行并有一个光标,但它在运行之前就崩溃了

4

1 回答 1

0

问题不在于鼠标管理器。

我不知道是什么困扰着 Cosmos,但这就是你解决它的方法:

        try
        {
            Canvas canvas = FullScreenCanvas.GetFullScreenCanvas();
            Sys.MouseManager.ScreenWidth = (uint)canvas.Mode.Columns;
            Sys.MouseManager.ScreenHeight = (uint)canvas.Mode.Rows;
            Pen pen = new Pen(Color.Red);
            int X = (int)Sys.MouseManager.X;
            int Y = (int)Sys.MouseManager.Y;
            canvas.DrawLine(pen, X, Y, X + 5, Y);
            canvas.DrawLine(pen, X, Y, X, Y - 5);
            canvas.DrawLine(pen, X, Y, X + 5, Y - 5);
        }
        catch (Exception ex)
        {
            System.Console.WriteLine(ex.Message);
        }

希望这对你有用 : )

于 2019-12-22T18:29:49.197 回答