private void conditionTextBox_Validating(object sender, CancelEventArgs e) { if (this.rulesListView.SelectedItems.Count == 0) { return; } try { Rule rule = this.rulesListView.SelectedItems[0].Tag as Rule; RuleCondition ruleCondition = this.ruleParser.ParseCondition(this.conditionTextBox.Text); rule.Condition = ruleCondition; if (!string.IsNullOrEmpty(this.conditionTextBox.Text)) { this.conditionTextBox.Text = ruleCondition.ToString().Replace("\n", "\r\n"); } UpdateItem(this.rulesListView.SelectedItems[0], rule); conditionErrorProvider.SetError(this.conditionTextBox, string.Empty); } catch (Exception ex) { conditionErrorProvider.SetError(this.conditionTextBox, ex.Message); DesignerHelpers.DisplayError(Messages.Error_ConditionParser + "\n" + ex.Message, this.Text, this.serviceProvider); e.Cancel = true; } }
private void conditionTextBox_Validating(object sender, CancelEventArgs e) { if (this.rulesListView.SelectedItems.Count != 0) { try { Rule tag = this.rulesListView.SelectedItems[0].Tag as Rule; RuleCondition condition = this.ruleParser.ParseCondition(this.conditionTextBox.Text); tag.Condition = condition; if (!string.IsNullOrEmpty(this.conditionTextBox.Text)) { this.conditionTextBox.Text = condition.ToString().Replace("\n", "\r\n"); } this.UpdateItem(this.rulesListView.SelectedItems[0], tag); this.conditionErrorProvider.SetError(this.conditionTextBox, string.Empty); } catch (Exception exception) { this.conditionErrorProvider.SetError(this.conditionTextBox, exception.Message); System.Workflow.Activities.Rules.Design.DesignerHelpers.DisplayError(Messages.Error_ConditionParser + "\n" + exception.Message, this.Text, this.serviceProvider); e.Cancel = true; } } }