Example #1
0
        private void alterFunction_Click(object sender, RoutedEventArgs e)
        {
            InputIndex i = new InputIndex(controller)
            {
                Title = "Изменение по индексу"
            };

            i.ShowDialog();
            if (!i.IsOK)
            {
                return;
            }
            AddFunction alter = new AddFunction()
            {
                Title = "Изменение"
            };

            ChartingObject obj = controller.getAllChartings()[i.Index - 1];

            alter.name_txt.Text     = obj.Name;
            alter.function_txt.Text = obj.Function;
            alter.step_txt.Text     = obj.Step.ToString();
            alter.min_txt.Text      = obj.Min.ToString();
            alter.max_txt.Text      = obj.Max.ToString();
            alter.ShowDialog();
            if (!alter.IsOK)
            {
                return;
            }
            if (!controller.alterFunction(i.Index - 1, alter.Name, alter.Function,
                                          alter.Step, alter.Min, alter.Max))
            {
                MessageBox.Show("Не могу изменить функцию: индекс = " + i.Index +
                                " за пределами диапазона!");
                return;
            }
            elementsPanel.Children.RemoveAt(i.Index - 1);
            GraphicsElement ge = showFunction(i.Index,
                                              alter.Name, alter.Function, alter.Step,
                                              alter.Min, alter.Max);

            elementsPanel.Children.Insert(i.Index - 1, ge);
            MessageBox.Show("График функции '" + alter.Name + "' изменен!");
        }
Example #2
0
        private void addFunction_Click(object sender, RoutedEventArgs e)
        {
            AddFunction f = new AddFunction()
            {
                Title = "Добавление"
            };

            f.ShowDialog();
            if (!f.IsOK)
            {
                return;
            }
            if (!controller.addFunction(f.Name, f.Function, f.Step, f.Min, f.Max))
            {
                MessageBox.Show("Невозможно добавить график: непредвиденное исключение!");
                return;
            }
            addGraphic(controller.getAllChartings().Count,
                       f.Name, f.Function, f.Step, f.Min, f.Max);
            MessageBox.Show("График функции '" + f.Name + "' добавлен!");
        }