private void DeleteItem() { if (stepTree.SelectedNode.Parent == null) { MessageBox.Show("Выделенные узел является корневым элементом", "Невозможно удалить шаг", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } { if (MessageBox.Show("Удалить текущий элемент и все дочерние?", "Подтвердите действие", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { List <TreeNode> nodes = new List <TreeNode>(); AddChildren(nodes, stepTree.SelectedNode); nodes.Add(stepTree.SelectedNode); StepsIdListToDelete.Clear(); foreach (TreeNode node in nodes) { StepsProperties stepsProperties = node.Tag as StepsProperties; if (stepsProperties != null) { StepsIdListToDelete.Add(stepsProperties.Id); } } stepTree.SelectedNode.Remove(); } } }
private TreeNode NodeToAdd(bool isPositive, StepsProperties stepsProperties) { var imageIndex = (isPositive) ? IMAGE_INDEX_POSITIVE : IMAGE_INDEX_NEGATIVE; var stepNode = new TreeNode(); stepNode.ImageIndex = imageIndex; stepNode.SelectedImageIndex = imageIndex; stepNode.Tag = stepsProperties; stepNode.Text = stepsProperties.OperationName; return(stepNode); }
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; } }