I am able to get the NDataCursorTool on the zoom screen. The one issue I'm having is that it now interferes with access to the scrolling tools at the bottom of the zoom screen.
Here's what my code looks like:
void resultVisualizationHeader1_MouseZoom(object sender, EventArgs e)
{
zoomToolOn = !zoomToolOn;
if (_resultsViewInfo.ProcessedTimeStep == ViewReportingFrequency.Monthly || _resultsViewInfo.ProcessedTimeStep == ViewReportingFrequency.Run_Period)
{
MessageBox.Show(MessageAndPrompts.INFORM_DATAZOOM_TOOL_FREQUENCY_COMPATIBITLIY);
return;
}
ClearAndResetAppliedToolSettings();
_chartControl.Controller.Tools.RemoveAllChildren();
_chartControl.Controller.Selection.Clear();
_chartControl.Controller.Selection.Add(_chartControl.Charts[0]);
if (cursorToolOn)
{
//_chart.RangeSelections.Add(new NRangeSelection());
NAxisCursor xAxisCursor = new NAxisCursor();
xAxisCursor.SynchronizeOnMouseAction = MouseAction.Move;
xAxisCursor.BeginEndAxis = (int)StandardAxis.PrimaryY;
_chart.Axis(StandardAxis.PrimaryX).Cursors.Add(xAxisCursor);
NAxisCursor yAxisCursor = new NAxisCursor();
yAxisCursor.SynchronizeOnMouseAction = MouseAction.Move;
yAxisCursor.BeginEndAxis = (int)StandardAxis.PrimaryX;
_chart.Axis(StandardAxis.PrimaryY).Cursors.Add(yAxisCursor);
}
_chartPrimaryXAxis.ScrollBar.Visible = true;
_chartPrimaryYAxis.ScrollBar.Visible = true;
var dateTimePagingView = _chartPrimaryXAxis.PagingView as NDateTimeAxisPagingView;
if (dateTimePagingView != null)
{
_chartPrimaryXAxis.ScrollBar.Visible = true;
dateTimePagingView.ResetMode = PagingViewResetMode.View;
dateTimePagingView.Reset();
dateTimePagingView.ResetMode = PagingViewResetMode.LastZoom;
}
_chartPrimaryYAxis.PagingView = new NNumericAxisPagingView();
UpdateDataZoomTool();
UpdateDateTimeScale();
_dateTimeScale.EnableUnitSensitiveFormatting = true;
// configure interactivity
_chartControl.Controller.Tools.Add(new NSelectorTool());
_chartControl.Controller.Tools.Add(_chartDataZoomTool);
_chartControl.Controller.Tools.Add(_chartDataCursorTool);
_chartControl.Controller.Tools.Add(new NAxisScrollTool());
_chartControl.Refresh();
UpdateResultsViewReloadState();
}
private void ClearAndResetAppliedToolSettings()
{
if (_chartDataCursorTool != null)
{
if (_chartControl.Controller.Tools.Contains(_chartDataCursorTool))
{
NChart chart = _chartControl.Charts[0];
NAxis primaryXAxis = chart.Axis(StandardAxis.PrimaryX);
NAxis primaryYAxis = chart.Axis(StandardAxis.PrimaryY);
NAxis depthAxis = chart.Axis(StandardAxis.Depth);
primaryXAxis.Cursors.Clear();
primaryYAxis.Cursors.Clear();
toolTip1.SetToolTip(_chartControl, "");
}
}
//Reset all Chart interaction controls
_chartControl.Controller.Tools.RemoveAllChildren();
if (_resultsViewInfo.ChartType == ChartOrTableType.Bar3d)
{
_chartControl.Controller.Tools.Add(new NSelectorTool());
_chartControl.Controller.Tools.Add(new NTrackballTool());
}
_chartPrimaryXAxis.ScrollBar.Visible = false;
_chartPrimaryYAxis.ScrollBar.Visible = false;
this.Cursor = Cursors.Default;
ChartCategory chartCategory = GetChartCategory(_resultsViewInfo.ChartType);
if (chartCategory == ChartCategory.Column || chartCategory == ChartCategory.Range)
{
_chartPrimaryXAxis.PagingView = null;
_chartPrimaryXAxis.Visible = _resultsViewInfo.ResultsViewVariables.Count != 0;
}
else
{
if (_resultsViewInfo.ResultsViewVariables.Count == 0)
{
_chartPrimaryXAxis.PagingView = new NDateTimeAxisPagingView();
}
}
_chartPrimaryYAxis.PagingView = new NNumericAxisPagingView();
;
}
private void UpdateResultsViewReloadState()
{
_chartControl.document.Calculate();
_chartControl.document.RecalcLayout(_chartControl.View.Context);
//dateTimeScale
NRange1DD xAxisRange = _chart.Axis(StandardAxis.PrimaryX).Scale.RulerRange;
DateTime startdate = DateTime.FromOADate(xAxisRange.Begin);
DateTime enddate = DateTime.FromOADate(xAxisRange.End);
_resultsViewInfo.StartDate = startdate;
_resultsViewInfo.EndDate = enddate;
Debug.WriteLine("StartDate:" + startdate.ToString() + " - EndDate:" + enddate.ToString());
}
This is the code that initially turns on the Data Cursor:
void resultVisualizationHeader1_MouseTrackBallSelect(object sender, EventArgs e)
{
if (!zoomToolOn)
{
if (!cursorToolOn)
{
ClearAndResetAppliedToolSettings();
UpdateCursorFromControls();
var dateTimePagingView = _chartPrimaryXAxis.PagingView as NDateTimeAxisPagingView;
if (dateTimePagingView != null)
{
_chartPrimaryXAxis.ScrollBar.Visible = false;
dateTimePagingView.ResetMode = PagingViewResetMode.View;
dateTimePagingView.Reset();
dateTimePagingView.ResetMode = PagingViewResetMode.LastZoom;
}
_chartControl.Controller.Selection.Clear();
_chartControl.Controller.Selection.Add(_chartControl.Charts[0]);
_chartControl.Controller.Tools.Add(_chartDataCursorTool);
_chartControl.Refresh();
UpdateResultsViewReloadState();
cursorToolOn = true;
}
else
{
ClearAndResetAppliedToolSettings();
UpdateCursorFromControls();
_chartControl.Controller.Selection.Clear();
_chartControl.Controller.Selection.Add(_chartControl.Charts[0]);
//_chartControl.Controller.Tools.Remove(_chartDataCursorTool);
_chart.Axis(StandardAxis.PrimaryX).Cursors.Clear();
_chart.Axis(StandardAxis.PrimaryY).Cursors.Clear();
_chartControl.Refresh();
cursorToolOn = false;
}
}
else
{
MessageBox.Show(MessageAndPrompts.INFORM_DATATRACK_TOOL_BEFORE_ZOOM);
}
}
private void UpdateCursorFromControls()
{
_chartHorizontalAxisCursor.ValueSnapper = null;
_chartVerticalAxisCursor.ValueSnapper = null;
NAxis depthAxis = _chart.Axis(StandardAxis.Depth);
_chartPrimaryXAxis.Cursors.Clear();
_chartPrimaryYAxis.Cursors.Clear();
depthAxis.Cursors.Clear();
_chartPrimaryXAxis.Cursors.Add(_chartHorizontalAxisCursor);
_chartPrimaryYAxis.Cursors.Add(_chartVerticalAxisCursor);
_chartHorizontalAxisCursor.SynchronizeOnMouseAction = MouseAction.None;
_chartVerticalAxisCursor.SynchronizeOnMouseAction = MouseAction.None;
_chartHorizontalAxisCursor.SynchronizeOnMouseAction |= MouseAction.Down;
_chartVerticalAxisCursor.SynchronizeOnMouseAction |= MouseAction.Down;
_chartHorizontalAxisCursor.SynchronizeOnMouseAction |= MouseAction.Up;
_chartVerticalAxisCursor.SynchronizeOnMouseAction |= MouseAction.Up;
_chartHorizontalAxisCursor.SynchronizeOnMouseAction |= MouseAction.Move;
_chartVerticalAxisCursor.SynchronizeOnMouseAction |= MouseAction.Move;
}
Note: You will notice that I require that the user turns on the cursor before turning on zoom.
Thanks for your help.
Jim