/// <summary> /// Handler for the "Undo All Zoom/Pan" context menu item. Restores the scale ranges to the values /// before all zoom and pan operations /// </summary> /// <remarks> /// This method differs from the <see cref="RestoreScale" /> method in that it sets the scales /// to their initial setting prior to any user actions. The <see cref="RestoreScale" /> method /// sets the scales to full auto mode (regardless of what the initial setting may have been). /// </remarks> /// <param name="primaryPane">The <see cref="GraphPane" /> object which is to be zoomed out</param> public void ZoomOutAll(GraphPane primaryPane) { if (primaryPane != null && !primaryPane.ZoomStack.IsEmpty) { ZoomState.StateType type = primaryPane.ZoomStack.Top.Type; ZoomState oldState = new ZoomState(primaryPane, type); //ZoomState newState = pane.ZoomStack.PopAll( pane ); ZoomState newState = null; if (_isSynchronizeXAxes || _isSynchronizeYAxes) { foreach (GraphPane pane in _masterPane._paneList) { ZoomState state = pane.ZoomStack.PopAll(pane); if (pane == primaryPane) { newState = state; } } } else { newState = primaryPane.ZoomStack.PopAll(primaryPane); } // Provide Callback to notify the user of zoom events if (this.ZoomEvent != null) { this.ZoomEvent(this, oldState, newState); } Refresh(); } }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="ZoomState"/> object from which to copy</param> public ZoomState( ZoomState rhs ) { _xAxis = new ScaleState( rhs._xAxis ); _x2Axis = new ScaleState( rhs._x2Axis ); _yAxis = new ScaleStateList( rhs._yAxis ); _y2Axis = new ScaleStateList( rhs._y2Axis ); }
/// <summary> /// Handler for the "UnZoom/UnPan" context menu item. Restores the scale ranges to the values /// before the last zoom, pan, or scroll operation. /// </summary> /// <remarks> /// Triggers a <see cref="ZoomEvent" /> for any type of undo (including pan, scroll, zoom, and /// wheelzoom). This method will affect all the /// <see cref="GraphPane" /> objects in the <see cref="MasterPane" /> if /// <see cref="IsSynchronizeXAxes" /> or <see cref="IsSynchronizeYAxes" /> is true. /// </remarks> /// <param name="primaryPane">The primary <see cref="GraphPane" /> object which is to be /// zoomed out</param> public void ZoomOut(GraphPane primaryPane) { if (primaryPane == null || primaryPane.ZoomStack.IsEmpty) { return; } var type = primaryPane.ZoomStack.Top.Type; var oldState = new ZoomState(primaryPane, type); ZoomState newState = null; if (_isSynchronizeXAxes || _isSynchronizeYAxes) { foreach (var pane in _masterPane._paneList) { var state = pane.ZoomStack.Pop(pane); if (pane == primaryPane) { newState = state; } } } else { newState = primaryPane.ZoomStack.Pop(primaryPane); } // Provide Callback to notify the user of zoom events if (ZoomEvent != null) { ZoomEvent(this, oldState, newState); } Refresh(); }
///------------------------------------------------------------------------ /// <summary> /// Zooms the curve. /// </summary> /// <param name="graphPane">The graph pane.</param> /// <param name="lineItem">The line item.</param> /// <returns></returns> ///------------------------------------------------------------------------ public bool ZoomCurve(GraphPane graphPane, CurveItem lineItem, double filterMinX = double.MinValue, double filterMaxX = double.MaxValue) { if (lineItem.Points.Count == 0) { return(false); } if (!ZoomCurveOnLegendClick) { Invalidate(); return(false); } // Add the zoom to the zoom stack var oldState = new ZoomState(graphPane, ZoomState.StateType.Zoom); graphPane.ZoomStack.Push(graphPane, ZoomState.StateType.Zoom); ZoomEvent?.Invoke(this, oldState, new ZoomState(graphPane, ZoomState.StateType.Zoom)); if (!SetZoomScale(graphPane, lineItem, filterMinX, filterMaxX)) { return(false); } // Update the pane graphPane.AxisChange(); Invalidate(); return(true); }
private void ZedGraphControl_MouseDown(object sender, MouseEventArgs e) { this.isPanning = false; this.isZooming = false; this.dragPane = null; GraphPane pane = this.MasterPane.FindAxisRect(new PointF(e.X, e.Y)); if (pane != null && this.isEnablePan && (e.Button == MouseButtons.Middle || (e.Button == MouseButtons.Left && (Control.ModifierKeys == Keys.Shift)))) { isPanning = true; // Calculate the startPoint by using the PointToScreen // method. this.dragRect = new Rectangle(((Control)sender).PointToScreen(new Point(e.X, e.Y)), new Size(1, 1)); this.dragPane = pane; this.zoomState = new ZoomState(this.dragPane, ZoomState.StateType.Pan); } else if (pane != null && this.isEnableZoom && e.Button == MouseButtons.Left) { isZooming = true; // Calculate the startPoint by using the PointToScreen // method. this.dragRect = new Rectangle(((Control)sender).PointToScreen(new Point(e.X, e.Y)), new Size(1, 1)); this.dragPane = pane; } }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="ZoomState"/> object from which to copy</param> public ZoomState(ZoomState rhs) { _xAxis = new ScaleState(rhs._xAxis); _x2Axis = new ScaleState(rhs._x2Axis); _yAxis = new ScaleStateList(rhs._yAxis); _y2Axis = new ScaleStateList(rhs._y2Axis); }
/// <summary> /// Handler for the "Undo All Zoom/Pan" context menu item. Restores the scale ranges to the values /// before all zoom and pan operations /// </summary> /// <remarks> /// This method differs from the <see cref="RestoreScale" /> method in that it sets the scales /// to their initial setting prior to any user actions. The <see cref="RestoreScale" /> method /// sets the scales to full auto mode (regardless of what the initial setting may have been). /// </remarks> /// <param name="primaryPane">The <see cref="GraphPane" /> object which is to be zoomed out</param> public void ZoomOutAll(GraphPane primaryPane) { if (primaryPane == null || primaryPane.ZoomStack.IsEmpty) { return; } var type = primaryPane.ZoomStack.Top.Type; var oldState = new ZoomState(primaryPane, type); //ZoomState newState = pane.ZoomStack.PopAll( pane ); ZoomState newState = null; if (_isSynchronizeXAxes || _isSynchronizeYAxes) { foreach (var pane in _masterPane.PaneList.Where(p => p is GraphPane).Cast <GraphPane>()) { ZoomState state = pane.ZoomStack.PopAll(pane); if (pane == primaryPane) { newState = state; } } } else { newState = primaryPane.ZoomStack.PopAll(primaryPane); } // Provide Callback to notify the user of zoom events ZoomEvent?.Invoke(this, oldState, newState); Refresh(); }
/// <summary> /// Handler for the "Set Scale to Default" context menu item. Sets the scale ranging to /// full auto mode for all axes. /// </summary> /// <remarks> /// This method differs from the <see cref="ZoomOutAll" /> method in that it sets the scales /// to full auto mode. The <see cref="ZoomOutAll" /> method sets the scales to their initial /// setting prior to any user actions (which may or may not be full auto mode). /// </remarks> /// <param name="primaryPane">The <see cref="GraphPane" /> object which is to have the /// scale restored</param> public void RestoreScale(PaneBase primaryPane) { if (primaryPane == null || !(primaryPane is GraphPane)) { return; } var pane = (GraphPane)primaryPane; //Go ahead and save the old zoomstates, which provides an "undo"-like capability //ZoomState oldState = primaryPane.ZoomStack.Push( primaryPane, ZoomState.StateType.Zoom ); var oldState = new ZoomState(pane, ZoomState.StateType.Zoom); using (var g = CreateGraphics()) { if (_isSynchronizeXAxes || _isSynchronizeYAxes) { foreach (var paneBase in _masterPane.PaneList) { var p = (GraphPane)paneBase; p.ZoomStack.Push(p, ZoomState.StateType.Zoom); RestoreAutoScale(p, g); } } else { pane.ZoomStack.Push(pane, ZoomState.StateType.Zoom); RestoreAutoScale(pane, g); } // Provide Callback to notify the user of zoom events ZoomEvent?.Invoke(this, oldState, new ZoomState(pane, ZoomState.StateType.Zoom)); } Refresh(); }
/// <summary> /// Add the scale range information from the specified <see cref="GraphPane"/> object as a /// new <see cref="ZoomState"/> entry on the stack. /// </summary> /// <param name="pane">The <see cref="GraphPane"/> object from which the scale range /// information should be copied.</param> /// <param name="type">A <see cref="ZoomState.StateType"/> enumeration that indicates whether this /// state is the result of a zoom or pan operation.</param> /// <returns>The resultant <see cref="ZoomState"/> object that was pushed on the stack.</returns> public ZoomState Push(GraphPane pane, ZoomState.StateType type) { ZoomState state = new ZoomState(pane, type); this.List.Add(state); return(state); }
/// <summary> /// Handler for the "Set Scale to Default" context menu item. Sets the scale ranging to /// full auto mode for all axes. /// </summary> /// <remarks> /// This method differs from the <see cref="ZoomOutAll" /> method in that it sets the scales /// to full auto mode. The <see cref="ZoomOutAll" /> method sets the scales to their initial /// setting prior to any user actions (which may or may not be full auto mode). /// </remarks> /// <param name="primaryPane">The <see cref="GraphPane" /> object which is to have the /// scale restored</param> public void RestoreScale(GraphPane primaryPane) { if (primaryPane != null) { //Go ahead and save the old zoomstates, which provides an "undo"-like capability //ZoomState oldState = primaryPane.ZoomStack.Push( primaryPane, ZoomState.StateType.Zoom ); ZoomState oldState = new ZoomState(primaryPane, ZoomState.StateType.Zoom); using (Graphics g = this.CreateGraphics()) { if (_isSynchronizeXAxes || _isSynchronizeYAxes) { foreach (GraphPane pane in _masterPane._paneList) { pane.ZoomStack.Push(pane, ZoomState.StateType.Zoom); ResetAutoScale(pane, g); } } else { primaryPane.ZoomStack.Push(primaryPane, ZoomState.StateType.Zoom); ResetAutoScale(primaryPane, g); } // Provide Callback to notify the user of zoom events if (this.ZoomEvent != null) { this.ZoomEvent(this, oldState, new ZoomState(primaryPane, ZoomState.StateType.Zoom)); } //g.Dispose(); } Refresh(); } }
public ZedGraphControl() { InitializeComponent(); // These commands do nothing, but they get rid of the compiler warnings for // unused events bool b = MouseDown == null || MouseUp == null || MouseMove == null; // Link in these events from the base class, since we disable them from this class. base.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ZedGraphControl_MouseDown); base.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ZedGraphControl_MouseUp); base.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ZedGraphControl_MouseMove); // Use double-buffering for flicker-free updating: SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true); _resourceManager = new ResourceManager("ZedGraph.ZedGraph.ZedGraphLocale", Assembly.GetExecutingAssembly()); Rectangle rect = new Rectangle(0, 0, this.Size.Width, this.Size.Height); _masterPane = new MasterPane("", rect); _masterPane.Margin.All = 0; _masterPane.Title.IsVisible = false; string titleStr = _resourceManager.GetString("title_def"); string xStr = _resourceManager.GetString("x_title_def"); string yStr = _resourceManager.GetString("y_title_def"); //GraphPane graphPane = new GraphPane( rect, "Title", "X Axis", "Y Axis" ); GraphPane graphPane = new GraphPane(rect, titleStr, xStr, yStr); using (Graphics g = this.CreateGraphics()) { graphPane.AxisChange(g); } _masterPane.Add(graphPane); this.hScrollBar1.Minimum = 0; this.hScrollBar1.Maximum = 100; this.hScrollBar1.Value = 0; this.vScrollBar1.Minimum = 0; this.vScrollBar1.Maximum = 100; this.vScrollBar1.Value = 0; _xScrollRange = new ScrollRange(true); _yScrollRangeList = new ScrollRangeList(); _y2ScrollRangeList = new ScrollRangeList(); _yScrollRangeList.Add(new ScrollRange(true)); _y2ScrollRangeList.Add(new ScrollRange(false)); _zoomState = null; _zoomStateStack = new ZoomStateStack(); }
/// <summary> /// Pop a <see cref="ZoomState"/> entry from the top of the stack, and apply the properties /// to the specified <see cref="GraphPane"/> object. /// </summary> /// <param name="pane">The <see cref="GraphPane"/> object to which the scale range /// information should be copied.</param> public void Pop(GraphPane pane) { if (!this.IsEmpty) { ZoomState state = (ZoomState)this.List[this.List.Count - 1]; this.List.RemoveAt(this.List.Count - 1); state.ApplyState(pane); } }
/// <summary> /// Pop a <see cref="ZoomState"/> entry from the top of the stack, and apply the properties /// to the specified <see cref="GraphPane"/> object. /// </summary> /// <param name="pane">The <see cref="GraphPane"/> object to which the scale range /// information should be copied.</param> /// <returns>The <see cref="ZoomState"/> object that was "popped" from the stack and applied /// to the specified <see cref="GraphPane"/>. null if no <see cref="ZoomState"/> was /// available (the stack was empty).</returns> public ZoomState Pop(GraphPane pane) { if (!this.IsEmpty) { ZoomState state = (ZoomState)this.List[this.List.Count - 1]; this.List.RemoveAt(this.List.Count - 1); state.ApplyState(pane); return(state); } else { return(null); } }
/// <summary> /// Pop the <see cref="ZoomState"/> entry from the bottom of the stack, and apply the properties /// to the specified <see cref="GraphPane"/> object. Clear the stack completely. /// </summary> /// <param name="pane">The <see cref="GraphPane"/> object to which the scale range /// information should be copied.</param> /// <returns>The <see cref="ZoomState"/> object at the bottom of the stack that was applied /// to the specified <see cref="GraphPane"/>. null if no <see cref="ZoomState"/> was /// available (the stack was empty).</returns> public ZoomState PopAll(GraphPane pane) { if (!this.IsEmpty) { ZoomState state = (ZoomState)this.List[0]; this.List.Clear(); state.ApplyState(pane); return(state); } else { return(null); } }
/// <summary> /// Save the current states of the GraphPanes to a separate collection. Save a single /// (<see paramref="primaryPane" />) GraphPane if the panes are not synchronized /// (see <see cref="IsSynchronizeXAxes" /> and <see cref="IsSynchronizeYAxes" />), /// or save a list of states for all GraphPanes if the panes are synchronized. /// </summary> /// <param name="primaryPane">The primary GraphPane on which zoom/pan/scroll operations /// are taking place</param> /// <param name="type">The <see cref="ZoomState.StateType" /> that describes the /// current operation</param> /// <returns>The <see cref="ZoomState" /> that corresponds to the /// <see paramref="primaryPane" />. /// </returns> private ZoomState ZoomStateSave(GraphPane primaryPane, ZoomState.StateType type) { ZoomStateClear(); if (_isSynchronizeXAxes || _isSynchronizeYAxes) { foreach (var pane in _masterPane.PaneList.Where(p => p is GraphPane).Cast <GraphPane>()) { var state = new ZoomState(pane, type); if (pane == primaryPane) { _zoomState = state; } _zoomStateStack.Add(state); } } else { _zoomState = new ZoomState(primaryPane, type); } return(_zoomState); }
/// <summary> /// Save the current states of the GraphPanes to a separate collection. Save a single /// (<see paramref="primaryPane" />) GraphPane if the panes are not synchronized /// (see <see cref="IsSynchronizeXAxes" /> and <see cref="IsSynchronizeYAxes" />), /// or save a list of states for all GraphPanes if the panes are synchronized. /// </summary> /// <param name="primaryPane">The primary GraphPane on which zoom/pan/scroll operations /// are taking place</param> /// <param name="type">The <see cref="ZoomState.StateType" /> that describes the /// current operation</param> /// <returns>The <see cref="ZoomState" /> that corresponds to the /// <see paramref="primaryPane" />. /// </returns> private ZoomState ZoomStateSave(GraphPane primaryPane, ZoomState.StateType type) { ZoomStateClear(); if (_isSynchronizeXAxes || _isSynchronizeYAxes) { foreach (GraphPane pane in _masterPane._paneList) { ZoomState state = new ZoomState(pane, type); if (pane == primaryPane) { _zoomState = state; } _zoomStateStack.Add(state); } } else { _zoomState = new ZoomState(primaryPane, type); } return(_zoomState); }
/// <summary> /// Save the current states of the GraphPanes to a separate collection. Save a single /// (<see paramref="primaryPane" />) GraphPane if the panes are not synchronized /// (see <see cref="IsSynchronizeXAxes" /> and <see cref="IsSynchronizeYAxes" />), /// or save a list of states for all GraphPanes if the panes are synchronized. /// </summary> /// <param name="primaryPane">The primary GraphPane on which zoom/pan/scroll operations /// are taking place</param> /// <param name="type">The <see cref="ZoomState.StateType" /> that describes the /// current operation</param> /// <returns>The <see cref="ZoomState" /> that corresponds to the /// <see paramref="primaryPane" />. /// </returns> private ZoomState ZoomStateSave( GraphPane primaryPane, ZoomState.StateType type ) { ZoomStateClear(); if ( _isSynchronizeXAxes || _isSynchronizeYAxes ) { foreach ( GraphPane pane in _masterPane._paneList ) { ZoomState state = new ZoomState( pane, type ); if ( pane == primaryPane ) _zoomState = state; _zoomStateStack.Add( state ); } } else _zoomState = new ZoomState( primaryPane, type ); return _zoomState; }
// Respond to a Zoom Event private void MyZoomEvent( ZedGraphControl control, ZoomState oldState, ZoomState newState) { // Here we get notification everytime the user zooms }
private void MyZoomEvent(ZedGraph.ZedGraphControl control, ZoomState oldState, ZoomState newState) { }
/// <summary> /// Default Constructor /// </summary> public ZedGraphControl() { InitializeComponent(); // These commands do nothing, but they get rid of the compiler warnings for // unused events bool b = MouseDown == null || MouseUp == null || MouseMove == null; // Link in these events from the base class, since we disable them from this class. base.MouseDown += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseDown ); base.MouseUp += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseUp ); base.MouseMove += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseMove ); //this.MouseWheel += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseWheel ); // Use double-buffering for flicker-free updating: SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true ); //isTransparentBackground = false; //SetStyle( ControlStyles.Opaque, false ); SetStyle( ControlStyles.SupportsTransparentBackColor, true ); //this.BackColor = Color.Transparent; _resourceManager = new ResourceManager( "VixenModules.App.Curves.ZedGraph.ZedGraphLocale", Assembly.GetExecutingAssembly()); Rectangle rect = new Rectangle( 0, 0, this.Size.Width, this.Size.Height ); _masterPane = new MasterPane( "", rect ); _masterPane.Margin.All = 0; _masterPane.Title.IsVisible = false; string titleStr = _resourceManager.GetString( "title_def" ); string xStr = _resourceManager.GetString( "x_title_def" ); string yStr = _resourceManager.GetString( "y_title_def" ); //GraphPane graphPane = new GraphPane( rect, "Title", "X Axis", "Y Axis" ); GraphPane graphPane = new GraphPane( rect, titleStr, xStr, yStr ); using ( Graphics g = this.CreateGraphics() ) { graphPane.AxisChange( g ); //g.Dispose(); } _masterPane.Add( graphPane ); this.hScrollBar1.Minimum = 0; this.hScrollBar1.Maximum = 100; this.hScrollBar1.Value = 0; this.vScrollBar1.Minimum = 0; this.vScrollBar1.Maximum = 100; this.vScrollBar1.Value = 0; _xScrollRange = new ScrollRange( true ); _yScrollRangeList = new ScrollRangeList(); _y2ScrollRangeList = new ScrollRangeList(); _yScrollRangeList.Add( new ScrollRange( true ) ); _y2ScrollRangeList.Add( new ScrollRange( false ) ); _zoomState = null; _zoomStateStack = new ZoomStateStack(); }
void zgc_ScrollProgressEvent( ZedGraphControl sender, ScrollBar scrollBar, ZoomState oldState, ZoomState newState ) { //this.toolStripStatusLabel1.Text = sender.GraphPane.XAxis.Scale.Max.ToString(); // When scroll action is finished, recalculate the axis ranges sender.AxisChange(); sender.Refresh(); }
/// <summary> /// Handler for the "Set Scale to Default" context menu item. Sets the scale ranging to /// full auto mode for all axes. /// </summary> /// <remarks> /// This method differs from the <see cref="ZoomOutAll" /> method in that it sets the scales /// to full auto mode. The <see cref="ZoomOutAll" /> method sets the scales to their initial /// setting prior to any user actions (which may or may not be full auto mode). /// </remarks> /// <param name="primaryPane">The <see cref="GraphPane" /> object which is to have the /// scale restored</param> public void RestoreScale(GraphPane primaryPane) { if (primaryPane != null) { //Go ahead and save the old zoomstates, which provides an "undo"-like capability //ZoomState oldState = primaryPane.ZoomStack.Push( primaryPane, ZoomState.StateType.Zoom ); ZoomState oldState = new ZoomState(primaryPane, ZoomState.StateType.Zoom); using (Graphics g = this.CreateGraphics()) { if (_isSynchronizeXAxes || _isSynchronizeYAxes) { foreach (GraphPane pane in _masterPane._paneList) { pane.ZoomStack.Push(pane, ZoomState.StateType.Zoom); ResetAutoScale(pane, g); } } else { primaryPane.ZoomStack.Push(primaryPane, ZoomState.StateType.Zoom); ResetAutoScale(primaryPane, g); } // Provide Callback to notify the user of zoom events if (this.ZoomEvent != null) this.ZoomEvent(this, oldState, new ZoomState(primaryPane, ZoomState.StateType.Zoom)); //g.Dispose(); } Refresh(); } }
/// <summary> /// Clear the collection of saved states. /// </summary> private void ZoomStateClear() { _zoomStateStack.Clear(); _zoomState = null; }
void ScrollTest_ScrollProgressEvent( ZedGraphControl sender, ScrollBar scrollBar, ZoomState oldState, ZoomState newState ) { //MessageBox.Show( "ScrollProgressEvent" ); }
/// <summary> /// Add a new <see cref="ZoomState" /> object to the <see cref="ZoomStateStack" />. /// </summary> /// <param name="state">The <see cref="ZoomState" /> object to be added.</param> public void Add( ZoomState state ) { List.Add( state ); }
void zg_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState) { _autoScrollSize = null; }
/// <summary> /// Add the scale range information from the specified <see cref="GraphPane"/> object as a /// new <see cref="ZoomState"/> entry on the stack. /// </summary> /// <param name="pane">The <see cref="GraphPane"/> object from which the scale range /// information should be copied.</param> /// <param name="type">A <see cref="ZoomState.StateType"/> enumeration that indicates whether this /// state is the result of a zoom or pan operation.</param> /// <returns>The resultant <see cref="ZoomState"/> object that was pushed on the stack.</returns> public ZoomState Push( GraphPane pane, ZoomState.StateType type ) { ZoomState state = new ZoomState( pane, type ); List.Add( state ); return state; }
/// <summary> /// Add the scale range information from the specified <see cref="ZoomState"/> object as a /// new <see cref="ZoomState"/> entry on the stack. /// </summary> /// <param name="state">The <see cref="ZoomState"/> object to be placed on the stack.</param> /// <returns>The <see cref="ZoomState"/> object (same as the <see paramref="state"/> /// parameter).</returns> public ZoomState Push(ZoomState state) { this.List.Add(state); return(state); }
/// <summary> /// Add the scale range information from the specified <see cref="ZoomState"/> object as a /// new <see cref="ZoomState"/> entry on the stack. /// </summary> /// <param name="state">The <see cref="ZoomState"/> object to be placed on the stack.</param> /// <returns>The <see cref="ZoomState"/> object (same as the <see paramref="state"/> /// parameter).</returns> public ZoomState Push( ZoomState state ) { List.Add( state ); return state; }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="ZoomState"/> object from which to copy</param> public ZoomState(ZoomState rhs) { this.xAxis = new ScaleState(rhs.xAxis); this.yAxis = new ScaleState(rhs.yAxis); this.y2Axis = new ScaleState(rhs.y2Axis); }
private void Graph_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState) { PauseUpdateGraph(); }
/// <summary> /// Default Constructor /// </summary> public ZedGraphControl() { InitializeComponent(); InitializeComponentPartial(); this._tooltip = ValuesToolTip.Create(this, this.pointToolTip); // These commands do nothing, but they get rid of the compiler warnings for // unused events bool b = MouseDown == null || MouseUp == null || MouseMove == null; // Link in these events from the base class, since we disable them from this class. base.MouseDown += ZedGraphControl_MouseDown; base.MouseUp += ZedGraphControl_MouseUp; base.MouseMove += ZedGraphControl_MouseMove; //this.MouseWheel += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseWheel ); // Use double-buffering for flicker-free updating: SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true); //isTransparentBackground = false; //SetStyle( ControlStyles.Opaque, false ); SetStyle(ControlStyles.SupportsTransparentBackColor, true); //this.BackColor = Color.Transparent; Rectangle rect = new Rectangle(0, 0, this.Size.Width, this.Size.Height); _masterPane = new MasterPane("", rect); _masterPane.Margin.All = 0; _masterPane.Title.IsVisible = false; string titleStr = ZedGraphLocale.title_def; string xStr = ZedGraphLocale.x_title_def; string yStr = ZedGraphLocale.y_title_def; //GraphPane graphPane = new GraphPane( rect, "Title", "X Axis", "Y Axis" ); GraphPane graphPane = new GraphPane(rect, titleStr, xStr, yStr); using (Graphics g = this.CreateGraphics()) { graphPane.AxisChange(g); //g.Dispose(); } _masterPane.Add(graphPane); this.hScrollBar1.Minimum = 0; this.hScrollBar1.Maximum = 100; this.hScrollBar1.Value = 0; this.vScrollBar1.Minimum = 0; this.vScrollBar1.Maximum = 100; this.vScrollBar1.Value = 0; _xScrollRange = new ScrollRange(true); YScrollRangeList.Add(new ScrollRange(true)); Y2ScrollRangeList.Add(new ScrollRange(false)); _zoomState = null; _zoomStateStack = new ZoomStateStack(); _graphDragState = new GraphDragState(); CrossHairFontSpec = new FontSpec { FontColor = Color.Black, Size = 9, Border = { IsVisible = true }, Fill = { Color = Color.Beige, Brush = new SolidBrush(Color.Beige) }, TextBrush = new SolidBrush(Color.Black) }; }
/// <summary> /// Add the scale range information from the specified <see cref="ZoomState"/> object as a /// new <see cref="ZoomState"/> entry on the stack. /// </summary> /// <param name="state">The <see cref="ZoomState"/> object to be placed on the stack.</param> public void Push(ZoomState state) { this.List.Add(state); }
void zgc_ScrollDoneEvent( ZedGraphControl sender, ScrollBar scrollBar, ZoomState oldState, ZoomState newState ) { // When scroll action is finished, recalculate the axis ranges sender.AxisChange(); sender.Refresh(); }
/// <summary> /// Use the MouseCaptureChanged as an indicator for the start and end of a scrolling operation /// </summary> private void ScrollBarMouseCaptureChanged(object sender, EventArgs e) { var scrollBar = sender as ScrollBar; if (scrollBar != null) { // If this is the start of a new scroll, then Capture will be true if (scrollBar.Capture) { // save the original zoomstate //_zoomState = new ZoomState( this.GraphPane, ZoomState.StateType.Scroll ); ZoomStateSave(GraphPane, ZoomState.StateType.Scroll); } else { // push the prior saved zoomstate, since the scale ranges have already been changed on // the fly during the scrolling operation if (_zoomState != null && _zoomState.IsChanged(GraphPane)) { //this.GraphPane.ZoomStack.Push( _zoomState ); ZoomStatePush(GraphPane); // Provide Callback to notify the user of pan events if (ScrollDoneEvent != null) ScrollDoneEvent(this, scrollBar, _zoomState, new ZoomState(GraphPane, ZoomState.StateType.Scroll)); _zoomState = null; } } } }
void MSGraphControl_ZoomEvent( ZedGraphControl sender, ZoomState oldState, ZoomState newState, PointF mousePosition ) { MSGraphPane pane = MasterPane.FindChartRect(mousePosition) as MSGraphPane; if( pane == null ) mousePosition = PointToClient(new Point(ContextMenuStrip.Left, ContextMenuStrip.Top)); pane = MasterPane.FindChartRect( mousePosition ) as MSGraphPane; if( pane == null ) return; Graphics g = CreateGraphics(); pane.SetScale(g); if( IsSynchronizeXAxes ) { foreach( MSGraphPane syncPane in MasterPane.PaneList ) { if( syncPane == pane ) continue; syncPane.SetScale(g); } } Refresh(); }
private void Zoom(ZedGraphControl sender, ZoomState oldState, ZoomState newState) { sender.GraphPane.XAxis.CrossAuto = false; sender.GraphPane.YAxis.CrossAuto = false; if ((sender.GraphPane.XAxis.Scale.Max - sender.GraphPane.XAxis.Scale.Min) < 0.2) { sender.ZoomOut(sender.GraphPane); } }
/// <summary> /// Handler for the "Undo All Zoom/Pan" context menu item. Restores the scale ranges to the values /// before all zoom and pan operations /// </summary> /// <remarks> /// This method differs from the <see cref="RestoreScale" /> method in that it sets the scales /// to their initial setting prior to any user actions. The <see cref="RestoreScale" /> method /// sets the scales to full auto mode (regardless of what the initial setting may have been). /// </remarks> /// <param name="primaryPane">The <see cref="GraphPane" /> object which is to be zoomed out</param> public void ZoomOutAll(GraphPane primaryPane) { if (primaryPane != null && !primaryPane.ZoomStack.IsEmpty) { ZoomState.StateType type = primaryPane.ZoomStack.Top.Type; ZoomState oldState = new ZoomState(primaryPane, type); //ZoomState newState = pane.ZoomStack.PopAll( pane ); ZoomState newState = null; if (_isSynchronizeXAxes || _isSynchronizeYAxes) { foreach (GraphPane pane in _masterPane._paneList) { ZoomState state = pane.ZoomStack.PopAll(pane); if (pane == primaryPane) newState = state; } } else newState = primaryPane.ZoomStack.PopAll(primaryPane); // Provide Callback to notify the user of zoom events if (this.ZoomEvent != null) this.ZoomEvent(this, oldState, newState); Refresh(); } }
private void Graph_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState) { _isUpdateAxis = false; }
protected override void DoTest() { // IsPauseForScreenShots = true; RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("SplitGraphUnitTest.sky"))); CollectionAssert.AreEqual(new[]{"SplitGraph_rev1.clib"}, SkylineWindow.Document.Settings.PeptideSettings.Libraries.LibrarySpecs .Select(spec => Path.GetFileName(spec.FilePath)).ToArray()); WaitForDocumentLoaded(); // Test that AutoZoomNone and AutoZoomBestPeak work var graphChromatogram = Application.OpenForms.OfType<GraphChromatogram>().First(); var graphChromatogramGraphControl = AllControls(graphChromatogram).OfType<ZedGraphControl>().First(); RunUI(() => { // Select the first transition group SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo(2, 0); SkylineWindow.AutoZoomBestPeak(); // Make sure that we are zoomed in to approximately the best peak Assert.AreEqual(graphChromatogramGraphControl.GraphPane.XAxis.Scale.Min, 13.0, 1.0); Assert.AreEqual(graphChromatogramGraphControl.GraphPane.XAxis.Scale.Max, 14.0, 1.0); // Remember the zoom state so that we can pretend to manually zoom later var zoomStateAuto = new ZoomState(graphChromatogramGraphControl.GraphPane, ZoomState.StateType.Zoom); SkylineWindow.AutoZoomNone(); Assert.AreEqual(graphChromatogramGraphControl.GraphPane.XAxis.Scale.Min, 0.0, 1.0); Assert.AreEqual(graphChromatogramGraphControl.GraphPane.XAxis.Scale.Max, 35.0, 1.0); // Pretend to manually zoom zoomStateAuto.ApplyState(graphChromatogramGraphControl.GraphPane); Assert.AreEqual(graphChromatogramGraphControl.GraphPane.XAxis.Scale.Min, 13.0, 1.0); // Select some other transition group: SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo(2, 1); SkylineWindow.ShowPeakAreaReplicateComparison(); }); WaitForGraphs(); // Ensure that we zoomed out when the selected transition group changed Assert.AreEqual(graphChromatogramGraphControl.GraphPane.XAxis.Scale.Min, 0.0, 1.0); var peakAreaSummary = Application.OpenForms.OfType<GraphSummary>().First(); var graphLibraryMatch = Application.OpenForms.OfType<GraphSpectrum>().First(); var libraryMatchGraphControl = AllControls(graphLibraryMatch).OfType<ZedGraphControl>().First(); RunUI(() => { Assert.IsTrue(Settings.Default.ShowLibraryChromatograms); AssertCurveListsSame(graphChromatogram.CurveList, libraryMatchGraphControl.GraphPane.CurveList); AssertCurveListsSame(graphChromatogram.CurveList, peakAreaSummary.GraphControl.GraphPane.CurveList); Assert.AreEqual(9, graphChromatogram.CurveList.Count); Assert.AreEqual(1, graphChromatogramGraphControl.MasterPane.PaneList.Count); Assert.AreEqual(1, peakAreaSummary.GraphControl.MasterPane.PaneList.Count); SkylineWindow.ShowPrecursorTransitions(); Assert.AreEqual(3, graphChromatogram.CurveList.Count); // TODO(nicksh): Enable this when libraries filter based on precursor/product //AssertCurveListsSame(graphChromatogram.CurveList, libraryMatchGraphControl.GraphPane.CurveList); AssertCurveListsSame(graphChromatogram.CurveList, peakAreaSummary.GraphControl.GraphPane.CurveList); SkylineWindow.ShowProductTransitions(); Assert.AreEqual(6, graphChromatogram.CurveList.Count); // TODO(nicksh): Enable this when libraries filter based on precursor/product AssertCurveListsSame(graphChromatogram.CurveList, libraryMatchGraphControl.GraphPane.CurveList); AssertCurveListsSame(graphChromatogram.CurveList, peakAreaSummary.GraphControl.GraphPane.CurveList); SkylineWindow.ShowAllTransitions(); SkylineWindow.ShowSplitChromatogramGraph(true); }); WaitForGraphs(); Assert.AreEqual(2, graphChromatogramGraphControl.MasterPane.PaneList.Count); Assert.AreEqual(2, peakAreaSummary.GraphControl.MasterPane.PaneList.Count); AssertCurveListsSame(graphChromatogram.GetCurveList(graphChromatogramGraphControl.MasterPane.PaneList[0]), peakAreaSummary.GraphControl.MasterPane.PaneList[0].CurveList); AssertCurveListsSame(graphChromatogram.GetCurveList(graphChromatogramGraphControl.MasterPane.PaneList[1]), peakAreaSummary.GraphControl.MasterPane.PaneList[1].CurveList); }
private void chart1_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState) { if (mouseDownLoc.IsEmpty || mouseUpLoc.IsEmpty) { return; } // if zoom rectangle is drawn from right to left, clear all zooming if (mouseDownLoc.X > mouseUpLoc.X && mouseDownLoc.Y > mouseUpLoc.Y ) { sender.ZoomOutAll(sender.GraphPane); RefreshChart(sender); } }
private void ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState) { if (sender == zedGraphControl1) { newState.ApplyState(zedGraphControl2.GraphPane); zedGraphControl2.Invalidate(); zedGraphControl2.AxisChange(); } else { newState.ApplyState(zedGraphControl1.GraphPane); zedGraphControl1.Invalidate(); zedGraphControl1.AxisChange(); } }
private void zgIsolationWindow_ZoomEvent(ZedGraphControl sender, ZoomState oldstate, ZoomState newstate, PointF mousePosition) { RescaleGraph(); }
private void zedSpectrumAnalyzer_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState) { }
private void zg1_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState) { GraphPane myPane = zg1.GraphPane; nudGraphX.Value = (decimal)(myPane.XAxis.Scale.Max-myPane.XAxis.Scale.Min); }
void zg1_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState) { UpdateGraph(); }
void zedGraph_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState) { GraphPane pane = sender.GraphPane; pane.XAxis.Scale.Min = 0; pane.XAxis.Scale.Max = 50; pane.YAxis.Scale.Min = 0; pane.YAxis.Scale.Max = 100; }
private void HandlePanFinish() { // push the prior saved zoomstate, since the scale ranges have already been changed on // the fly during the panning operation if (_zoomState != null && _zoomState.IsChanged(_dragPane)) { //_dragPane.ZoomStack.Push( _zoomState ); ZoomStatePush(_dragPane); // Provide Callback to notify the user of pan events if (ZoomEvent != null) ZoomEvent(this, _zoomState, new ZoomState(_dragPane, ZoomState.StateType.Pan)); _zoomState = null; } }
private void zg1_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState) { try { DrawModes(); DrawErrors(); DrawTime(); } catch { } }
/// <summary> /// Add a new <see cref="ZoomState" /> object to the <see cref="ZoomStateStack" />. /// </summary> /// <param name="state">The <see cref="ZoomState" /> object to be added.</param> public void Add(ZoomState state) { List.Add(state); }