private SimpleWizardRule m_ruleToUpdate; // If this is set means the control is updating an existing rule as opposed to adding a new one. public SimpleWizardOutRuleControl() { // Required to initialize variables InitializeComponent(); m_rulePriority.Text = DEFAULT_RULE_PRIORITY.ToString(); DialCommandSB.Begin(); HideError.Begin(); }
private void CloseErrorMessage(object sender, System.Windows.RoutedEventArgs e) { //m_rulePattern.IsEnabled = true; //m_ruleCommandType.IsEnabled = true; //m_ruleCommandString.IsEnabled = true; //m_ruleDescription.IsEnabled = true; //m_rulePriority.IsEnabled = true; //m_ruleSaveButton.IsEnabled = true; //m_ruleCancelButton.IsEnabled = true; //m_errorCanvas.Visibility = System.Windows.Visibility.Collapsed; //m_descriptionText.Text = (m_ruleToUpdate != null) ? UPDATE_TEXT : ADD_TEXT; HideError.Begin(); }
/// <summary> /// Sets the UI fields based on the supplied rule. If the rule is null the fields are reset ready for a new rule to be added. /// </summary> public void SetRuleToUpdate(SimpleWizardRule rule) { if (rule != null) { m_ruleToUpdate = rule; SetStatusMessage(UPDATE_TEXT, false); m_rulePatternType.SelectedIndex = m_rulePatternType.Items.IndexOf(m_rulePatternType.Items.Single(x => ((TextBlock)x).Text == rule.PatternType)); m_rulePattern.Text = rule.Pattern; m_ruleCommandType.SelectedIndex = m_ruleCommandType.Items.IndexOf(m_ruleCommandType.Items.Single(x => ((TextBlock)x).Text == rule.Command)); m_ruleCommandString.Text = rule.CommandParameter1; m_ruleDescription.Text = rule.Description; m_rulePriority.Text = rule.Priority.ToString(); m_ruleIsDisabled.IsChecked = rule.IsDisabled; SetCommandParameterFieldsForRule(rule); } else { m_ruleToUpdate = null; SetStatusMessage(ADD_TEXT, false); m_ruleIsDisabled.IsChecked = false; m_rulePatternType.SelectedIndex = 0; m_rulePattern.Text = String.Empty; m_ruleCommandString.Text = DEFAULT_DIAL_DESTINATION; m_ruleProvider.SelectedIndex = 0; m_ruleDescription.Text = String.Empty; m_rulePriority.Text = DEFAULT_RULE_PRIORITY.ToString(); m_ruleAdvancedDialString.Text = String.Empty; m_ruleRingDuration.Text = String.Empty; m_ruleAnswerDuration.Text = String.Empty; m_rejectResponseCode.SelectedIndex = DEFAULT_REJECT_RESPONSE_INDEX; m_rejectReason.Text = String.Empty; m_ruleCommandType.SelectedIndex = 0; HideError.Begin(); } }
private void Submit(object sender, System.Windows.RoutedEventArgs e) { decimal priority = DEFAULT_RULE_PRIORITY; Decimal.TryParse(m_rulePriority.Text, out priority); if (m_ruleToUpdate == null) { SimpleWizardRule rule = new SimpleWizardRule() { ID = Guid.Empty.ToString(), // Will be set in the manager. Owner = "None", // Will be set in the manager. DialPlanID = Guid.Empty.ToString(), // Will be set in the manager. Direction = SIPCallDirection.Out.ToString(), PatternType = ((TextBlock)m_rulePatternType.SelectedValue).Text, Pattern = m_rulePattern.Text, Command = ((TextBlock)m_ruleCommandType.SelectedValue).Text, Description = m_ruleDescription.Text, Priority = priority, IsDisabled = m_ruleIsDisabled.IsChecked.GetValueOrDefault() }; string commandParameterError = SetRuleCommandParameters(rule); if (commandParameterError != null) { SetErrorMessage(commandParameterError); } else if (rule.Pattern.IsNullOrBlank()) { SetErrorMessage("A pattern must be specified to match the outgoing call."); } else { HideError.Begin(); Add(rule); } } else { m_ruleToUpdate.IsDisabled = m_ruleIsDisabled.IsChecked.GetValueOrDefault(); m_ruleToUpdate.PatternType = ((TextBlock)m_rulePatternType.SelectedValue).Text; m_ruleToUpdate.Pattern = m_rulePattern.Text; m_ruleToUpdate.Command = ((TextBlock)m_ruleCommandType.SelectedValue).Text; m_ruleToUpdate.Description = m_ruleDescription.Text; m_ruleToUpdate.Priority = priority; string commandParameterError = SetRuleCommandParameters(m_ruleToUpdate); if (commandParameterError != null) { SetErrorMessage(commandParameterError); } else if (m_ruleToUpdate.Pattern.IsNullOrBlank()) { SetErrorMessage("A pattern must be specified to match the outgoing call."); } else { HideError.Begin(); Update(m_ruleToUpdate); } } }