private void NewRuleCommandHandler() { XElement element = null; SignalRule signalRule = null; element = XElementExtensions.NewSignalRule(); signalRule = element.ToTypeSignalRule(); if (element != null && signalRule != null) { NewRuleViewModel newRuleViewModel = new NewRuleViewModel { SignalRule = signalRule }; // here we have to open a new rule dialog. _dialogContainerService.ShowDialog(newRuleViewModel); if (newRuleViewModel.Result == DialogResult.Success) { if (this.SignalRules != null && _document != null) { _document.Root.Add(element, Environment.NewLine); this.SignalRules.Add(signalRule); this.IsDirty = true; this.PrimaryCommand.RaiseCanExecuteChanged(); } } } }
private void EditRuleCommandHandler(SignalRule signalRule) { if (signalRule != null) { SignalRule preservedSignalRule = signalRule.DeepCopy(); NewRuleViewModel editRuleViewModel = new NewRuleViewModel(performValidationOnLoad: false) { SignalRule = signalRule }; editRuleViewModel.Title = "Edit Rule"; editRuleViewModel.PrimaryButtonText = "Save"; // here we have to open a new rule dialog. _dialogContainerService.ShowDialog(editRuleViewModel); if (editRuleViewModel.Result == DialogResult.Success) { this.IsDirty = true; this.PrimaryCommand.RaiseCanExecuteChanged(); } else { signalRule.AllowedValues = preservedSignalRule.AllowedValues; signalRule.AllowFutureDate = preservedSignalRule.AllowFutureDate; signalRule.AllowNull = preservedSignalRule.AllowNull; signalRule.DateFormat = preservedSignalRule.DateFormat; signalRule.Element = preservedSignalRule.Element; signalRule.IsActive = preservedSignalRule.IsActive; signalRule.MaxDate = preservedSignalRule.MaxDate; signalRule.MaxLength = preservedSignalRule.MaxLength; signalRule.MaxValue = preservedSignalRule.MaxValue; signalRule.MinDate = preservedSignalRule.MinDate; signalRule.MinLength = preservedSignalRule.MinLength; signalRule.MinValue = preservedSignalRule.MinValue; signalRule.NotAllowedValues = preservedSignalRule.NotAllowedValues; signalRule.SignalID = preservedSignalRule.SignalID; signalRule.ValueType = preservedSignalRule.ValueType; } } }