Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 Problems with ChartView.FindObj
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

K_P

1 Posts

Posted - 31 Oct 2007 :  17:02:27  Show Profile  Reply with Quote
My intent is to use the right mouse down to remove a placed marker and its string label. I add the marker and label to the chart - no problem. I verified that the chartview obj contains a Marker object in the ChartArryList but the FindObj method always returns a null. I also checked the mouse location value and the ChartArrayList for the marker location and they match. Still it does not work. Here is the code I am using:


        public override void OnMouseDown(MouseEventArgs mouseevent)
        {
            NearestPointData nearestPointObj1 = new NearestPointData();
            Point2D nearestPoint = new Point2D(0, 0);
            ChartView chartview = GetChartObjComponent();
            bool bfound1 = false;

            base.OnMouseDown(mouseevent);

            if ((mouseevent.Button & MouseButtons.Right) != 0)
            {
                // Find mouse location
                Point2D location = GetLocation();
                //get nearest point location
                bfound1 = thePlot1.CalcNearestPoint(location, ChartObj.FNP_DIST, nearestPointObj1);

                if (bfound1)
                {
                    nearestPoint = nearestPointObj1.GetNearestPoint();

                    GraphObj remove_obj = chartview.FindObj(nearestPoint, "Marker");
                    if (remove_obj != null)
                    {                        
                        chartview.DeleteChartObject(remove_obj);
                        GraphObj remove_obj1 = chartview.FindObj(nearestPoint, "StringLabel");
                        if (remove_obj1 != null)
                        {
                            chartview.DeleteChartObject(remove_obj1);
                        }
                    }
                }
            }
        }



Any ideas what I might be doing wrong?

Thank you for your help.

Best Regards,

Kurt

quinncurtis

1164 Posts

Posted - 01 Nov 2007 :  08:46:38  Show Profile  Reply with Quote
Our best guess is that you are comparing different coordinate systems.
The CalcNearestPoint method calculates the nearest point in physical (scaled) coordinates. The FindObj method expects coordinates in device (pixel) coordinates. So you should try converting the physical coordinates of the nearest point to device coordinates.

nearestPoint = nearestPointObj1.GetNearestPoint();

// Convert physical coordinates to device coordinates
nearestPoint = thePlot1.ChartObjScale.ConvertCoord(ChartObj.DEV_POS,
       nearestPoint,ChartObj.PHYS_POS);

GraphObj remove_obj = chartview.FindObj(nearestPoint, "Marker");


If you still cannot make it work you should probably make a simple example program that demonstrates the problem and send us (support@quinn-curtis.com) the complete project as a zip file
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07