Esempio n. 1
0
        private void DataGrid_OnCellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            if (!(e.EditingElement is TextBox textBox))
            {
                return;
            }
            if (textBox.DataContext is RuleValidationOutput ruleValidationOutput)
            {
                // 1. Try to change actual parameter value
                Document  document  = RegularApp.DocumentCacheService.GetDocument(RuleManagerViewModel.DocumentGuid);
                Element   element   = document.GetElement(ruleValidationOutput.ElementId);
                RegexRule regexRule = RuleManagerViewModel.SelectedRegexRule;
                Parameter parameter = ParameterUtils.GetParameterById
                                      (
                    document,
                    element,
                    regexRule.TrackingParameterObject.ParameterObjectId
                                      );
                if (parameter == null || parameter.IsReadOnly)
                {
                    return;
                }

                using (Transaction transaction = new Transaction(document, $"DataSpec User Modifying Element {element.Id}"))
                {
                    transaction.Start();
                    parameter.Set(textBox.Text);
                    transaction.Commit();

                    RuleValidationResult ruleValidationResult = RuleExecutionUtils.ExecuteRegexRule
                                                                (
                        RuleManagerViewModel.DocumentGuid,
                        regexRule.RuleGuid,
                        element
                                                                );

                    ruleValidationOutput.RuleValidationResult = ruleValidationResult;
                    ruleValidationOutput.ValidationText       = ruleValidationResult.GetEnumDescription();
                    if (ruleValidationOutput.RuleValidationResult != RuleValidationResult.Valid)
                    {
                        return;
                    }
                    ruleValidationOutput.CompliantExample = "";
                }
            }
        }