0

i was making a cosmos os project and want to make a mouse cursor but it continue crashing before run

        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);
    }

i expect it to run and have a cursor but it crash before it run

1 Answers1

0

The issue isn't with the mouse manager.

I don't know what's bothering Cosmos but this is how you fix it:

        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);
        }

hope it works for you : )

Yasen
  • 4,241
  • 1
  • 16
  • 25