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

Commit

Permalink
Format using clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
StrangeRanger committed Mar 23, 2024
1 parent 42993d2 commit ade8862
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
36 changes: 16 additions & 20 deletions ActiveDirectoryQuerier/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,8 @@ private void DeleteQueryFromQueryStackPanel(object queryButton)
private void CreateNewQueryFile(object _)
{
// Saves/creates a new save file for the queries
SaveFileDialog saveFileDialog = new()
{
Filter = "Json files (*.json)|*.json|Text files (*.txt)|*.txt"
};

SaveFileDialog saveFileDialog = new() { Filter = "Json files (*.json)|*.json|Text files (*.txt)|*.txt" };

if (saveFileDialog.ShowDialog() == true)
{
QueryButtonStackPanel.Clear();
Expand Down Expand Up @@ -575,7 +572,7 @@ private void SaveCurrentQuery(object commandParameter)
_queryManager.ConvertCommandToQueryAndSave(SelectedCommandInQueryBuilder, QueryName, QueryDescription);

Button newButton = CreateQueryButtonInStackPanel();

if (newButton.Content != null)
{
QueryButtonStackPanel.Add(newButton);
Expand Down Expand Up @@ -616,7 +613,7 @@ private void ClearQueryBuilder(object _)
DynamicallyAvailableADCommandParameterValueTextBoxes.Clear();
}
}

/// <remarks>
/// The use of the <c>command</c> parameter indicates that the method can be called from the Query Stack Panel.
/// On the other hand, the absence of the <c>command</c> parameter and use of the
Expand All @@ -625,7 +622,7 @@ private void ClearQueryBuilder(object _)
private async Task ExecuteQueryAsync(ConsoleViewModel consoleOutput, Command? command = null)
{
PSExecutor psExecutor = new();

if (SelectedCommandInQueryBuilder is null && command is null)
{
Trace.WriteLine("No command selected.");
Expand All @@ -651,8 +648,7 @@ private async Task ExecuteQueryAsync(ConsoleViewModel consoleOutput, Command? co
// Null forgiveness operator is used because if command is not null, this line will never be reached.
// If it is null, that must mean that SelectedCommandInQueryBuilder is not null, else the return
// statement above would have been executed.
result =
await psExecutor.ExecuteAsync(SelectedCommandInQueryBuilder!, outputFormat);
result = await psExecutor.ExecuteAsync(SelectedCommandInQueryBuilder!, outputFormat);
}

if (result.HadErrors)
Expand All @@ -668,23 +664,23 @@ private async Task ExecuteQueryAsync(ConsoleViewModel consoleOutput, Command? co
consoleOutput.Append($"Error executing command: {exception.Message}");
}
}

private async void ExecuteQueryFromQueryStackPanelAsync(object queryButton)
{
if (queryButton is not Button currentButton)
{
Trace.WriteLine("No button selected.");
MessageBox.Show("To execute a query, you must first select a query.",
"Warning",
MessageBoxButton.OK,
MessageBoxImage.Warning);
"Warning",
MessageBoxButton.OK,
MessageBoxImage.Warning);
return;
}

var buttonQuery = (Query)currentButton.Tag;
await ExecuteQueryAsync(ConsoleOutputInQueryBuilder, buttonQuery.Command);
}

private void ExportConsoleOutputToFile(object _)
{
if (ConsoleOutputInQueryBuilder.ConsoleOutput.Length == 0)
Expand All @@ -703,7 +699,7 @@ private void ExportConsoleOutputToFile(object _)
ConsoleOutputInQueryBuilder.ExportToTextFile(filename);
}
}

private async void OutputExecutionResultsToTextFileAsync(object? queryButton)
{
await OutputExecutionResultsToFileAsync(queryButton, ".txt", "Text documents (.txt)|*.txt");
Expand Down Expand Up @@ -800,7 +796,7 @@ private Button CreateQueryButtonInStackPanel(Query? query = null)
newButton.ContextMenu = contextMenu;
return newButton;
}

private void OnIsQueryEditingEnabledChanged()
{
if (!IsQueryEditingEnabled)
Expand All @@ -814,9 +810,9 @@ private void CheckBoxChecked(object obj)
if (IsQueryEditingEnabled)
{
MessageBox.Show("To edit a query, right click on a query button and select 'Edit' from the context menu.",
"Warning",
MessageBoxButton.OK,
MessageBoxImage.Warning);
"Warning",
MessageBoxButton.OK,
MessageBoxImage.Warning);
IsQueryEditingEnabled = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion ActiveDirectoryQuerier/PowerShell/PSExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public async Task<PSOutput> ExecuteAsync(Command command, OutputFormat outputFor
return HandleExecutionException(exception);
}
}

private void AssembleFullCommand(Command psCommand, OutputFormat outputFormat)
{
ArgumentNullException.ThrowIfNull(psCommand);
Expand Down

0 comments on commit ade8862

Please sign in to comment.