Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

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

Print Search « Previous Thread Next Thread »
  05-13-2008, 5:06
Joshua is not online. Last active: 9/1/2008 11:12:20 PM Joshua



Top 25 Posts
Joined on 03-12-2008
Munich, Germany
Posts 67
Setting the MedicalViewer cursor property
Reply Quote
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:36
Adam Boulad is not online. Last active: 7/23/2008 4:14:05 PM Adam Boulad



Top 10 Posts
Joined on 09-16-2007
Posts 406
Re: Setting the MedicalViewer cursor property
Reply Quote

Did you try to set the m_medicalViewer.Cursor = Cursors.Hand; in the Form Load event handler?
Also, try using the medicalViewer1.Invalidate(); method in the Mouse Down event.

I have tried in an application here and the cursor did not change when performing different actions (such as the mouse click).

Please see attached project. If this small project doesn't work correctly at your side, please send your serial number to support@leadtools.com and ask for the latest patches.
Adam Boulad
LEADTOOLS Technical Support

   Report 
  05-13-2008, 10:38
Adam Boulad is not online. Last active: 7/23/2008 4:14:05 PM Adam Boulad



Top 10 Posts
Joined on 09-16-2007
Posts 406
Re: Setting the MedicalViewer cursor property

Attachment: MedicalViewerCell.zip
Reply Quote
The attached project

Adam Boulad
LEADTOOLS Technical Support

   Report 
  05-13-2008, 11:56
Joshua is not online. Last active: 9/1/2008 11:12:20 PM Joshua



Top 25 Posts
Joined on 03-12-2008
Munich, Germany
Posts 67
Re: Setting the MedicalViewer cursor property
Reply Quote
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-14-2008, 11:20
Adam Boulad is not online. Last active: 7/23/2008 4:14:05 PM Adam Boulad



Top 10 Posts
Joined on 09-16-2007
Posts 406
Re: Setting the MedicalViewer cursor property
Reply Quote

Josh,

I see what you are talking about. I have solved this by handling the CellMouseDown and the CellMouseDoubleClick events and adding this line in the events functions this line:

medicalViewer1.Cursor = Cursors.Hand;

This way the cursor will always be a Hand.
Adam Boulad
LEADTOOLS Technical Support

   Report 
  05-15-2008, 2:53
Joshua is not online. Last active: 9/1/2008 11:12:20 PM Joshua



Top 25 Posts
Joined on 03-12-2008
Munich, Germany
Posts 67
Re: Setting the MedicalViewer cursor property
Reply Quote
Thanks Adam, that works great.

   Report 
  05-26-2008, 12:15
Joshua is not online. Last active: 9/1/2008 11:12:20 PM Joshua



Top 25 Posts
Joined on 03-12-2008
Munich, Germany
Posts 67
Re: Setting the MedicalViewer cursor property
Reply Quote
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, 10:19
Adam Boulad is not online. Last active: 7/23/2008 4:14:05 PM Adam Boulad



Top 10 Posts
Joined on 09-16-2007
Posts 406
Re: Setting the MedicalViewer cursor property

Attachment: MedicalViewer_SwapCells.zip
Reply Quote

Joshua,

Thank you for your feedback. I have tried to reproduce the issue by creating a simple project but I was able to change the cursor without a problem. I'm posting the project here if you want to take a look at it.


Adam Boulad
LEADTOOLS Technical Support

   Report 
  05-28-2008, 12:00
Joshua is not online. Last active: 9/1/2008 11:12:20 PM Joshua



Top 25 Posts
Joined on 03-12-2008
Munich, Germany
Posts 67
Re: Setting the MedicalViewer cursor property

Attachment: Modified_MedicalViewer_SwapCells.zip
Reply Quote
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 
  06-02-2008, 3:57
Adam Boulad is not online. Last active: 7/23/2008 4:14:05 PM Adam Boulad



Top 10 Posts
Joined on 09-16-2007
Posts 406
Re: Setting the MedicalViewer cursor property
Reply Quote

Josh,

I have reported this issue to our engineers under incident number 7017AMN. I will update this forum post with changes regarding this incident.


Adam Boulad
LEADTOOLS Technical Support

   Report 
Post
LEAD Support Fo... » Developer » DotNet » Re: Setting the MedicalViewer cursor property

Powered by Community Server, by Telligent Systems