Overriding Cursors
Posted: Mon Jun 01, 2020 11:55 pm
Hi, I'm looking to overwrite the cursors for the annotation tool for specific annotation types (ex. Replace the normal cursor and action cursor for the PdfAnnotationTool to reflect the annotation that will be created by the tool is an ink annotation, etc.). I can get the icon replaced, but for some reason it doesn't always get reflected in the viewer. Also, updating the action cursor doesn't seem to be doing anything (it always goes back to the cross).
So far as I can tell, the cursor being displayed is the ImageViewer's cursor property, but that seems to be set in the background by active tools etc. Is there a way for me to force the viewer to take the cursor off of a specific tool or otherwise lock the ImageViewer's cursor image?
Of note, I have tried overriding the cursor properties in the ImageViewer, PdfAnnotationTool, and CompositeVisualTool and I that gets things close (specifically the ImageViewer works the best) however it dramatically slows down drawing ink annotations (I assume because it's constantly flipping back and forth between cursors under the hood somewhere). It also sometimes keeps my cursor around even when I do the following:
And then when I want my cursor to override everything I call LockCursor(newCursor) and when I want it to go back to normal operation I call LockCursor(null). Sometimes I'll switch to a different tool and the previously locked cursor comes back from somewhere I haven't been able to find.
Thanks!
So far as I can tell, the cursor being displayed is the ImageViewer's cursor property, but that seems to be set in the background by active tools etc. Is there a way for me to force the viewer to take the cursor off of a specific tool or otherwise lock the ImageViewer's cursor image?
Of note, I have tried overriding the cursor properties in the ImageViewer, PdfAnnotationTool, and CompositeVisualTool and I that gets things close (specifically the ImageViewer works the best) however it dramatically slows down drawing ink annotations (I assume because it's constantly flipping back and forth between cursors under the hood somewhere). It also sometimes keeps my cursor around even when I do the following:
Code: Select all
public class MyImageViewer : ImageViewer
{
private Cursor _lockCursor = null;
public void LockCursor(Cursor lockCursor)
{
_lockCursor = lockCursor;
}
public override Cursor Cursor
{
get
{
if (_lockCursor != null)
{
return _lockCursor;
}
else
{
return base.Cursor;
}
}
set => base.Cursor = value;
}
}
Thanks!