By Mark Malburg - Monday, March 7, 2016
Currently my Grid Surface chart is doing a "global zoom" quite nicely via:
NZoomTool zt = new NZoomTool(); zt.BeginDragMouseCommand = new NMouseCommand(MouseAction.Wheel, MouseButton.Middle, 0); zt.ZoomStep = 16; chartControl.Controller.Tools.Add(zt);
However, I'd like to catch Ctrl+Wheel as a way of affecting the chart's "Height" property. How can I catch the Ctrl+Wheel to do this? I can't seem to adjust height in a wheel handler without also getting the zoom from the NZoomTool.
|
By Nevron Support - Wednesday, March 9, 2016
Hi Mark,
You can create a custom tool based on the zoom tool that overrides the wheel action:
class CustomZoomTool : NZoomTool { /// <summary> /// Processes wheel operations /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override void DoWheel(object sender, NMouseEventArgs e) { if ((ModifierKeys & Keys.Control) == Keys.Control) { if (this.GetActiveChart() != null) { this.GetActiveChart().Height *= (float)(1.0 + 10.0 / e.Delta); base.Repaint(); } } else { base.DoWheel(sender, e); } } }
private void Form1_Load(object sender, EventArgs e) { NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true;
NBarSeries bar = new NBarSeries();
bar.Values.Add(10); bar.Values.Add(20); bar.Values.Add(30);
chart.Series.Add(bar);
nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); CustomZoomTool zt = new CustomZoomTool(); zt.BeginDragMouseCommand = new NMouseCommand(MouseAction.Wheel, MouseButton.Middle, 0); zt.ZoomStep = 16; nChartControl1.Controller.Tools.Add(zt); }
Let us know if you meet any problems.
|
By Mark Malburg - Sunday, March 13, 2016
Thanks!
|
|