Ejemplo n.º 1
0
        private void buttonDraw_Click(object sender, RoutedEventArgs e)
        {
            double xMin = SafeParse(textBoxXMin.Text);
            double xMax = SafeParse(textBoxXMax.Text);

            if (SafeParse(textBoxYMin.Text) >= SafeParse(textBoxYMax.Text))
            {
                if (SafeParse(textBoxYMin.Text) == SafeParse(textBoxYMax.Text) || SafeParse(textBoxYMax.Text) - SafeParse(textBoxYMin.Text) < 1)
                {
                    MessageBox.Show("Incorrect drawing range by y-axis!\nNeed yMin < yMax and yMax - yMin >= 1", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                string temp = textBoxYMin.Text;
                textBoxYMin.Text = textBoxYMax.Text;
                textBoxYMax.Text = temp;
            }
            double yMin = SafeParse(textBoxYMin.Text);
            double yMax = SafeParse(textBoxYMax.Text);

            CanvasBuilder.ClearCanvas(canvas);
            CanvasBuilder.DrawGrid(canvas, xMax, xMin, yMax, yMin);

            CanvasBuilder.DrawPoints(canvas, Brushes.Red, points);
        }
Ejemplo n.º 2
0
        private void buttonDraw_Click(object sender, RoutedEventArgs e)
        {
            // dataGridGx.Items.Refresh();

            if (SafeParse(textBoxXMin.Text) >= SafeParse(textBoxXMax.Text))
            {
                if (SafeParse(textBoxXMin.Text) == SafeParse(textBoxXMax.Text) || SafeParse(textBoxXMax.Text) - SafeParse(textBoxXMin.Text) < 1)
                {
                    MessageBox.Show("Incorrect drawing range by x-axis!\nNeed xMin < xMax and xMax - yMin >= 1", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                string temp = textBoxXMin.Text;
                textBoxXMin.Text = textBoxXMax.Text;
                textBoxXMax.Text = temp;
            }
            double xMin = SafeParse(textBoxXMin.Text);
            double xMax = SafeParse(textBoxXMax.Text);

            if (SafeParse(textBoxYMin.Text) >= SafeParse(textBoxYMax.Text))
            {
                if (SafeParse(textBoxYMin.Text) == SafeParse(textBoxYMax.Text) || SafeParse(textBoxYMax.Text) - SafeParse(textBoxYMin.Text) < 1)
                {
                    MessageBox.Show("Incorrect drawing range by y-axis!\nNeed yMin < yMax and yMax - yMin >= 1", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                string temp = textBoxYMin.Text;
                textBoxYMin.Text = textBoxYMax.Text;
                textBoxYMax.Text = temp;
            }
            double yMin = SafeParse(textBoxYMin.Text);
            double yMax = SafeParse(textBoxYMax.Text);

            CanvasBuilder.ClearCanvas(canvas);
            CanvasBuilder.DrawGrid(canvas, xMax, xMin, yMax, yMin);
            pf.StringFunction = textBoxFunc.Text;
            if (pf.CheckFunc())
            {
                CanvasBuilder.DrawFunction(canvas, Brushes.Blue, pf.F);
            }
            foreach (double i in solutions)
            {
                CanvasBuilder.DrawPoint(canvas, Brushes.Green, 13, i, pf.F(i));
            }
        }