private void OpenPropertiesForm(StepFormMode mode) { if (stepTree.SelectedNode == null) { return; } if (stepTree.SelectedNode.Parent == null && stepTree.SelectedNode.Tag == null && (mode == StepFormMode.AddNegative || mode == StepFormMode.AddPositive)) { MessageBox.Show("Сначала необходимо задать свойства корневого элемента (базовой операции)", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.OpenPropertiesForm(StepFormMode.Edit); return; } var selectNode = this.stepTree.SelectedNode; var propertiesForm = new StepPropertiesForm(mode, (StepsProperties)selectNode.Tag, this.Operations); propertiesForm.ShowDialog(); if (propertiesForm?.SelectedOperationItem == null) { return; } if (mode == StepFormMode.Edit) { var newNode = this.NodeToAdd(true, propertiesForm.StepsProperties); selectNode.Text = newNode.Text; selectNode.Tag = newNode.Tag; if (selectNode.Parent == null) { ((StepsProperties)selectNode.Tag).IsPositive = true; } } else if (mode == StepFormMode.AddPositive) { selectNode.Nodes.Add(this.NodeToAdd(true, propertiesForm.StepsProperties)); selectNode.Expand(); } else if (mode == StepFormMode.AddNegative) { selectNode.Nodes.Add(this.NodeToAdd(false, propertiesForm.StepsProperties)); selectNode.Expand(); } }
public StepPropertiesForm(StepFormMode mode, StepsProperties properties, Dictionary <int, string> operations) { InitializeComponent(); this.StepsProperties = properties; this.Operations = operations; switch (mode) { case StepFormMode.AddPositive: this._isPositive = true; this.Text = "Действие при положительном результате"; SetDefaultValues(); break; case StepFormMode.AddNegative: this._isPositive = false; this.Text = "Действие при отрицательном результате"; SetDefaultValues(); break; case StepFormMode.Edit: if (this.StepsProperties == null) { SetDefaultValues(); break; } chbIs1cErrorEqualRuntimeError.Checked = this.StepsProperties.Is1cErrorEqualRuntimeError; chbIsOperErrorEqualRuntimeError.Checked = this.StepsProperties.IsOperErrorEqualRuntimeError; if (this.StepsProperties.WaitingForSuccessInterval < 0) { MessageBox.Show($"Неверное значение: {this.StepsProperties.WaitingForSuccessInterval}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var waitingForSuccessInterval = TimeSpan.FromSeconds(this.StepsProperties.WaitingForSuccessInterval); this.pckrWaitingForSuccessInterval.Value = new DateTime( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, waitingForSuccessInterval.Hours, waitingForSuccessInterval.Minutes, waitingForSuccessInterval.Seconds); if (this.StepsProperties.RepeatingIntervalOn1cWaiting < 0) { MessageBox.Show($"Неверное значение: {this.StepsProperties.RepeatingIntervalOn1cWaiting}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var repeatingIntervalOn1cWaiting = TimeSpan.FromSeconds(this.StepsProperties.RepeatingIntervalOn1cWaiting); this.pckrRepeatingIntervalOn1cWaiting.Value = new DateTime( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, repeatingIntervalOn1cWaiting.Hours, repeatingIntervalOn1cWaiting.Minutes, repeatingIntervalOn1cWaiting.Seconds); edRepeatTimesOnLackOf1cResponse.Text = this.StepsProperties.RepeatTimesOnLackOf1cResponse.ToString(); break; default: this._isPositive = false; break; } }