コード例 #1
0
ファイル: TChart.cs プロジェクト: eture-server/Paway.Forms
        private void TChart_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (MouseButtons != MouseButtons.Left)
            {
                return;
            }

            var test = this.HitTest(e.X, e.Y);

            if (test.Object is AxisScrollBar)
            {
                return;
            }

            AxisScaleView view1    = this.ChartAreas[0].AxisX.ScaleView;
            int           interval = start - e.X;
            double        value    = interval * (view1.ViewMaximum - view1.ViewMinimum) * 1 / this.Width / 0.7;

            value = Math.Round(value);
            if (value == 0)
            {
                return;
            }
            if (view1.ViewMaximum + value <= this.ChartAreas[0].AxisX.Maximum && view1.ViewMinimum + value >= this.ChartAreas[0].AxisX.Minimum)
            {
                view1.Position += value;
                start          -= (this.Width * 0.7 * value / (view1.ViewMaximum - view1.ViewMinimum)).ToInt();
            }
        }
コード例 #2
0
 /// <summary>
 /// 检查是否可以调整。确保可以调整。
 /// </summary>
 /// <param name="ScaleView"></param>
 private static void CheckZoomable(AxisScaleView ScaleView)
 {
     if (!ScaleView.IsZoomed)
     {
         ScaleView.Zoom(ScaleView.ViewMinimum, ScaleView.ViewMaximum * 0.999999999);
     }
 }
コード例 #3
0
ファイル: Draw.cs プロジェクト: unclealexkun/CompressingData
        public static bool DrawWave(WaveFile wave, Chart chartcontrol)
        {
            bool isComplited = true;

            if (wave != null)
            {
                // Установка меток оси
                chartcontrol.ChartAreas[0].AxisX.Title = "t";
                chartcontrol.ChartAreas[0].AxisY.Title = "A";
                // Минимальное значение по оси Х, максимальное значение, установки интервала масштабирования
                chartcontrol.ChartAreas[0].AxisX.Minimum  = 0;
                chartcontrol.ChartAreas[0].AxisX.Maximum  = wave.RightData.Length;
                chartcontrol.ChartAreas[0].AxisX.Interval = wave.SamplingRate;
                // Минимальное значение Y-оси, максимальное значение
                chartcontrol.ChartAreas[0].AxisY.Minimum = wave.RightData.Min();
                chartcontrol.ChartAreas[0].AxisY.Maximum = wave.RightData.Max();

                // Отображение полосы прокрутки
                AxisScaleView sv = chartcontrol.ChartAreas[0].AxisX.ScaleView;
                sv.SmallScrollSize = wave.SamplingRate;
                sv.Position        = 1;
                sv.Size            = wave.SamplingRate * 10;
                chartcontrol.ChartAreas[0].AxisX.ScaleView = sv;

                AxisScrollBar sb = chartcontrol.ChartAreas[0].AxisX.ScrollBar;
                sb.ButtonStyle        = ScrollBarButtonStyles.All;
                sb.IsPositionedInside = true;
                chartcontrol.ChartAreas[0].AxisX.ScrollBar = sb;

                Series series = new Series();
                series.ChartType = SeriesChartType.FastLine;

                for (int i = 0; i < wave.LeftData.Length; i++)
                {
                    series.Points.AddXY(i, wave.RightData[i]);
                }

                chartcontrol.Series.Add(series);

                chartcontrol.Invalidate();
            }
            else
            {
                isComplited = false;
            }

            return(isComplited);
        }
コード例 #4
0
ファイル: TChart.cs プロジェクト: eture-server/Paway.Forms
        private void UpdateShow()
        {
            AxisScaleView view1 = this.ChartAreas[0].AxisX.ScaleView;

            if (this.Series.Count == 0)
            {
                return;
            }
            if (this.Series[0].Points.Count * 1.0 * (view1.ViewMaximum - view1.ViewMinimum) / (this.ChartAreas[0].AxisX.Maximum - this.ChartAreas[0].AxisX.Minimum) / this.Width < 0.03)
            {
                this.Series[0].Label = "#VAL";
            }
            else
            {
                this.Series[0].Label = null;
            }
        }
コード例 #5
0
        private void MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }
            if (!WrappedChart.ChartAreas[0].AxisX.ScaleView.IsZoomed)
            {
                return;
            }
            int delta = e.X - lastMousePosX;

            lastMousePosX = e.X;
            AxisScaleView view  = WrappedChart.ChartAreas[0].AxisX.ScaleView;
            double        start = view.ViewMinimum - delta;

            view.Scroll(start);
            for (int i = 0; i < Series.Count; i++)
            {
                ZoomApproximation(Series[i]);
            }
        }
コード例 #6
0
        // Events which initiate approximation.

        private void AxisViewChanged(object sender, ViewEventArgs e)
        {
            if (!e.Axis.Equals(WrappedChart.ChartAreas[0].AxisX))
            {
                return; // if we aren't dealing with X axis ignore that.
            }
            AxisScaleView view = WrappedChart.ChartAreas[0].AxisX.ScaleView;

            if (view.IsZoomed)
            {
                for (int i = 0; i < Series.Count; i++)
                {
                    ZoomApproximation(Series[i]);
                }
            }
            else
            {
                for (int i = 0; i < Series.Count; i++)
                {
                    ApproximateSeries(Series[i]);
                }
            }
        }
コード例 #7
0
ファイル: TChart.cs プロジェクト: eture-server/Paway.Forms
        private void TChart_MouseWheel(object sender, MouseEventArgs e)
        {
            if (this.Series.Count == 0 || this.Series[0].Points.Count < 3)
            {
                return;
            }

            AxisScaleView view1    = this.ChartAreas[0].AxisX.ScaleView;
            double        total    = Math.Abs(e.Delta);
            double        interval = 1;

            for (int i = 0; i < total; i += 120)
            {
                if (e.Delta > 0)
                {
                    interval *= 0.8;
                }
                else
                {
                    interval *= 1.2;
                }
            }
            if (interval > 1 && (view1.ViewMaximum - view1.ViewMinimum) > (this.ChartAreas[0].AxisX.Maximum - this.ChartAreas[0].AxisX.Minimum) * 0.8)
            {
                view1.ZoomReset();
                this.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
                UpdateLine();
                return;
            }
            this.ChartAreas[0].CursorX.IsUserSelectionEnabled = false;
            if (this.ChartAreas[0].AxisX.CustomLabels.Count == 0)
            {
                return;
            }

            string v1 = this.ChartAreas[0].AxisX.CustomLabels[0].Text;
            double value;

            if (this.Series[0].XValueType == ChartValueType.Time)
            {
                var v2 = v1.Split(' ')[0].Split(':');
                value = v2[0].ToInt() * 60 + v2[1].ToInt();
            }
            else
            {
                value = v1.ToDouble();
            }
            double min2 = value - (value - view1.ViewMinimum) * interval;

            min2 = Math.Floor(min2);
            double max2 = value + (view1.ViewMaximum - value) * interval;

            max2 = Math.Ceiling(max2);
            if (interval < 1 && max2 - min2 < minInterval * 3)
            {
                return;
            }
            view1.Zoom(min2, max2);
            UpdateShow();
            UpdateLine();
        }
コード例 #8
0
        private void Zoom(AxisScaleView asv, double coeff)
        {
            double shift = coeff * (asv.ViewMaximum - asv.ViewMinimum);

            asv.Zoom(asv.ViewMinimum + shift, asv.ViewMaximum - shift);
        }
コード例 #9
0
 public AxisSize(AxisScaleView view)
 {
     Min = view.ViewMinimum;
     Max = view.ViewMaximum;
 }