... overwriting OnEndDrag basically seems to work. But now 2 other problems arise: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)?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);
the legend is not really at the position desired.
When I add an offset like
int iWidthLegend = (int)oLegend.MarginsArea.Width;
int iHeightLegend = (int)oLegend.MarginsArea.Height;
iX - = iWidthLegend;
iY - = iHeightLegend;
The Legend is getting closer to the desired original point - but still quite far away.
So what must be done to bring the legend to exactly the position which was given by iX / iY from OnEndDrag ?
Furthermore, in case the given iX and iY are stored somewhere and to be restored later on a different screen, I want to ensure that the legend is always visible:
NRectangleF oBoundsChart = m_listCharts[i].Chart.PlotArea;
int iXMin = (int)oBoundsChart.X;
int iXMax = iXMin + (int)oBoundsChart.Width;
int iYMin = (int)oBoundsChart.Y ;
int iYMax = iYMin + (int)oBoundsChart.Height ;
and keep the legend position within this chart bounds area. But somehow here is also an considerable offset (actually the legend disappears without correcting iY -= 100)
So how can I ensure, that the legend is always visible within the chart when the legend position is set manually ?
Thanks a lot for your help,