예제 #1
0
        public FormAddFunction(DataFunctionForm data = null)
        {
            InitializeComponent();

            textBoxFunc.Text = data?.Function?.Function;
            textBoxX.Text    = data?.X?.Vars();
            textBoxP.Text    = data?.P?.Vars();
        }
예제 #2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            Function func = null;
            Vector   x    = null;
            Vector   p    = null;

            try
            {
                if (textBoxFunc.Text == "")
                {
                    throw new Exception("Функция должна быть!!");
                }
                func = new Function(textBoxFunc.Text);
                errorProvider.SetError(label1, "");
                if (textBoxX.Text != "")
                {
                    x = new Vector(textBoxX.Text);
                    if (func.Vars.Count != x.Size)
                    {
                        throw new Exception("Не совпадает количество переменных");
                    }
                }
                errorProvider.SetError(label2, "");
                if (textBoxP.Text != "")
                {
                    p = new Vector(textBoxP.Text);
                    if (func.Vars.Count != p.Size)
                    {
                        throw new Exception("Не совпадает количество переменных");
                    }
                }
                errorProvider.SetError(label3, "");

                DataFunctionForm data = new DataFunctionForm();
                data.Function = func;
                data.X        = x;
                data.P        = p;
                EventNotifyAddFunction?.Invoke(data);
                Close();
            } catch (Exception exc)
            {
                if (func == null)
                {
                    errorProvider.SetError(label1, exc.Message);
                }
                else if (x == null)
                {
                    errorProvider.SetError(label2, exc.Message);
                }
                else if (p == null)
                {
                    errorProvider.SetError(label3, exc.Message);
                }
            }
        }
예제 #3
0
 void GetNewFunction(DataFunctionForm data)
 {
     if (indexUpdateFunction == -1)
     {
         dictionary.Add(dataGridViewFunctions.Rows.Count, data);
         dataGridViewFunctions.Rows.Add(data.Function.Function, data.X?.Vars(), data.P?.Vars());
         dataGridViewFunctions.Rows[dataGridViewFunctions.RowCount - 1].HeaderCell.Value = (dataGridViewFunctions.Rows.Count - 1).ToString();
     }
     else
     {
         dictionary[indexUpdateFunction] = data;
         dataGridViewFunctions.Rows[indexUpdateFunction].SetValues(data.Function.Function, data.X?.Vars(), data.P?.Vars());
         indexUpdateFunction = -1;
     }
     dataGridViewFunctions.Refresh();
 }