How to add OnDragEnd event to a moveable Legend of a Chart


Author
Message
joern kunze
joern kunze
Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)
Group: Forum Members
Posts: 86, Visits: 221
Hi Experts,
I have a moveable Legend (using NOffserTool based Controller-Tool) where I want to save Legend-Coordinates after the Legend has been moved so that I can restore Legend position when needed.
Moving the Legend works good - but I have some trouble getting the Legend position after it has been moved. The NOffsetTool offers only OnDoDrag but no EndDrag event:
https://www.nevron.com/forum/uploads/images/d6aaed4b-bc4e-42cd-9908-f5a7.jpg
 Within the OnDoDrag I can get the coordinates continously while the Legend is moved - but I would like to get the coordinates only when the Legend Drag has been finished. Is there a way to achieve this ?

Furthermore I wonder if there is an easy way to get the Legend Coordinates in the LegendMoveTool
LocationChanged event.

Present Situation:
     LegendMoveTool hLegendMoveTool = new LegendMoveTool();
      hLegendMoveTool.LocationChanged += eventSink_OnLegendEndDrag;
      _NevronChart.Controller.Tools.Add(hLegendMoveTool);

where
  public void eventSink_OnLegendEndDrag(object sender, EventArgs e) {
    Console.WriteLine("OnLegendEndDrag");
           // How can I get the Legend coordinates here - EventArgs e seems not to have them ?
   }

and
public class LegendMoveTool : Nevron.Chart.Windows.NOffsetTool
{
...
  public override void OnDoDrag(object sender, NMouseEventArgs e) {
         // event is fired continously when Legend is moved ....
           NPoint oPoint = e.Location;
      Console.WriteLine("OnDoDrag: X=" + oPoint.X + " / Y=" + oPoint.Y);   // Coordinates of the Legends lower right corner
      base.OnDoDrag(sender, e);
   }
}

Thanks for your help,
Best regards,
Joern



Reply
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Joern,

1. Problem
 When the entire form is resized or even maximized, the Legend automatically is moved to the upper right corner of the chart area (which is good). But in such a case, the OnEndDrag event is not fired. Is there a way to detect such an case with the LegendMoveTool (force somehow an OnEndDrag event)?
You can attach to the ContentAreaChanged event of the legend which if fired each time the content area changes (this is valid for app panels)

2. Setting the Legend position
 When I use the OnEndDrag to determine Legend position;
      NPoint oPoint = ((NMouseEventArgs)eIn).Location;                               // Coordinates of the Legends lower right corner ?
       int iX = oPoint.X;
       int iY = oPoint.Y;
 and use iX / iY afterwards to set the position:

NLegend oLegend = m_listCharts[i].Chart.DisplayOnLegend;
oLegend.Location = new NPointL(iX, iY);


 
When you set the location in this way it is actually specified in points – you need to ensure the location is specified in pixels in this case:
 
legend.Location = new NPointL(new NLength(x, NGraphicsUnit.Pixel), new NLength(y, NGraphicsUnit.Pixel));
 
Please elaborate on the last problem if it still persist after you change the location to use pixels instead of points.





Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search