Exemple #1
0
        /// <summary>
        /// Редактировать формулу
        /// </summary>
        /// <param name="Selected">Выборанный элемент в сиписке</param>
        /// <param name="Edit">Редактируемая формула</param>
        private void EditFormula(ListViewItem Selected, Formula Edit)
        {
            switch (Edit.Type)
            {
            case FormulaType.Constant:

                AddConstantForm const_frm = new AddConstantForm(app);

                const_frm.Value   = Edit.Macros.Value;
                const_frm.Comment = Edit.Macros.Description;

                const_frm.checkBox1.Visible = false;
                const_frm.Number            = Edit.Position;

                if (const_frm.ShowDialog(this) == DialogResult.OK)
                {
                    Edit.Position     = const_frm.Number;
                    Edit.Macros.Value = const_frm.Value;

                    Edit.Macros.Description = const_frm.Comment;

                    UpdateFormula(Selected, Edit);
                }
                break;

            case FormulaType.Assignment:

                AddAssignmentForm assignment_frm = new AddAssignmentForm(app);

                assignment_frm.Comment = Edit.Macros.Description;

                assignment_frm.Number   = Edit.Position;
                assignment_frm.Position = Edit.Macros.Args[0].Index;

                assignment_frm.checkBox1.Visible = false;

                if (assignment_frm.ShowDialog(this) == DialogResult.OK)
                {
                    Edit.Position = assignment_frm.Number;

                    Edit.Macros.Args[0].Index  = assignment_frm.Position;
                    Edit.Macros.Args[0].Source = DataSource.Signals;

                    Edit.Macros.Description = assignment_frm.Comment;
                    UpdateFormula(Selected, Edit);
                }
                break;

            case FormulaType.Summa:

                AddSummaNewForm summa_frm = new AddSummaNewForm(app);

                summa_frm.FirstArg   = Edit.Macros.Args[0];
                summa_frm.SecondtArg = Edit.Macros.Args[1];

                summa_frm.Comment           = Edit.Macros.Description;
                summa_frm.checkBox1.Visible = false;

                summa_frm.Number = Edit.Position;

                if (summa_frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (summa_frm.FirstArg != null && summa_frm.SecondtArg != null)
                    {
                        Edit.Position = summa_frm.Number;

                        Edit.Macros.Args[0] = summa_frm.FirstArg;
                        Edit.Macros.Args[1] = summa_frm.SecondtArg;

                        Edit.Macros.Description = summa_frm.Comment;
                        UpdateFormula(Selected, Edit);
                    }
                }
                break;

            case FormulaType.Difference:

                AddDifferenceNewForm difference_frm = new AddDifferenceNewForm(app);

                difference_frm.FirstArg   = Edit.Macros.Args[0];
                difference_frm.SecondtArg = Edit.Macros.Args[1];

                difference_frm.Comment           = Edit.Macros.Description;
                difference_frm.checkBox1.Visible = false;

                difference_frm.Number = Edit.Position;

                if (difference_frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (difference_frm.FirstArg != null && difference_frm.SecondtArg != null)
                    {
                        Edit.Position = difference_frm.Number;

                        Edit.Macros.Args[0] = difference_frm.FirstArg;
                        Edit.Macros.Args[1] = difference_frm.SecondtArg;

                        Edit.Macros.Description = difference_frm.Comment;
                        UpdateFormula(Selected, Edit);
                    }
                }
                break;

            case FormulaType.Division:

                AddDivizionNewForm divizion_frm = new AddDivizionNewForm(app);

                divizion_frm.FirstArg   = Edit.Macros.Args[0];
                divizion_frm.SecondtArg = Edit.Macros.Args[1];

                divizion_frm.Comment           = Edit.Macros.Description;
                divizion_frm.checkBox1.Visible = false;

                divizion_frm.Number = Edit.Position;

                if (divizion_frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (divizion_frm.FirstArg != null && divizion_frm.SecondtArg != null)
                    {
                        Edit.Position = divizion_frm.Number;

                        Edit.Macros.Args[0] = divizion_frm.FirstArg;
                        Edit.Macros.Args[1] = divizion_frm.SecondtArg;

                        Edit.Macros.Description = divizion_frm.Comment;
                        UpdateFormula(Selected, Edit);
                    }
                }
                break;

            case FormulaType.Multiplication:

                AddMultiplicationNewForm multiplication_frm = new AddMultiplicationNewForm(app);

                multiplication_frm.FirstArg   = Edit.Macros.Args[0];
                multiplication_frm.SecondtArg = Edit.Macros.Args[1];

                multiplication_frm.Comment           = Edit.Macros.Description;
                multiplication_frm.checkBox1.Visible = false;

                multiplication_frm.Number = Edit.Position;

                if (multiplication_frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (multiplication_frm.FirstArg != null && multiplication_frm.SecondtArg != null)
                    {
                        Edit.Position = multiplication_frm.Number;

                        Edit.Macros.Args[0] = multiplication_frm.FirstArg;
                        Edit.Macros.Args[1] = multiplication_frm.SecondtArg;

                        Edit.Macros.Description = multiplication_frm.Comment;
                        UpdateFormula(Selected, Edit);
                    }
                }
                break;

            case FormulaType.Increment:

                AddIncrementForm increment_frm = new AddIncrementForm(app);

                increment_frm.Position = Edit.Macros.Args[0].Index;
                increment_frm.Comment  = Edit.Macros.Description;

                increment_frm.checkBox1.Visible = false;
                increment_frm.Number            = Edit.Position;

                if (increment_frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (increment_frm.Position > -1)
                    {
                        Edit.Position = increment_frm.Number;

                        Edit.Macros.Args[0].Index = increment_frm.Position;
                        Edit.Macros.Description   = increment_frm.Comment;

                        UpdateFormula(Selected, Edit);
                        (Edit.Macros as Increment).Reset();
                    }
                }

                break;

            case FormulaType.Maximum:

                AddMaximumForm maximum_frm = new AddMaximumForm(app);

                maximum_frm.Position = Edit.Macros.Args[0].Index;
                maximum_frm.Comment  = Edit.Macros.Description;

                maximum_frm.checkBox1.Visible = false;
                maximum_frm.Number            = Edit.Position;

                if (maximum_frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (maximum_frm.Position > -1)
                    {
                        Edit.Position = maximum_frm.Number;

                        Edit.Macros.Args[0].Index = maximum_frm.Position;
                        Edit.Macros.Description   = maximum_frm.Comment;

                        UpdateFormula(Selected, Edit);
                        Edit.Macros.Reset();
                    }
                }
                break;

            case FormulaType.Minimum:

                AddMinimumForm minimum_frm = new AddMinimumForm(app);

                minimum_frm.Position = Edit.Macros.Args[0].Index;
                minimum_frm.Comment  = Edit.Macros.Description;

                minimum_frm.checkBox1.Visible = false;
                minimum_frm.Number            = Edit.Position;

                if (minimum_frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (minimum_frm.Position > -1)
                    {
                        Edit.Position = minimum_frm.Number;

                        Edit.Macros.Args[0].Index = minimum_frm.Position;
                        Edit.Macros.Description   = minimum_frm.Comment;

                        UpdateFormula(Selected, Edit);
                        Edit.Macros.Reset();
                    }
                }
                break;

            case FormulaType.PowerOf10:

                Add10PowXForm powX_frm = new Add10PowXForm(app);

                powX_frm.Position = Edit.Macros.Args[0].Index;
                powX_frm.Comment  = Edit.Macros.Description;

                powX_frm.checkBox1.Visible = false;
                powX_frm.Number            = Edit.Position;

                if (powX_frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (powX_frm.Position > -1)
                    {
                        Edit.Position = powX_frm.Number;

                        Edit.Macros.Args[0].Index = powX_frm.Position;
                        Edit.Macros.Description   = powX_frm.Comment;

                        UpdateFormula(Selected, Edit);
                    }
                }
                break;

            case FormulaType.Accumulation:

                AddAccumulationForm accumulation_frm = new AddAccumulationForm(app);

                accumulation_frm.Position = Edit.Macros.Args[0].Index;
                accumulation_frm.Comment  = Edit.Macros.Description;

                accumulation_frm.checkBox1.Visible = false;
                accumulation_frm.Number            = Edit.Position;

                if (accumulation_frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (accumulation_frm.Position > -1)
                    {
                        Edit.Position = accumulation_frm.Number;

                        Edit.Macros.Args[0].Index = accumulation_frm.Position;
                        Edit.Macros.Description   = accumulation_frm.Comment;

                        UpdateFormula(Selected, Edit);
                        Edit.Macros.Reset();
                    }
                }

                break;

            case FormulaType.Media:

                AddMediaNewForm media_frm = new AddMediaNewForm(app);

                media_frm.FirstArg   = Edit.Macros.Args[0];
                media_frm.SecondtArg = Edit.Macros.Args[1];

                media_frm.Comment           = Edit.Macros.Description;
                media_frm.checkBox1.Visible = false;

                media_frm.Number = Edit.Position;

                if (media_frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (media_frm.FirstArg != null && media_frm.SecondtArg != null)
                    {
                        Edit.Position = media_frm.Number;

                        Edit.Macros.Args[0] = media_frm.FirstArg;
                        Edit.Macros.Args[1] = media_frm.SecondtArg;

                        Edit.Macros.Description = media_frm.Comment;
                        UpdateFormula(Selected, Edit);
                    }
                }

                break;

            case FormulaType.Tranformation:

                AddTransformationForm transform_frm = new AddTransformationForm(app);

                transform_frm.FirstArg = Edit.Macros.Args[0];
                transform_frm.Comment  = Edit.Macros.Description;

                transform_frm.checkBoxSetNumberAuto.Visible = false;
                transform_frm.Number = Edit.Position;

                if (Edit.Macros is Transformation)
                {
                    Transformation temp = Edit.Macros as Transformation;

                    Transformation t_clone = new Transformation();
                    foreach (Transformation.TCondition condition in temp.Table)
                    {
                        Transformation.TCondition t_condition = new Transformation.TCondition();

                        t_condition.Multy  = condition.Multy;
                        t_condition.Result = condition.Result;

                        t_condition.Shift  = condition.Shift;
                        t_condition.Signal = condition.Signal;

                        t_clone.Insert(t_condition);
                    }

                    t_clone.Args[0].Source = temp.Args[0].Source;
                    t_clone.Args[0].Index  = temp.Args[0].Index;

                    t_clone.Description          = temp.Description;
                    transform_frm.Transformation = t_clone;

                    if (transform_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        Edit.Position = transform_frm.Number;

                        Edit.Macros             = transform_frm.Transformation;
                        Edit.Macros.Description = transform_frm.Comment;

                        UpdateFormula(Selected, Edit);
                    }
                }
                break;

            case FormulaType.Capture:

                AddCaptureForm cap_frm = new AddCaptureForm(app);

                cap_frm.Value   = Edit.Macros.Value;
                cap_frm.Comment = Edit.Macros.Description;

                cap_frm.checkBox1.Visible = false;
                cap_frm.Number            = Edit.Position;

                if (cap_frm.ShowDialog(this) == DialogResult.OK)
                {
                    Edit.Position     = cap_frm.Number;
                    Edit.Macros.Value = cap_frm.Value;

                    Edit.Macros.Description = cap_frm.Comment;

                    UpdateFormula(Selected, Edit);
                }
                break;

            case FormulaType.Gases:

                GasesForm gas_frm = new GasesForm(app);

                gas_frm.Comment = Edit.Macros.Description;

                gas_frm.checkBox1.Visible = true;
                gas_frm.Number            = Edit.Position;

                gas_frm.Gases = Edit.Macros as Gases;

                if (gas_frm.ShowDialog(this) == DialogResult.OK)
                {
                    Edit.Position           = gas_frm.Number;
                    Edit.Macros.Description = gas_frm.Comment;

                    UpdateFormula(Selected, Edit);
                }
                break;

            case FormulaType.Script:

                ScriptFormEdit scr_frm = new ScriptFormEdit(Edit.Macros as Script);

                scr_frm.Comment           = Edit.Macros.Description;
                scr_frm.checkBox1.Visible = true;

                scr_frm.Number = Edit.Position;

                if (scr_frm.ShowDialog(this) == DialogResult.OK)
                {
                    Edit.Position           = scr_frm.Number;
                    Edit.Macros.Description = scr_frm.Comment;

                    UpdateFormula(Selected, Edit);

                    Script script = Edit.Macros as Script;
                    if (script != null)
                    {
                        script.Reset();
                    }
                }
                break;

            default:

                break;
            }
        }
        /// <summary>
        /// Редактировать формулу
        /// </summary>
        /// <param name="Selected">Выборанный элемент в сиписке</param>
        /// <param name="Edit">Редактируемая формула</param>
        private void EditFormula(ListViewItem Selected, Formula Edit)
        {
            switch (Edit.Type)
            {
                case FormulaType.Constant:

                    AddConstantForm const_frm = new AddConstantForm(app);

                    const_frm.Value = Edit.Macros.Value;
                    const_frm.Comment = Edit.Macros.Description;

                    const_frm.checkBox1.Visible = false;
                    const_frm.Number = Edit.Position;

                    if (const_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        Edit.Position = const_frm.Number;
                        Edit.Macros.Value = const_frm.Value;

                        Edit.Macros.Description = const_frm.Comment;

                        UpdateFormula(Selected, Edit);
                    }
                    break;

                case FormulaType.Assignment:

                    AddAssignmentForm assignment_frm = new AddAssignmentForm(app);

                    assignment_frm.Comment = Edit.Macros.Description;

                    assignment_frm.Number = Edit.Position;
                    assignment_frm.Position = Edit.Macros.Args[0].Index;

                    assignment_frm.checkBox1.Visible = false;

                    if (assignment_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        Edit.Position = assignment_frm.Number;

                        Edit.Macros.Args[0].Index = assignment_frm.Position;
                        Edit.Macros.Args[0].Source = DataSource.Signals;

                        Edit.Macros.Description = assignment_frm.Comment;
                        UpdateFormula(Selected, Edit);
                    }
                    break;

                case FormulaType.Summa:

                    AddSummaNewForm summa_frm = new AddSummaNewForm(app);

                    summa_frm.FirstArg = Edit.Macros.Args[0];
                    summa_frm.SecondtArg = Edit.Macros.Args[1];

                    summa_frm.Comment = Edit.Macros.Description;
                    summa_frm.checkBox1.Visible = false;

                    summa_frm.Number = Edit.Position;

                    if (summa_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        if (summa_frm.FirstArg != null && summa_frm.SecondtArg != null)
                        {
                            Edit.Position = summa_frm.Number;

                            Edit.Macros.Args[0] = summa_frm.FirstArg;
                            Edit.Macros.Args[1] = summa_frm.SecondtArg;

                            Edit.Macros.Description = summa_frm.Comment;
                            UpdateFormula(Selected, Edit);
                        }
                    }
                    break;

                case FormulaType.Difference:

                    AddDifferenceNewForm difference_frm = new AddDifferenceNewForm(app);

                    difference_frm.FirstArg = Edit.Macros.Args[0];
                    difference_frm.SecondtArg = Edit.Macros.Args[1];

                    difference_frm.Comment = Edit.Macros.Description;
                    difference_frm.checkBox1.Visible = false;

                    difference_frm.Number = Edit.Position;

                    if (difference_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        if (difference_frm.FirstArg != null && difference_frm.SecondtArg != null)
                        {
                            Edit.Position = difference_frm.Number;

                            Edit.Macros.Args[0] = difference_frm.FirstArg;
                            Edit.Macros.Args[1] = difference_frm.SecondtArg;

                            Edit.Macros.Description = difference_frm.Comment;
                            UpdateFormula(Selected, Edit);
                        }
                    }
                    break;

                case FormulaType.Division:

                    AddDivizionNewForm divizion_frm = new AddDivizionNewForm(app);

                    divizion_frm.FirstArg = Edit.Macros.Args[0];
                    divizion_frm.SecondtArg = Edit.Macros.Args[1];

                    divizion_frm.Comment = Edit.Macros.Description;
                    divizion_frm.checkBox1.Visible = false;

                    divizion_frm.Number = Edit.Position;

                    if (divizion_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        if (divizion_frm.FirstArg != null && divizion_frm.SecondtArg != null)
                        {
                            Edit.Position = divizion_frm.Number;

                            Edit.Macros.Args[0] = divizion_frm.FirstArg;
                            Edit.Macros.Args[1] = divizion_frm.SecondtArg;

                            Edit.Macros.Description = divizion_frm.Comment;
                            UpdateFormula(Selected, Edit);
                        }
                    }
                    break;

                case FormulaType.Multiplication:

                    AddMultiplicationNewForm multiplication_frm = new AddMultiplicationNewForm(app);

                    multiplication_frm.FirstArg = Edit.Macros.Args[0];
                    multiplication_frm.SecondtArg = Edit.Macros.Args[1];

                    multiplication_frm.Comment = Edit.Macros.Description;
                    multiplication_frm.checkBox1.Visible = false;

                    multiplication_frm.Number = Edit.Position;

                    if (multiplication_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        if (multiplication_frm.FirstArg != null && multiplication_frm.SecondtArg != null)
                        {
                            Edit.Position = multiplication_frm.Number;

                            Edit.Macros.Args[0] = multiplication_frm.FirstArg;
                            Edit.Macros.Args[1] = multiplication_frm.SecondtArg;

                            Edit.Macros.Description = multiplication_frm.Comment;
                            UpdateFormula(Selected, Edit);
                        }
                    }
                    break;

                case FormulaType.Increment:

                    AddIncrementForm increment_frm = new AddIncrementForm(app);

                    increment_frm.Position = Edit.Macros.Args[0].Index;
                    increment_frm.Comment = Edit.Macros.Description;

                    increment_frm.checkBox1.Visible = false;
                    increment_frm.Number = Edit.Position;

                    if (increment_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        if (increment_frm.Position > -1)
                        {
                            Edit.Position = increment_frm.Number;

                            Edit.Macros.Args[0].Index = increment_frm.Position;
                            Edit.Macros.Description = increment_frm.Comment;

                            UpdateFormula(Selected, Edit);
                            (Edit.Macros as Increment).Reset();
                        }
                    }

                    break;

                case FormulaType.Maximum:

                    AddMaximumForm maximum_frm = new AddMaximumForm(app);

                    maximum_frm.Position = Edit.Macros.Args[0].Index;
                    maximum_frm.Comment = Edit.Macros.Description;

                    maximum_frm.checkBox1.Visible = false;
                    maximum_frm.Number = Edit.Position;

                    if (maximum_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        if (maximum_frm.Position > -1)
                        {
                            Edit.Position = maximum_frm.Number;

                            Edit.Macros.Args[0].Index = maximum_frm.Position;
                            Edit.Macros.Description = maximum_frm.Comment;

                            UpdateFormula(Selected, Edit);
                            Edit.Macros.Reset();
                        }
                    }
                    break;

                case FormulaType.Minimum:

                    AddMinimumForm minimum_frm = new AddMinimumForm(app);

                    minimum_frm.Position = Edit.Macros.Args[0].Index;
                    minimum_frm.Comment = Edit.Macros.Description;

                    minimum_frm.checkBox1.Visible = false;
                    minimum_frm.Number = Edit.Position;

                    if (minimum_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        if (minimum_frm.Position > -1)
                        {
                            Edit.Position = minimum_frm.Number;

                            Edit.Macros.Args[0].Index = minimum_frm.Position;
                            Edit.Macros.Description = minimum_frm.Comment;

                            UpdateFormula(Selected, Edit);
                            Edit.Macros.Reset();
                        }
                    }
                    break;

                case FormulaType.PowerOf10:

                    Add10PowXForm powX_frm = new Add10PowXForm(app);

                    powX_frm.Position = Edit.Macros.Args[0].Index;
                    powX_frm.Comment = Edit.Macros.Description;

                    powX_frm.checkBox1.Visible = false;
                    powX_frm.Number = Edit.Position;

                    if (powX_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        if (powX_frm.Position > -1)
                        {
                            Edit.Position = powX_frm.Number;

                            Edit.Macros.Args[0].Index = powX_frm.Position;
                            Edit.Macros.Description = powX_frm.Comment;

                            UpdateFormula(Selected, Edit);
                        }
                    }
                    break;

                case FormulaType.Accumulation:

                    AddAccumulationForm accumulation_frm = new AddAccumulationForm(app);

                    accumulation_frm.Position = Edit.Macros.Args[0].Index;
                    accumulation_frm.Comment = Edit.Macros.Description;

                    accumulation_frm.checkBox1.Visible = false;
                    accumulation_frm.Number = Edit.Position;

                    if (accumulation_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        if (accumulation_frm.Position > -1)
                        {
                            Edit.Position = accumulation_frm.Number;

                            Edit.Macros.Args[0].Index = accumulation_frm.Position;
                            Edit.Macros.Description = accumulation_frm.Comment;

                            UpdateFormula(Selected, Edit);
                            Edit.Macros.Reset();
                        }
                    }

                    break;

                case FormulaType.Media:

                    AddMediaNewForm media_frm = new AddMediaNewForm(app);

                    media_frm.FirstArg = Edit.Macros.Args[0];
                    media_frm.SecondtArg = Edit.Macros.Args[1];

                    media_frm.Comment = Edit.Macros.Description;
                    media_frm.checkBox1.Visible = false;

                    media_frm.Number = Edit.Position;

                    if (media_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        if (media_frm.FirstArg != null && media_frm.SecondtArg != null)
                        {
                            Edit.Position = media_frm.Number;

                            Edit.Macros.Args[0] = media_frm.FirstArg;
                            Edit.Macros.Args[1] = media_frm.SecondtArg;

                            Edit.Macros.Description = media_frm.Comment;
                            UpdateFormula(Selected, Edit);
                        }
                    }

                    break;

                case FormulaType.Tranformation:

                    AddTransformationForm transform_frm = new AddTransformationForm(app);

                    transform_frm.FirstArg = Edit.Macros.Args[0];
                    transform_frm.Comment = Edit.Macros.Description;

                    transform_frm.checkBoxSetNumberAuto.Visible = false;
                    transform_frm.Number = Edit.Position;

                    if (Edit.Macros is Transformation)
                    {
                        Transformation temp = Edit.Macros as Transformation;

                        Transformation t_clone = new Transformation();
                        foreach (Transformation.TCondition condition in temp.Table)
                        {
                            Transformation.TCondition t_condition = new Transformation.TCondition();

                            t_condition.Multy = condition.Multy;
                            t_condition.Result = condition.Result;

                            t_condition.Shift = condition.Shift;
                            t_condition.Signal = condition.Signal;

                            t_clone.Insert(t_condition);
                        }

                        t_clone.Args[0].Source = temp.Args[0].Source;
                        t_clone.Args[0].Index = temp.Args[0].Index;

                        t_clone.Description = temp.Description;
                        transform_frm.Transformation = t_clone;

                        if (transform_frm.ShowDialog(this) == DialogResult.OK)
                        {
                            Edit.Position = transform_frm.Number;

                            Edit.Macros = transform_frm.Transformation;
                            Edit.Macros.Description = transform_frm.Comment;

                            UpdateFormula(Selected, Edit);
                        }
                    }
                    break;

                case FormulaType.Capture:

                    AddCaptureForm cap_frm = new AddCaptureForm(app);

                    cap_frm.Value = Edit.Macros.Value;
                    cap_frm.Comment = Edit.Macros.Description;

                    cap_frm.checkBox1.Visible = false;
                    cap_frm.Number = Edit.Position;

                    if (cap_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        Edit.Position = cap_frm.Number;
                        Edit.Macros.Value = cap_frm.Value;

                        Edit.Macros.Description = cap_frm.Comment;

                        UpdateFormula(Selected, Edit);
                    }
                    break;

                case FormulaType.Gases:

                    GasesForm gas_frm = new GasesForm(app);

                    gas_frm.Comment = Edit.Macros.Description;

                    gas_frm.checkBox1.Visible = true;
                    gas_frm.Number = Edit.Position;

                    gas_frm.Gases = Edit.Macros as Gases;

                    if (gas_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        Edit.Position = gas_frm.Number;
                        Edit.Macros.Description = gas_frm.Comment;

                        UpdateFormula(Selected, Edit);
                    }
                    break;

                case FormulaType.Script:

                    ScriptFormEdit scr_frm = new ScriptFormEdit(Edit.Macros as Script);

                    scr_frm.Comment = Edit.Macros.Description;
                    scr_frm.checkBox1.Visible = true;

                    scr_frm.Number = Edit.Position;

                    if (scr_frm.ShowDialog(this) == DialogResult.OK)
                    {
                        Edit.Position = scr_frm.Number;
                        Edit.Macros.Description = scr_frm.Comment;

                        UpdateFormula(Selected, Edit);

                        Script script = Edit.Macros as Script;
                        if (script != null)
                        {
                            script.Reset();
                        }
                    }
                    break;

                default:

                    break;
            }
        }