Esempio n. 1
0
File: Axis.cs Progetto: CareyGit/jx
        /// <summary>
        /// Restore the scale ranging to automatic mode, and recalculate the
        /// <see c_ref="Axis"/> scale ranges
        /// </summary>
        /// <param name="pane">
        /// A reference to the <see c_ref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <seealso c_ref="ZedGraph.Scale.MinAuto"/>
        /// <seealso c_ref="ZedGraph.Scale.MaxAuto"/>
        /// <seealso c_ref="ZedGraph.Scale.MajorStepAuto"/>
        /// <seealso c_ref="ZedGraph.Scale.MagAuto"/>
        /// <seealso c_ref="ZedGraph.Scale.FormatAuto"/>
        public void ResetAutoScale( GraphPane pane, Graphics g )
		{
			_scale._minAuto = true;
			_scale._maxAuto = true;
			_scale._majorStepAuto = true;
			_scale._minorStepAuto = true;
			_crossAuto = true;
			_scale._magAuto = true;
			//this.numDecAuto = true;
			_scale._formatAuto = true;
			pane.AxisChange( g );
		}
Esempio n. 2
0
		/// <summary>
		/// Default Constructor
		/// </summary>
		public GraphControl()
		{
			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 += 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;

            _resourceManager = new ResourceManager("UIGraphLib.GraphLocale",
				Assembly.GetExecutingAssembly() );

			Rectangle rect = new Rectangle( 0, 0, Size.Width, 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 = CreateGraphics() )
			{
				graphPane.AxisChange( g );
				//g.Dispose();
			}
			_masterPane.Add( graphPane );

			hScrollBar1.Minimum = 0;
			hScrollBar1.Maximum = 100;
			hScrollBar1.Value = 0;

			vScrollBar1.Minimum = 0;
			vScrollBar1.Maximum = 100;
			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();
		}
Esempio n. 3
0
		/// <summary>
		/// Zoom a specified pane in or out according to the specified zoom fraction.
		/// </summary>
		/// <remarks>
		/// The zoom will occur on the <see c_ref="XAxis" />, <see c_ref="YAxis" />, and
		/// <see c_ref="Y2Axis" /> only if the corresponding flag, <see c_ref="IsEnableHZoom" /> or
		/// <see c_ref="IsEnableVZoom" />, is true.  Note that if there are multiple Y or Y2 axes, all of
		/// them will be zoomed.
		/// </remarks>
		/// <param name="pane">The <see c_ref="GraphPane" /> instance to be zoomed.</param>
		/// <param name="zoomFraction">The fraction by which to zoom, less than 1 to zoom in, greater than
		/// 1 to zoom out.  For example, 0.9 will zoom in such that the scale is 90% of what it was
		/// originally.</param>
		/// <param name="centerPt">The screen position about which the zoom will be centered.  This
		/// value is only used if <see paramref="isZoomOnCenter" /> is true.
		/// </param>
		/// <param name="isZoomOnCenter">true to cause the zoom to be centered on the point
		/// <see paramref="centerPt" />, false to center on the <see c_ref="Chart.Rect" />.
		/// </param>
		/// <param name="isRefresh">true to force a refresh of the control, false to leave it unrefreshed</param>
		protected void ZoomPane( GraphPane pane, double zoomFraction, PointF centerPt,
					bool isZoomOnCenter, bool isRefresh )
		{
			double x;
			double x2;
			double[] y;
			double[] y2;

			pane.ReverseTransform( centerPt, out x, out x2, out y, out y2 );

			if ( _isEnableHZoom )
			{
				ZoomScale( pane.XAxis, zoomFraction, x, isZoomOnCenter );
				ZoomScale( pane.X2Axis, zoomFraction, x2, isZoomOnCenter );
			}
			if ( _isEnableVZoom )
			{
				for ( int i = 0; i < pane.YAxisList.Count; i++ )
					ZoomScale( pane.YAxisList[i], zoomFraction, y[i], isZoomOnCenter );
				for ( int i = 0; i < pane.Y2AxisList.Count; i++ )
					ZoomScale( pane.Y2AxisList[i], zoomFraction, y2[i], isZoomOnCenter );
			}

			using ( Graphics g = CreateGraphics() )
			{
				pane.AxisChange( g );
				//g.Dispose();
			}

			SetScroll( hScrollBar1, pane.XAxis, _xScrollRange.Min, _xScrollRange.Max );
			SetScroll( vScrollBar1, pane.YAxis, _yScrollRangeList[0].Min,
				_yScrollRangeList[0].Max );

			if ( isRefresh )
				Refresh();
		}