diff --git a/ActiveDirectoryQuerier/MainWindow.xaml b/ActiveDirectoryQuerier/MainWindow.xaml index 689ac82..e39fa67 100644 --- a/ActiveDirectoryQuerier/MainWindow.xaml +++ b/ActiveDirectoryQuerier/MainWindow.xaml @@ -26,6 +26,7 @@
diff --git a/ActiveDirectoryQuerier/MainWindowViewModel.cs b/ActiveDirectoryQuerier/MainWindowViewModel.cs index d15248c..a155491 100644 --- a/ActiveDirectoryQuerier/MainWindowViewModel.cs +++ b/ActiveDirectoryQuerier/MainWindowViewModel.cs @@ -163,6 +163,7 @@ public Command? SelectedCommandFromComboBoxInActiveDirectoryInfo public ICommand ExportConsoleOutputRelay { get; } public ICommand ClearConsoleOutputInQueryBuilderRelay { get; } public ICommand ImportQueryFileRelay { get; } + public ICommand CreateNewQueryFileRelay { get; } public ICommand ClearConsoleOutputInActiveDirectoryInfoRelay { get; } // TODO: Impliment functionality..... @@ -204,6 +205,7 @@ public MainWindowViewModel() ExecuteQueryFromActiveDirectoryInfoRelay = new RelayCommand( _ => ExecuteQuery(_consoleOutputInActiveDirectoryInfo)); ImportQueryFileRelay = new RelayCommand(ImportQueryFile); + CreateNewQueryFileRelay = new RelayCommand(CreateNewQueryFile); AddCommandParameterComboBoxRelay = new RelayCommand(AddParameterComboBoxInQueryBuilder); AddCommandComboBoxRelay = new RelayCommand(AddCommandComboBoxInQueryBuilder); RemoveCommandParameterComboBoxRelay = new RelayCommand(RemoveCommandParameterComboBoxInQueryBuilder); @@ -347,6 +349,18 @@ private void DeleteQueryFromQueryStackPanel(object queryButton) } } + private void CreateNewQueryFile(object _) + { + // Saves/creates a new save file for the queries + SaveFileDialog saveFileDialog = new SaveFileDialog(); + saveFileDialog.Filter = "Json files (*.json)|*.json|Text files (*.txt)|*.txt"; + if (saveFileDialog.ShowDialog() == true) + { + File.WriteAllText(saveFileDialog.FileName, string.Empty); + _customQuery.CustomQueryFileLocation = saveFileDialog.FileName; + } + } + private void LoadSavedQueriesFromFile() { try @@ -372,7 +386,7 @@ private void ImportQueryFile(object _) { OpenFileDialog dialog = new() { FileName = "CustomQueries.dat", - Filter = "All files(*.*) | *.*" + Filter = "Json files (*.json)|*.json|Text Files (*.txt)|*.txt" }; diff --git a/ActiveDirectoryQuerier/Queries/CustomQueries.cs b/ActiveDirectoryQuerier/Queries/CustomQueries.cs index 02d9d93..511e1a3 100644 --- a/ActiveDirectoryQuerier/Queries/CustomQueries.cs +++ b/ActiveDirectoryQuerier/Queries/CustomQueries.cs @@ -1,5 +1,4 @@ -using System; -using System.Diagnostics; +using System.Diagnostics; using System.IO; using System.Management.Automation.Runspaces; using System.Text.Json; @@ -9,7 +8,7 @@ namespace ActiveDirectoryQuerier.Queries; ///