/// <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();
            }
        }
Ejemplo n.º 2
0
 /// <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 "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();
            }
        }
Ejemplo n.º 4
0
 /// <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);
 }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
        /// <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;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Clear the collection of saved states.
 /// </summary>
 private void ZoomStateClear()
 {
     _zoomStateStack.Clear();
     _zoomState = null;
 }
Ejemplo n.º 8
0
        /// <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;

            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 = Properties.Resources.Zedgraph_title_def;
            string xStr = Properties.Resources.Zedgraph_x_title_def;
            string yStr = Properties.Resources.Zedgraph_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();
        }
        /// <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>
        /// 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();
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Clear the collection of saved states.
 /// </summary>
 private void ZoomStateClear()
 {
     _zoomStateStack.Clear();
     _zoomState = null;
 }
Ejemplo n.º 12
0
        /// <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;

            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 = Properties.Resources.Zedgraph_title_def;
            string xStr     = Properties.Resources.Zedgraph_x_title_def;
            string yStr     = Properties.Resources.Zedgraph_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();
        }