From: Dave C. <dav...@gm...> - 2009-01-14 19:05:15
|
I, personally, could never get the mousewheel interaction to perform. I implemented a double click Zoom though (C#). You'll need to have the form capture all key presses to catch the Control key (used to return the chart to normal view). And a bunch of this code is my custom stuff - but you should get the picture. protected void Zoom(NPlot.Windows.PlotSurface2D ps, int zoomFactor, int x, int y) { try { Point minPoint = new Point(0, 0); minPoint.X = x - zoomFactor; minPoint.Y = y - (int)(zoomFactor / 1.4); Point maxPoint = new Point(0, 0); maxPoint.X = x + zoomFactor; maxPoint.Y = y + (int)(zoomFactor / 1.4); ps.CacheAxes(); ps.PhysicalXAxis1Cache.SetWorldLimitsFromPhysical(minPoint, maxPoint); ps.PhysicalXAxis2Cache.SetWorldLimitsFromPhysical(minPoint, maxPoint); ps.PhysicalYAxis1Cache.SetWorldLimitsFromPhysical(maxPoint, minPoint); ps.PhysicalYAxis2Cache.SetWorldLimitsFromPhysical(maxPoint, minPoint); ps.Invalidate(); } catch { } } private void plotSurface_DoubleClick(object sender, EventArgs e) { if (controlKeyIsBeingPressed) { RedrawAll(); } else { Zoom(plotSurface, 100, ((MouseEventArgs)e).X, ((MouseEventArgs)e).Y); } } private void frmTest_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.ControlKey) controlKeyIsBeingPressed = true; else controlKeyIsBeingPressed = false; } protected void RedrawAll() { Charting.DrawChart(plotSurface, chartDataTable, this.Symbol); DrawTrendLine(plotSurface, chartDataTable, 21, Color.Red, false); DrawTrendLine(plotSurface, chartDataTable, 63, Color.Blue, false); DrawTrendLine(plotSurface, chartDataTable, 189, Color.Black, false); DrawEMATrendLine(plotSurface, chartDataTable, Convert.ToInt32(txtArraySize.Text), Color.DarkGoldenrod, false); DrawTradeLines(plotSurface, tradeQuotes); plotSurface.Invalidate(); } On Wed, Jan 14, 2009 at 8:56 AM, FXHat - <fxh...@gm...> wrote: > Does anybody use the MouseWheelZoom interaction? Even when I try the demo > application - ABC plot example, I can not zoom in on the graph using my > mouse wheel. This plot does have MouseWheelZoom enabled according to the > source code. Also, is there a way to zoom programatically; i.e. zoom in as > a > starting point for the plot so that the user can zoom out if necessary. > > Thanks. > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Nplot-devel mailing list > Npl...@li... > https://lists.sourceforge.net/lists/listinfo/nplot-devel > -- ___________________ Dav...@gm... Lake Oswego, OR 801-473-9213 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ |