Re: Setting the MedicalViewer cursor property
Started by Joshua at 05-13-2008 5:06. Topic has 9 replies.
|
|
05-13-2008, 5:06
|
Joshua

Joined on 03-12-2008
Munich, Germany
Posts 65
|
Setting the MedicalViewer cursor property
|
 
 
|
|
|
Hi,
I want to change the mouse cursor that appears when the user is interacting with the MedicalViewer control. I have currently implemented this by setting the Cursor property of the MedicalViewer control like so: m_medicalViewer.Cursor = Cursors.Hand;
This works great and gives exactly the behaviour that I want, the only problem is that when the mouse is clicked on the viewer the cursor changes back to the standard arrow cursor, when the mouse is moved (doesn't matter whether the click button is held down or not) the cursor then changes back to the hand. This is a bit strange! I tried catching the CellMouseDown event on the viewer and setting the cursor there again, however that seems to have no effect. Is this a leadtools bug or is there something I'm supposed to be doing that I'm not?
I'm using the v15 .Net LeadTools framework.
|
|
|
|
|
Report
|
|
|
|
05-13-2008, 10:38
|
Adam Boulad

Joined on 09-16-2007
Posts 402
|
|
|
The attached project
Adam Boulad LEADTOOLS Technical Support
|
|
|
|
|
Report
|
|
|
|
05-13-2008, 11:56
|
Joshua

Joined on 03-12-2008
Munich, Germany
Posts 65
|
Re: Setting the MedicalViewer cursor property
|
 
 
|
|
|
Hi Adam,
Thanks for that. The project works as expected on my machine, however, if you add an image to the viewer, then click on the cell containing the image you'll see the behaviour I mentioned earlier. Cells without images behave as expected, it's just those with them that temporarily reset the mouse cursor.
Add this code to your project and you'll see what I mean:
private void Form1_Load(object sender, EventArgs e) { medicalViewer1.Cursor = Cursors.Hand;
RasterImage image; RasterCodecs.Startup(); using (RasterCodecs codecs = new RasterCodecs()) { image = codecs.Load("BRAIN006"); } RasterCodecs.Shutdown();
Leadtools.MedicalViewer.MedicalViewerCell cell = new Leadtools.MedicalViewer.MedicalViewerCell(image); medicalViewer1.Cells.Add(cell); }
The invalidate method didn't help. :(
Josh.
|
|
|
|
|
Report
|
|
|
|
05-15-2008, 2:53
|
Joshua

Joined on 03-12-2008
Munich, Germany
Posts 65
|
Re: Setting the MedicalViewer cursor property
|
 
 
|
|
|
Thanks Adam, that works great.
|
|
|
|
|
Report
|
|
|
|
05-26-2008, 12:15
|
Joshua

Joined on 03-12-2008
Munich, Germany
Posts 65
|
Re: Setting the MedicalViewer cursor property
|
 
 
|
|
|
Hi Adam,
That worked great when I just wanted to set the cursor as a one off, on the first click, but when attempting to toggle between two cursors (on the mouse down and mouse up events) I began to experience the exact same problem.
I managed to solve it, but wanted to post here anyway so that if someone else has the same problem they know how to solve it (also, it's a bug, so maybe you guys could fix it) It turns out that you have to set the cursor property *twice* for it to stick. Strange. I'll post my code here, it's in C# 3 and full of anonymous methods and LINQ though so it's not as straightforward as it could be:
-----------------------------------------------------------------------------------------------------------------------------------
MedicalViewer m_movableMedicalViewerControl = new MedicalViewer();
// Change the mouse cursor to give a visual hint of the drag capabilities. { Assembly assembly = Assembly.GetExecutingAssembly();
Cursor openHandCursor = ((Func) delegate { Cursor cursor;
try { string openHandCursorResourceName = (from resourceName in assembly.GetManifestResourceNames() where resourceName.EndsWith("OpenHand.cur") select resourceName).First(); using (Stream resourceStream = assembly.GetManifestResourceStream(openHandCursorResourceName)) cursor = new Cursor(resourceStream); } catch { cursor = Cursors.Default; }
return cursor; }).Invoke();
Cursor closedHandCursor = ((Func) delegate { Cursor cursor;
try { string openHandCursorResourceName = (from resourceName in assembly.GetManifestResourceNames() where resourceName.EndsWith("ClosedHand.cur") select resourceName).First(); using (Stream resourceStream = assembly.GetManifestResourceStream(openHandCursorResourceName)) cursor = new Cursor(resourceStream); } catch { cursor = Cursors.Default; }
return cursor; }).Invoke();
// Note: It's not a coding error here that the cursor assignment happens twice, it's a bug in the LeadTools code // that requires the double assignment. Without it, the cursor doesn't get set until the mouse is moved. EventHandler setCursorDelegate = (object sender, MedicalViewerCellMouseEventArgs e) => { if (Control.MouseButtons == MouseButtons.Left) { // Having an open hand cursor without a closed hand cursor is ok, but the other way // around is not. If the open hand cursor couldn't be loaded then we'll leave the // cursor properties alone. if (openHandCursor != Cursors.Default) { m_movableMedicalViewerControl.Cursor = closedHandCursor; m_movableMedicalViewerControl.Cursor = closedHandCursor; } } else { m_movableMedicalViewerControl.Cursor = openHandCursor; m_movableMedicalViewerControl.Cursor = openHandCursor; } };
m_movableMedicalViewerControl.Cursor = openHandCursor;
m_movableMedicalViewerControl.CellMouseDoubleClick += setCursorDelegate;
m_movableMedicalViewerControl.CellMouseDown += setCursorDelegate;
m_movableMedicalViewerControl.CellMouseUp += setCursorDelegate; }
-----------------------------------------------------------------------------------------------------------------------------------
Josh.
|
|
|
|
|
Report
|
|
|
|
05-28-2008, 12:00
|
Joshua

Joined on 03-12-2008
Munich, Germany
Posts 65
|
|
|
Hi Adam,
I've modified the project you created so that it now demonstrates the bug I was talking about, which I've attached to this post. All you have to do is comment out, or uncomment, line 47 in Form.cs to see it.
Josh.
|
|
|
|
|
Report
|
|
|
|
|
LEAD Support Fo... » Developer » DotNet » Re: Setting the MedicalViewer cursor property
|
|
Copyright LEAD Technologies, Inc. 2008
