Esempio n. 1
0
        /// <summary>
        /// Zoom a specified pane in or out according to the specified zoom fraction.
        /// </summary>
        /// <remarks>
        /// The zoom will occur on the <see cref="XAxis"/>, <see cref="YAxis"/>, and
        /// <see cref="Y2Axis"/> only if the corresponding flag, <see cref="IsEnableHZoom"/> or
        /// <see cref="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 cref="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 cref="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 (this._isEnableHZoom)
            {
                this.ZoomScale(pane.XAxis, zoomFraction, x, isZoomOnCenter);
                this.ZoomScale(pane.X2Axis, zoomFraction, x2, isZoomOnCenter);
            }

            if (this._isEnableVZoom)
            {
                for (int i = 0; i < pane.YAxisList.Count; i++)
                {
                    this.ZoomScale(pane.YAxisList[i], zoomFraction, y[i], isZoomOnCenter);
                }

                for (int i = 0; i < pane.Y2AxisList.Count; i++)
                {
                    this.ZoomScale(pane.Y2AxisList[i], zoomFraction, y2[i], isZoomOnCenter);
                }
            }

            using (Graphics g = this.CreateGraphics())
            {
                pane.AxisChange(g);

                // g.Dispose();
            }

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

            if (isRefresh)
            {
                this.Refresh();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Restore the scale ranging to automatic mode, and recalculate the
        /// <see cref="Axis"/> scale ranges
        /// </summary>
        /// <param name="pane">
        /// A reference to the <see cref="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 cref="Graph.Scale.MinAuto"/>
        /// <seealso cref="Graph.Scale.MaxAuto"/>
        /// <seealso cref="Graph.Scale.MajorStepAuto"/>
        /// <seealso cref="Graph.Scale.MagAuto"/>
        /// <seealso cref="Graph.Scale.FormatAuto"/>
        public void ResetAutoScale(GraphPane pane, Graphics g)
        {
            this._scale._minAuto = true;
            this._scale._maxAuto = true;
            this._scale._majorStepAuto = true;
            this._scale._minorStepAuto = true;
            this._crossAuto = true;
            this._scale._magAuto = true;

            // this.numDecAuto = true;
            this._scale._formatAuto = true;
            pane.AxisChange(g);
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ZedGraphControl"/> class. Default Constructor
        /// </summary>
        public ZedGraphControl()
        {
            this.InitializeComponent();

            // These commands do nothing, but they get rid of the compiler warnings for
            // unused events
            bool b = this.MouseDown == null || this.MouseUp == null || this.MouseMove == null;

            // Link in these events from the base class, since we disable them from this class.
            base.MouseDown += this.ZedGraphControl_MouseDown;
            base.MouseUp += this.ZedGraphControl_MouseUp;
            base.MouseMove += this.ZedGraphControl_MouseMove;

            // this.MouseWheel += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseWheel );

            // Use double-buffering for flicker-free updating:
            this.SetStyle(
                ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw,
                true);

            // isTransparentBackground = false;
            // SetStyle( ControlStyles.Opaque, false );
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            // this.BackColor = Color.Transparent;
            var asm = Assembly.GetExecutingAssembly();
            var resNames = asm.GetManifestResourceNames();
            foreach (var res in resNames)
            {
                if (res.Contains("ZedGraphLocale"))
                {
                    var r = res.Substring(0, res.Length - 10);
                    this._resourceManager = new ResourceManager(r, asm);
                    break;
                }
            }

            Rectangle rect = new Rectangle(0, 0, this.Size.Width, this.Size.Height);
            this._masterPane = new MasterPane(string.Empty, rect);
            this._masterPane.Margin.All = 0;
            this._masterPane.Title.IsVisible = false;

            string titleStr = this._resourceManager.GetString("title_def");
            string xStr = this._resourceManager.GetString("x_title_def");
            string yStr = this._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();
            }

            this._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;

            this._xScrollRange = new ScrollRange(true);
            this._yScrollRangeList = new ScrollRangeList();
            this._y2ScrollRangeList = new ScrollRangeList();

            this._yScrollRangeList.Add(new ScrollRange(true));
            this._y2ScrollRangeList.Add(new ScrollRange(false));

            this._zoomState = null;
            this._zoomStateStack = new ZoomStateStack();
        }