/// <summary> /// Добавить приращение /// </summary> /// <param name="formula">Узел, содержащий формулу</param> protected void InsertIncrement(XmlNode formula) { try { Formula frm = new Formula(); Increment increment = new Increment(); frm.Position = GetPosition(formula); XmlNode macros = GetMacros(formula); if (macros != null) { increment.InstanceMacrosFromXmlNode(macros); frm.Macros = increment; InsertFormula(frm); } } catch { } }
/// <summary> /// Добавляем формулу /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void insert_formula_Click(object sender, EventArgs e) { switch (comboBoxFormuls.SelectedIndex) { case 0: AddConstantForm constFrm = new AddConstantForm(app); if (constFrm.ShowDialog(this) == DialogResult.OK) { Formula const_formula = new Formula(); Constant constant = new Constant(); constant.Value = constFrm.Value; const_formula.Macros = constant; if (constFrm.AutoSetNumber) { const_formula.Position = app.Converter.GetFreeChannel(); } else { const_formula.Position = constFrm.Number; } const_formula.Macros.Description = constFrm.Comment; InsertFormula(const_formula, true); app.Converter.InsertFormula(const_formula); } break; case 1: AddAssignmentForm assig_frm = new AddAssignmentForm(app); if (assig_frm.ShowDialog(this) == DialogResult.OK) { Formula assig = new Formula(); Assignment assignment = new Assignment(); assignment.Args[0].Index = assig_frm.Position; assignment.Args[0].Source = DataSource.Signals; assig.Macros = assignment; if (assig_frm.AutoSetNumber) { assig.Position = app.Converter.GetFreeChannel(); } else { assig.Position = assig_frm.Number; } assig.Macros.Description = assig_frm.Comment; InsertFormula(assig, true); app.Converter.InsertFormula(assig); } break; case 2: AddSummaNewForm summa_frm = new AddSummaNewForm(app); //AddSummaForm summa_frm = new AddSummaForm(app); if (summa_frm.ShowDialog(this) == DialogResult.OK) { if (summa_frm.FirstArg != null && summa_frm.SecondtArg != null) { Summa summa = new Summa(); Formula summ_formula = new Formula(); summa.Args[0] = summa_frm.FirstArg; summa.Args[1] = summa_frm.SecondtArg; summ_formula.Macros = summa; if (summa_frm.AutoSetNumber) { summ_formula.Position = app.Converter.GetFreeChannel(); } else { summ_formula.Position = summa_frm.Number; } summ_formula.Macros.Description = summa_frm.Comment; InsertFormula(summ_formula, true); app.Converter.InsertFormula(summ_formula); } } break; case 3: //AddDifferenceForm difference_frm = new AddDifferenceForm(app); AddDifferenceNewForm difference_frm = new AddDifferenceNewForm(app); if (difference_frm.ShowDialog(this) == DialogResult.OK) { if (difference_frm.FirstArg != null && difference_frm.SecondtArg != null) { Formula formula = new Formula(); Difference difference = new Difference(); difference.Args[0] = difference_frm.FirstArg; difference.Args[1] = difference_frm.SecondtArg; formula.Macros = difference; if (difference_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = difference_frm.Number; } formula.Macros.Description = difference_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 4: //AddMultiplicationForm multiplication_frm = new AddMultiplicationForm(app); AddMultiplicationNewForm multiplication_frm = new AddMultiplicationNewForm(app); if (multiplication_frm.ShowDialog(this) == DialogResult.OK) { if (multiplication_frm.FirstArg != null && multiplication_frm.SecondtArg != null) { Formula formula = new Formula(); Multiplication multiplication = new Multiplication(); multiplication.Args[0] = multiplication_frm.FirstArg; multiplication.Args[1] = multiplication_frm.SecondtArg; formula.Macros = multiplication; if (multiplication_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = multiplication_frm.Number; } formula.Macros.Description = multiplication_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 5: //AddDivizionForm divizion_frm = new AddDivizionForm(app); AddDivizionNewForm divizion_frm = new AddDivizionNewForm(app); if (divizion_frm.ShowDialog(this) == DialogResult.OK) { if (divizion_frm.FirstArg != null && divizion_frm.SecondtArg != null) { Formula formula = new Formula(); Division divizion = new Division(); divizion.Args[0] = divizion_frm.FirstArg; divizion.Args[1] = divizion_frm.SecondtArg; formula.Macros = divizion; if (divizion_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = divizion_frm.Number; } formula.Macros.Description = divizion_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 6: AddIncrementForm increment_frm = new AddIncrementForm(app); if (increment_frm.ShowDialog(this) == DialogResult.OK) { if (increment_frm.Position > -1) { Formula formula = new Formula(); Increment increment = new Increment(); increment.Args[0].Index = increment_frm.Position; increment.Args[0].Source = DataSource.Results; formula.Macros = increment; if (increment_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = increment_frm.Number; } formula.Macros.Description = increment_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 7: AddMaximumForm maximum_frm = new AddMaximumForm(app); if (maximum_frm.ShowDialog(this) == DialogResult.OK) { if (maximum_frm.Position > -1) { Formula formula = new Formula(); Maximum maximum = new Maximum(); maximum.Args[0].Index = maximum_frm.Position; maximum.Args[0].Source = DataSource.Results; formula.Macros = maximum; if (maximum_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = maximum_frm.Number; } formula.Macros.Description = maximum_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 8: AddMinimumForm minimum_frm = new AddMinimumForm(app); if (minimum_frm.ShowDialog(this) == DialogResult.OK) { if (minimum_frm.Position > -1) { Formula formula = new Formula(); Minimum minimum = new Minimum(); minimum.Args[0].Index = minimum_frm.Position; minimum.Args[0].Source = DataSource.Results; formula.Macros = minimum; if (minimum_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = minimum_frm.Number; } formula.Macros.Description = minimum_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 9: Add10PowXForm powX_frm = new Add10PowXForm(app); if (powX_frm.ShowDialog(this) == DialogResult.OK) { if (powX_frm.Position > -1) { Formula formula = new Formula(); PowerOf10 powX = new PowerOf10(); powX.Args[0].Index = powX_frm.Position; powX.Args[0].Source = DataSource.Results; formula.Macros = powX; if (powX_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = powX_frm.Number; } formula.Macros.Description = powX_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 10: AddAccumulationForm accumulation_frm = new AddAccumulationForm(app); if (accumulation_frm.ShowDialog(this) == DialogResult.OK) { if (accumulation_frm.Position > -1) { Formula formula = new Formula(); Accumulation accumulation = new Accumulation(); accumulation.Args[0].Index = accumulation_frm.Position; accumulation.Args[0].Source = DataSource.Results; formula.Macros = accumulation; if (accumulation_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = accumulation_frm.Number; } formula.Macros.Description = accumulation_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 11: AddMediaNewForm media_frm = new AddMediaNewForm(app); if (media_frm.ShowDialog(this) == DialogResult.OK) { if (media_frm.FirstArg != null && media_frm.SecondtArg != null) { Media media = new Media(); Formula formula = new Formula(); media.Args[0] = media_frm.FirstArg; media.Args[1] = media_frm.SecondtArg; formula.Macros = media; if (media_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = media_frm.Number; } formula.Macros.Description = media_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 12: AddTransformationForm transform_frm = new AddTransformationForm(app); if (transform_frm.ShowDialog(this) == DialogResult.OK) { if (transform_frm.FirstArg != null && transform_frm.Transformation != null) { Transformation transformation = transform_frm.Transformation; Formula formula = new Formula(); transformation.Args[0] = transform_frm.FirstArg; formula.Macros = transformation; if (transform_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = transform_frm.Number; } formula.Macros.Description = transform_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 13: AddCaptureForm captureFrm = new AddCaptureForm(app); if (captureFrm.ShowDialog(this) == DialogResult.OK) { Formula capture_formula = new Formula(); Capture capture = new DeviceManager.Capture(); capture_formula.Macros = capture; if (captureFrm.AutoSetNumber) { capture_formula.Position = app.Converter.GetFreeChannel(); } else { capture_formula.Position = captureFrm.Number; } capture_formula.Macros.Description = captureFrm.Comment; InsertFormula(capture_formula, true); app.Converter.InsertFormula(capture_formula); } break; case 14: GasesForm frm = new GasesForm(app); if (frm.ShowDialog(this) == DialogResult.OK) { if (frm.Gases != null) { Formula gases_formula = new Formula(); Gases gases = frm.Gases; gases_formula.Macros = gases; if (frm.AutoSetNumber) { gases_formula.Position = app.Converter.GetFreeChannel(); } else { gases_formula.Position = frm.Number; } gases_formula.Macros.Description = frm.Comment; InsertFormula(gases_formula, true); app.Converter.InsertFormula(gases_formula); } } break; case 15: ScriptForm scriptForm = new ScriptForm(); if (scriptForm.ShowDialog(this) == DialogResult.OK) { if (scriptForm.Script != null) { Formula script_formula = new Formula(); Script script = scriptForm.Script; script_formula.Macros = script; if (scriptForm.AutoSetNumber) { script_formula.Position = app.Converter.GetFreeChannel(); } else { script_formula.Position = scriptForm.Number; } script_formula.Macros.Description = scriptForm.Comment; InsertFormula(script_formula, true); app.Converter.InsertFormula(script_formula); } } break; default: break; } listViewFormuls.ListViewItemSorter = new ListViewItemComparer(0); }
/// <summary> /// Добавляем формулу /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void insert_formula_Click(object sender, EventArgs e) { switch (comboBoxFormuls.SelectedIndex) { case 0: AddConstantForm constFrm = new AddConstantForm(app); if (constFrm.ShowDialog(this) == DialogResult.OK) { Formula const_formula = new Formula(); Constant constant = new Constant(); constant.Value = constFrm.Value; const_formula.Macros = constant; if (constFrm.AutoSetNumber) { const_formula.Position = app.Converter.GetFreeChannel(); } else { const_formula.Position = constFrm.Number; } const_formula.Macros.Description = constFrm.Comment; InsertFormula(const_formula, true); app.Converter.InsertFormula(const_formula); } break; case 1: AddAssignmentForm assig_frm = new AddAssignmentForm(app); if (assig_frm.ShowDialog(this) == DialogResult.OK) { Formula assig = new Formula(); Assignment assignment = new Assignment(); assignment.Args[0].Index = assig_frm.Position; assignment.Args[0].Source = DataSource.Signals; assig.Macros = assignment; if (assig_frm.AutoSetNumber) { assig.Position = app.Converter.GetFreeChannel(); } else { assig.Position = assig_frm.Number; } assig.Macros.Description = assig_frm.Comment; InsertFormula(assig, true); app.Converter.InsertFormula(assig); } break; case 2: AddSummaNewForm summa_frm = new AddSummaNewForm(app); //AddSummaForm summa_frm = new AddSummaForm(app); if (summa_frm.ShowDialog(this) == DialogResult.OK) { if (summa_frm.FirstArg != null && summa_frm.SecondtArg != null) { Summa summa = new Summa(); Formula summ_formula = new Formula(); summa.Args[0] = summa_frm.FirstArg; summa.Args[1] = summa_frm.SecondtArg; summ_formula.Macros = summa; if (summa_frm.AutoSetNumber) { summ_formula.Position = app.Converter.GetFreeChannel(); } else { summ_formula.Position = summa_frm.Number; } summ_formula.Macros.Description = summa_frm.Comment; InsertFormula(summ_formula, true); app.Converter.InsertFormula(summ_formula); } } break; case 3: //AddDifferenceForm difference_frm = new AddDifferenceForm(app); AddDifferenceNewForm difference_frm = new AddDifferenceNewForm(app); if (difference_frm.ShowDialog(this) == DialogResult.OK) { if (difference_frm.FirstArg != null && difference_frm.SecondtArg != null) { Formula formula = new Formula(); Difference difference = new Difference(); difference.Args[0] = difference_frm.FirstArg; difference.Args[1] = difference_frm.SecondtArg; formula.Macros = difference; if (difference_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = difference_frm.Number; } formula.Macros.Description = difference_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 4: //AddMultiplicationForm multiplication_frm = new AddMultiplicationForm(app); AddMultiplicationNewForm multiplication_frm = new AddMultiplicationNewForm(app); if (multiplication_frm.ShowDialog(this) == DialogResult.OK) { if (multiplication_frm.FirstArg != null && multiplication_frm.SecondtArg != null) { Formula formula = new Formula(); Multiplication multiplication = new Multiplication(); multiplication.Args[0] = multiplication_frm.FirstArg; multiplication.Args[1] = multiplication_frm.SecondtArg; formula.Macros = multiplication; if (multiplication_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = multiplication_frm.Number; } formula.Macros.Description = multiplication_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 5: //AddDivizionForm divizion_frm = new AddDivizionForm(app); AddDivizionNewForm divizion_frm = new AddDivizionNewForm(app); if (divizion_frm.ShowDialog(this) == DialogResult.OK) { if (divizion_frm.FirstArg != null && divizion_frm.SecondtArg != null) { Formula formula = new Formula(); Division divizion = new Division(); divizion.Args[0] = divizion_frm.FirstArg; divizion.Args[1] = divizion_frm.SecondtArg; formula.Macros = divizion; if (divizion_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = divizion_frm.Number; } formula.Macros.Description = divizion_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 6: AddIncrementForm increment_frm = new AddIncrementForm(app); if (increment_frm.ShowDialog(this) == DialogResult.OK) { if (increment_frm.Position > -1) { Formula formula = new Formula(); Increment increment = new Increment(); increment.Args[0].Index = increment_frm.Position; increment.Args[0].Source = DataSource.Results; formula.Macros = increment; if (increment_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = increment_frm.Number; } formula.Macros.Description = increment_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 7: AddMaximumForm maximum_frm = new AddMaximumForm(app); if (maximum_frm.ShowDialog(this) == DialogResult.OK) { if (maximum_frm.Position > -1) { Formula formula = new Formula(); Maximum maximum = new Maximum(); maximum.Args[0].Index = maximum_frm.Position; maximum.Args[0].Source = DataSource.Results; formula.Macros = maximum; if (maximum_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = maximum_frm.Number; } formula.Macros.Description = maximum_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 8: AddMinimumForm minimum_frm = new AddMinimumForm(app); if (minimum_frm.ShowDialog(this) == DialogResult.OK) { if (minimum_frm.Position > -1) { Formula formula = new Formula(); Minimum minimum = new Minimum(); minimum.Args[0].Index = minimum_frm.Position; minimum.Args[0].Source = DataSource.Results; formula.Macros = minimum; if (minimum_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = minimum_frm.Number; } formula.Macros.Description = minimum_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 9: Add10PowXForm powX_frm = new Add10PowXForm(app); if (powX_frm.ShowDialog(this) == DialogResult.OK) { if (powX_frm.Position > -1) { Formula formula = new Formula(); PowerOf10 powX = new PowerOf10(); powX.Args[0].Index = powX_frm.Position; powX.Args[0].Source = DataSource.Results; formula.Macros = powX; if (powX_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = powX_frm.Number; } formula.Macros.Description = powX_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 10: AddAccumulationForm accumulation_frm = new AddAccumulationForm(app); if (accumulation_frm.ShowDialog(this) == DialogResult.OK) { if (accumulation_frm.Position > -1) { Formula formula = new Formula(); Accumulation accumulation = new Accumulation(); accumulation.Args[0].Index = accumulation_frm.Position; accumulation.Args[0].Source = DataSource.Results; formula.Macros = accumulation; if (accumulation_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = accumulation_frm.Number; } formula.Macros.Description = accumulation_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 11: AddMediaNewForm media_frm = new AddMediaNewForm(app); if (media_frm.ShowDialog(this) == DialogResult.OK) { if (media_frm.FirstArg != null && media_frm.SecondtArg != null) { Media media = new Media(); Formula formula = new Formula(); media.Args[0] = media_frm.FirstArg; media.Args[1] = media_frm.SecondtArg; formula.Macros = media; if (media_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = media_frm.Number; } formula.Macros.Description = media_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 12: AddTransformationForm transform_frm = new AddTransformationForm(app); if (transform_frm.ShowDialog(this) == DialogResult.OK) { if (transform_frm.FirstArg != null && transform_frm.Transformation != null ) { Transformation transformation = transform_frm.Transformation; Formula formula = new Formula(); transformation.Args[0] = transform_frm.FirstArg; formula.Macros = transformation; if (transform_frm.AutoSetNumber) { formula.Position = app.Converter.GetFreeChannel(); } else { formula.Position = transform_frm.Number; } formula.Macros.Description = transform_frm.Comment; InsertFormula(formula, true); app.Converter.InsertFormula(formula); } } break; case 13: AddCaptureForm captureFrm = new AddCaptureForm(app); if (captureFrm.ShowDialog(this) == DialogResult.OK) { Formula capture_formula = new Formula(); Capture capture = new DeviceManager.Capture(); capture_formula.Macros = capture; if (captureFrm.AutoSetNumber) { capture_formula.Position = app.Converter.GetFreeChannel(); } else { capture_formula.Position = captureFrm.Number; } capture_formula.Macros.Description = captureFrm.Comment; InsertFormula(capture_formula, true); app.Converter.InsertFormula(capture_formula); } break; case 14: GasesForm frm = new GasesForm(app); if (frm.ShowDialog(this) == DialogResult.OK) { if (frm.Gases != null) { Formula gases_formula = new Formula(); Gases gases = frm.Gases; gases_formula.Macros = gases; if (frm.AutoSetNumber) { gases_formula.Position = app.Converter.GetFreeChannel(); } else { gases_formula.Position = frm.Number; } gases_formula.Macros.Description = frm.Comment; InsertFormula(gases_formula, true); app.Converter.InsertFormula(gases_formula); } } break; case 15: ScriptForm scriptForm = new ScriptForm(); if (scriptForm.ShowDialog(this) == DialogResult.OK) { if (scriptForm.Script != null) { Formula script_formula = new Formula(); Script script = scriptForm.Script; script_formula.Macros = script; if (scriptForm.AutoSetNumber) { script_formula.Position = app.Converter.GetFreeChannel(); } else script_formula.Position = scriptForm.Number; script_formula.Macros.Description = scriptForm.Comment; InsertFormula(script_formula, true); app.Converter.InsertFormula(script_formula); } } break; default: break; } listViewFormuls.ListViewItemSorter = new ListViewItemComparer(0); }