示例#1
0
        private void yAxesSettingButton_Click(object sender, EventArgs e)
        {
            bool pauseState = graphPauseLed.Active;

            graphPauseLed.Active = true;

            for (int i = 0; i < viewGraph.AxesY.Count; i++)
            {
                YAxisRows[i].WholeMin = 0;
                YAxisRows[i].WholeMax = 0;
            }

            FormYAxesSetting form = new FormYAxesSetting(YAxisRows, xAxis.Minutes);

            try
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    if (form.GetYAxesCheckedCount() == 0)
                    {
                        MessageBox.Show("You must check Y-Axis over one!",
                                        Resource.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    if (form.GetYAxesCheckedCount() > 12)
                    {
                        MessageBox.Show("You must check Y-Axis under 12!",
                                        Resource.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    bool resetZoom = false;
                    Cursor = Cursors.WaitCursor;

                    try
                    {
                        xAxis.Minutes = form.Time;
                        InsertXAxis();
                        SetRangeAxisXMinutes(form.Time);

                        foreach (YAxisRow row in form.Axes)
                        {
                            YAxisRows[row.AxisNo].Checked = row.Checked;
                            YAxisRows[row.AxisNo].Align   = row.Align;

                            Axis2D axis = viewGraph.AxesY[row.AxisNo];
                            axis.Alignment  = (row.Align == EAxisAlign.Left) ? AxisAlignment.Near : AxisAlignment.Far;
                            axis.Visibility = (row.Checked == true) ? DefaultBoolean.True : DefaultBoolean.False;

                            YAxisRows[row.AxisNo].VisualMin = (float)((double)axis.WholeRange.MinValue);
                            YAxisRows[row.AxisNo].VisualMax = (float)((double)axis.WholeRange.MaxValue);
                            YAxisRows[row.AxisNo].WholeMin  = (float)((double)axis.WholeRange.MinValue);
                            YAxisRows[row.AxisNo].WholeMax  = (float)((double)axis.WholeRange.MaxValue);

                            if ((row.WholeMin != 0) || (row.WholeMax != 0))
                            {
                                if (row.WholeMin < row.WholeMax)
                                {
                                    resetZoom = true;

                                    YAxisRows[row.AxisNo].VisualMin = row.WholeMin;
                                    YAxisRows[row.AxisNo].VisualMax = row.WholeMax;
                                    YAxisRows[row.AxisNo].WholeMin  = row.WholeMin;
                                    YAxisRows[row.AxisNo].WholeMax  = row.WholeMax;

                                    axis.WholeRange.MinValue  = row.WholeMin;
                                    axis.WholeRange.MaxValue  = row.WholeMax;
                                    axis.VisualRange.MinValue = row.WholeMin;
                                    axis.VisualRange.MaxValue = row.WholeMax;
                                }
                            }
                        }

                        if (resetZoom == true)
                        {
                            ViewGraph.Zooming.Clear();
                        }

                        viewGraph.InvalidateSeries();
                        InsertYAxes();
                    }
                    finally
                    {
                        Cursor = Cursors.Default;
                    }
                }
            }
            finally
            {
                graphPauseLed.Active = pauseState;
            }
        }
示例#2
0
        private void yAxesSettingButton_Click(object sender, EventArgs e)
        {
            if (viewGraph.BufferedSeries.PointsCount == 0)
            {
                return;
            }

            for (int i = 0; i < viewGraph.AxesY.Count; i++)
            {
                YAxisRows[i].WholeMin = 0;
                YAxisRows[i].WholeMax = 0;
            }

            FormYAxesSetting form = new FormYAxesSetting(YAxisRows);

            if (form.ShowDialog() == DialogResult.OK)
            {
                if (form.GetYAxesCheckedCount() == 0)
                {
                    MessageBox.Show("You must check Y-Axis over one!",
                                    Resource.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (form.GetYAxesCheckedCount() > 12)
                {
                    MessageBox.Show("You must check Y-Axis under 12!",
                                    Resource.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                bool resetZoom = false;
                Cursor = Cursors.WaitCursor;

                try
                {
                    foreach (YAxisRow row in form.Axes)
                    {
                        YAxisRows[row.AxisNo].Checked = row.Checked;
                        YAxisRows[row.AxisNo].Align   = row.Align;

                        Axis2D axis = viewGraph.AxesY[row.AxisNo];
                        axis.Alignment  = (row.Align == EAxisAlign.Left) ? AxisAlignment.Near : AxisAlignment.Far;
                        axis.Visibility = (row.Checked == true) ? DefaultBoolean.True : DefaultBoolean.False;

                        YAxisRows[row.AxisNo].VisualMin = (float)((double)axis.WholeRange.MinValue);
                        YAxisRows[row.AxisNo].VisualMax = (float)((double)axis.WholeRange.MaxValue);
                        YAxisRows[row.AxisNo].WholeMin  = (float)((double)axis.WholeRange.MinValue);
                        YAxisRows[row.AxisNo].WholeMax  = (float)((double)axis.WholeRange.MaxValue);

                        if ((row.WholeMin != 0) || (row.WholeMax != 0))
                        {
                            if (row.WholeMin < row.WholeMax)
                            {
                                resetZoom = true;

                                YAxisRows[row.AxisNo].VisualMin = row.WholeMin;
                                YAxisRows[row.AxisNo].VisualMax = row.WholeMax;
                                YAxisRows[row.AxisNo].WholeMin  = row.WholeMin;
                                YAxisRows[row.AxisNo].WholeMax  = row.WholeMax;

                                axis.WholeRange.MinValue  = row.WholeMin;
                                axis.WholeRange.MaxValue  = row.WholeMax;
                                axis.VisualRange.MinValue = row.WholeMin;
                                axis.VisualRange.MaxValue = row.WholeMax;
                            }
                        }
                    }

                    if (resetZoom == true)
                    {
                        ViewGraph.Zooming.Clear();

                        Axis2D axis      = viewGraph.AxesX[0];
                        double wholeMin  = (double)axis.WholeRange.MinValue;
                        double wholeMax  = (double)axis.WholeRange.MaxValue;
                        double visualMin = (double)axis.VisualRange.MinValue;
                        double visualMax = (double)axis.VisualRange.MaxValue;

                        if ((wholeMin != visualMin) || (wholeMax != visualMax))
                        {
                            EZoomAxis zoomAxis = viewGraph.Zooming.ZoomAxis;
                            SetMaxRangeAxisX(MaxRangeAxisX);

                            viewGraph.Zooming.ZoomAxis = EZoomAxis.Both;
                            viewGraph.Zooming.Push();
                            viewGraph.Zooming.ZoomAxis = zoomAxis;

                            viewGraph.VisualRangeChanging = true;
                            axis.WholeRange.MinValue      = wholeMin;
                            axis.WholeRange.MaxValue      = wholeMax;
                            axis.VisualRange.MinValue     = visualMin;
                            axis.VisualRange.MaxValue     = visualMax;
                            viewGraph.VisualRangeChanging = false;
                        }
                    }

                    viewGraph.InvalidateSeries();
                    InsertYAxes();
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            }
        }