Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
Asks users for confirmation before clearing query builder
Browse files Browse the repository at this point in the history
  • Loading branch information
StrangeRanger committed Mar 9, 2024
1 parent 75badaa commit f721f42
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions ActiveDirectoryQuerier/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,16 +768,38 @@ private void SaveCustomQueries(object commandParameter)
/// <param name="_">Object that the command is tied to</param>
private void ClearQueryBuilder(object _)
{
SelectedComboBoxCommand = null;
DynamicParametersCollection.Clear();
DynamicParameterValuesCollection.Clear();
if (SelectedComboBoxCommand is null && DynamicParametersCollection.Count == 0)
{
MessageBox.Show("The query builder is already clear.",
"Information",
MessageBoxButton.OK,
MessageBoxImage.Information);
return;
}

// Display a gui box confirming if the user wants to confirm the clear
MessageBoxResult result = MessageBox.Show("Are you sure you want to clear the query builder?",
"Warning",
MessageBoxButton.YesNo,
MessageBoxImage.Warning,
MessageBoxResult.No);

// If the user selects yes, clear the console
if (result == MessageBoxResult.Yes)
{
SelectedComboBoxCommand = null;
DynamicParametersCollection.Clear();
DynamicParameterValuesCollection.Clear();
}
}

/// <summary>
/// This method is for creating buttons, right now it creates it off of the current/selectedcommand parameters but
/// could be changed to also do it from the query list.
/// TODO: Change method name???
/// </summary>
/// <note>
/// TODO: Change method name?
/// </note>
/// <returns>This method returns a button that has been customized for the custom query list</returns>
private Button CreateCustomButton(Query? query = null)
{
Expand Down

0 comments on commit f721f42

Please sign in to comment.