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

Commit

Permalink
filling dropdown with users (not complete yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsobtafo committed Feb 27, 2024
1 parent de2d5eb commit 56ec835
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
2 changes: 1 addition & 1 deletion FAFB-PowerShell-Tool/FAFB-PowerShell-Tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<!-- Project Compile Time Settings. -->
<PublishSingleFile>false</PublishSingleFile>
<SelfContained>true</SelfContained>
<SelfContained>false</SelfContained> <!-- changed from true to false-->
<DebugType>embedded</DebugType>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
Expand Down
76 changes: 76 additions & 0 deletions FAFB-PowerShell-Tool/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,82 @@ public sealed class MainWindowViewModel : INotifyPropertyChanged
/// <summary>
/// The name of the query.
/// </summary>
/// New code begins here

private void LoadCustomQueries()
{
try
{
// Assuming Get-Users returns a list of users
List<User> users = GetUsersCommand(); // Replace this with your actual PowerShell command

foreach (User user in users)
{
// Create a new button for each user
Button newUserButton = new() { Height = 48 };

// Set button content (text) to user's name or any relevant information
newUserButton.Content = user.UserName;

// Bind the user object to the button
newUserButton.Tag = user;

// Create a context menu for the button
ContextMenu contextMenu = new ContextMenu();

// Add menu items to the context menu
MenuItem menuItem1 = new MenuItem { Header = "Execute" };
menuItem1.Command = ExecuteCommandButton;
menuItem1.CommandParameter = newUserButton;

MenuItem menuItem2 = new MenuItem { Header = "Edit" };
menuItem2.Command = EditCustomQuery;
menuItem2.CommandParameter = newUserButton;

MenuItem menuItem3 = new MenuItem { Header = "Delete" };
menuItem3.Command = Remove_ParameterComboBox;

// Add menu items to the context menu
contextMenu.Items.Add(menuItem1);
contextMenu.Items.Add(menuItem2);
contextMenu.Items.Add(menuItem3);

// Set the context menu for the button
newUserButton.ContextMenu = contextMenu;

// Add the button to the stack panel
ButtonStackPanel.Add(newUserButton);
}
}
catch (Exception ex)
{
Trace.WriteLine(ex);
}
}

// Replace User with your actual user class
public class User
{
public string UserName { get; set; }
// Add other properties as needed
}

// Replace this with your actual PowerShell command to get users
private List<User> GetUsersCommand()
{
// Your PowerShell command logic to get users
return new List<User>
{
new User { UserName = "User1" },
new User { UserName = "User2" },

};
}

/// New code ends here



public string QueryName
{
get {
Expand Down

0 comments on commit 56ec835

Please sign in to comment.