public void CutOff(ChartRect rect)
 {
     X.Min = Math.Max(X.Min, rect.X.Min);
     X.Max = Math.Min(X.Max, rect.X.Max);
     Y.Min = Math.Max(Y.Min, rect.Y.Min);
     Y.Max = Math.Min(Y.Max, rect.Y.Max);
 }
Exemple #2
0
        private void ChartControl_MouseWheel(object sender, MouseEventArgs e)
        {
            ChartRect newZoom = new ChartRect(_ptrChartArea);

            ScaleViewZoom(e.Delta, ref newZoom.X);
            ScaleViewZoom(e.Delta, ref newZoom.Y);
            UpdateAxis(newZoom, true);
            ViewChanged?.Invoke(this, _ptrChartArea);
        }
Exemple #3
0
        public void UpdateAxis(ChartRect newView = null, bool isUpdateY = false, bool isResetZoom = false, bool isUpdateBorder = false)
        {
            var curView      = new ChartRect(_ptrChartArea);
            var globalBorder = new ChartRect(_ptrChartArea, true);

            if (isUpdateBorder)
            {
                globalBorder        = new ChartRect(GlobalBorder);
                globalBorder.Y.Min -= 2;
                globalBorder.Y.Max += YMinZoom * 10.0;
                _ptrAxisX.Minimum   = globalBorder.X.Min;
                _ptrAxisX.Maximum   = globalBorder.X.Max;
                _ptrAxisY.Minimum   = globalBorder.Y.Min;
                _ptrAxisY.Maximum   = globalBorder.Y.Max;
            }
            if (isResetZoom)
            {
                curView.X = globalBorder.X;
                curView.Y = Border.Y;
            }
            else
            {
                if (newView != null)
                {
                    //X
                    curView.X = newView.X;
                    //Y
                    if (isUpdateY)
                    {
                        curView.Y = newView.Y;
                    }
                }
            }
            var oldView = new ChartRect(_ptrChartArea);

            if (curView.X.Check(oldView.X, XMinZoom, globalBorder.X))
            {
                _ptrAxisX.ScaleView.Zoom(curView.X.Min, curView.X.Max);
            }
            if (curView.Y.Check(oldView.Y, YMinZoom, globalBorder.Y))
            {
                _ptrAxisY.ScaleView.Zoom(curView.Y.Min, curView.Y.Max);
            }
        }
 public ChartRect(ChartRect other)
 {
     X = other.X;
     Y = other.Y;
 }