Change Mouse Cursor

1521
2
Jump to solution
04-04-2022 12:24 AM
KhaledAliMoh
New Contributor II

I want to change the cursor pointer when user selects a tool, I got the sample but I don't know what  MapExploration.Resource1.red_cursor is ? I don't know if it is a file, file path or even an object. I appreciate if anyone gives me an explanation or a full example without shortcuts.

Here is the code in the sample:

internal class CustomMapTool : MapTool
{
    public CustomMapTool()
    {
        IsSketchTool = true;
        SketchType = SketchGeometryType.Rectangle;
        SketchOutputMode = SketchOutputMode.Map;
        //A custom cursor file as an embedded resource
        var cursorEmbeddedResource = new Cursor(new MemoryStream(MapExploration.Resource1.red_cursor));
        //A built in system cursor
        var systemCursor = System.Windows.Input.Cursors.ArrowCD;
        //Set the "CustomMapTool's" Cursor property to either one of the cursors defined above
        Cursor = cursorEmbeddedResource;
        //or
        Cursor = systemCursor;
    }

And here is the link of the sample Change the cursor of a tool.

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

You need to add your cursor file to visual studio project as resource. Instead of

"MapExploration.Resource1.red_cursor"  

use

Properties.Resources.<your_cursor_resource-name>

 

View solution in original post

2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

You need to add your cursor file to visual studio project as resource. Instead of

"MapExploration.Resource1.red_cursor"  

use

Properties.Resources.<your_cursor_resource-name>

 

KhaledAliMoh
New Contributor II

I had to add the file -as you said- as resource. This Link also helped to add the file in the wright way.

0 Kudos