### Build and Run PleasantUI Example App
Source: https://github.com/onebeld/pleasantui/blob/main/samples/PleasantUI.Example/README.md
Commands to build the entire PleasantUI solution and run the example application from the repository root. Ensure .NET 9.0 SDK and Avalonia 12.0 are installed.
```bash
# Navigate to the PleasantUI repository root
cd PleasantUI
# Build the entire solution
dotnet build
# Run the example app
dotnet run --project samples/PleasantUI.Example/PleasantUI.Example.csproj
```
--------------------------------
### Basic InstallWizard Usage
Source: https://github.com/onebeld/pleasantui/blob/main/docs/InstallWizard.md
Defines a multi-step installation wizard with three steps: Welcome, License, and Install. Each step has a header and content.
```xml
```
--------------------------------
### Full TerminalPanel Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/TerminalPanel.md
A comprehensive example demonstrating the initialization and command handling of a TerminalPanel.
```csharp
var terminal = new TerminalPanel
{
Title = "Command Line",
Prompt = ">",
IsRunning = true
};
terminal.CommandSubmitted += (sender, cmd) =>
{
terminal.AppendOutput($"{terminal.Prompt} {cmd}\n");
switch (cmd.ToLower())
{
case "help":
terminal.AppendOutput("Available commands: help, clear, echo [text]\n");
break;
case "clear":
terminal.ClearOutput();
break;
default:
terminal.AppendOutput($"Unknown command: {cmd}\n");
break;
}
};
```
--------------------------------
### StepDialog Full Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/StepDialog.md
A comprehensive example showing the initialization and usage of StepDialog with various properties and event handling.
```APIDOC
## StepDialog Full Example
### Description
This example provides a complete illustration of creating, configuring, and displaying a `StepDialog` with multiple steps and event handling.
### Method
N/A (UI Component)
### Endpoint
N/A (UI Component)
### Parameters
#### Path Parameters
N/A
#### Query Parameters
N/A
#### Request Body
N/A
### Request Example
```csharp
var dialog = new StepDialog
{
Title = "Installation Wizard",
Description = "Complete these steps to install the application",
PrimaryButtonText = "Next",
SecondaryButtonText = "Cancel"
};
dialog.Steps.Add(new StepItem { Title = "Welcome", Description = "Introduction" });
dialog.Steps.Add(new StepItem { Title = "License", Description = "Accept terms" });
dialog.Steps.Add(new StepItem { Title = "Install", Description = "Install files" });
dialog.PrimaryButtonClicked += (sender, e) =>
{
// Handle next step
};
await dialog.ShowAsync(window);
```
### Response
#### Success Response (200)
N/A (UI Component)
#### Response Example
N/A
```
--------------------------------
### VirtualizingWrapPanel Example with Images
Source: https://github.com/onebeld/pleasantui/blob/main/docs/VirtualizingWrapPanel.md
An example demonstrating VirtualizingWrapPanel with fixed item sizes for displaying a collection of images. This configuration is suitable for visual content.
```xml
```
--------------------------------
### Complete StepDialog Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/StepDialog.md
This comprehensive example demonstrates initializing a StepDialog with properties, adding steps programmatically, and attaching event handlers for button clicks, followed by showing the dialog.
```csharp
var dialog = new StepDialog
{
Title = "Installation Wizard",
Description = "Complete these steps to install the application",
PrimaryButtonText = "Next",
SecondaryButtonText = "Cancel"
};
dialog.Steps.Add(new StepItem { Title = "Welcome", Description = "Introduction" });
dialog.Steps.Add(new StepItem { Title = "License", Description = "Accept terms" });
dialog.Steps.Add(new StepItem { Title = "Install", Description = "Install files" });
dialog.PrimaryButtonClicked += (sender, e) =>
{
// Handle next step
};
await dialog.ShowAsync(window);
```
--------------------------------
### LogViewerPanel Copy Handling and Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/LogViewerPanel.md
Provides code examples for handling copy requests for individual entries or all entries, and a complete ViewModel example demonstrating LogViewerPanel integration.
```APIDOC
### Copy Handling
Handle copy requests:
```csharp
logViewerPanel.CopyAllRequested += (sender, e) =>
{
var text = string.Join("\n", logViewerPanel.FilteredEntries.Select(x => x.ToString()));
Clipboard.SetTextAsync(text);
};
logViewerPanel.CopyEntryRequested += (sender, entry) =>
{
Clipboard.SetTextAsync(entry.ToString());
};
```
### Example
```csharp
// In your ViewModel
public class MainViewModel
{
public LogViewerPanel LogViewer { get; } = new LogViewerPanel
{
Title = "Application Logs",
MaxEntries = 10000
};
private void LogOperation(string message, LogLevel level = LogLevel.Information)
{
LogViewer.Append(level, message, Source: "MainViewModel");
}
}
```
```
--------------------------------
### Complex DashboardCard Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/DashboardCard.md
An advanced example combining header, subtitle, toolbar items, content, and footer.
```xml
```
--------------------------------
### InstallWizard Show as Modal Dialog
Source: https://github.com/onebeld/pleasantui/blob/main/docs/InstallWizard.md
Example of how to display the InstallWizard as a modal dialog and handle its completion.
```APIDOC
## Show as Modal Dialog
### Description
This code snippet demonstrates how to launch the `InstallWizard` as a modal dialog and react to its completion.
### Method
`InstallWizard.ShowAsModalAsync`
### Endpoint
Not Applicable (Method Call)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```csharp
bool finished = await InstallWizard.ShowAsModalAsync(wizard, this);
if (finished)
CompleteInstallation();
```
### Response
#### Success Response (200)
Not Applicable (Method Return)
#### Response Example
`bool`: `true` if the wizard was finished, `false` if cancelled.
```
--------------------------------
### InstallWizard Show as Standalone Window
Source: https://github.com/onebeld/pleasantui/blob/main/docs/InstallWizard.md
Example of how to display the InstallWizard in a standalone window with specified dimensions.
```APIDOC
## Show as Standalone Window
### Description
This code snippet shows how to display the `InstallWizard` in a separate `PleasantWindow` with custom width and height.
### Method
`InstallWizard.ShowAsWindowAsync`
### Endpoint
Not Applicable (Method Call)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```csharp
bool finished = await InstallWizard.ShowAsWindowAsync(wizard, owner: this, width: 760, height: 500);
```
### Response
#### Success Response (200)
Not Applicable (Method Return)
#### Response Example
`bool`: `true` if the wizard was finished, `false` if cancelled.
```
--------------------------------
### Complete PropertyGrid Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PropertyGrid.md
A comprehensive example showcasing a PropertyGrid with custom label column width, row spacing, and multiple property rows.
```xml
```
--------------------------------
### Rich PleasantDialog Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PleasantDialog.md
A comprehensive example showcasing a PleasantDialog with an icon, subheader, custom commands, buttons, and an expandable footer.
```csharp
object result = await PleasantDialog.Show(window,
header: "Sync settings",
body: "Choose how your settings should be synchronized.",
iconGeometryKey: "TuneRegular",
subHeader: "Affects all connected accounts.",
commands: new PleasantDialogCommand[]
{
new PleasantDialogRadioButton { Text = "Sync automatically", IsChecked = true },
new PleasantDialogRadioButton { Text = "Ask before syncing" },
new PleasantDialogCheckBox { Text = "Remember my choice" }
},
buttons: new[]
{
new PleasantDialogButton { Text = "Save", DialogResult = PleasantDialogResult.OK, IsDefault = true },
new PleasantDialogButton { Text = "Cancel", DialogResult = PleasantDialogResult.Cancel }
},
footer: new TextBlock { Text = "Changes take effect after restart." },
footerExpandable: true,
footerToggleText: "More details");
```
--------------------------------
### PleasantDialog - Rich Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PleasantDialog.md
A comprehensive example showcasing the integration of various PleasantDialog features, including icons, subheaders, commands, custom buttons, and an expandable footer.
```APIDOC
## POST /api/dialogs/rich
### Description
Displays a highly customized PleasantDialog with multiple interactive elements and styling options.
### Method
POST
### Endpoint
/api/dialogs/rich
### Request Body
- **header** (string) - Required - The main title of the dialog.
- **body** (string) - Optional - The descriptive text content of the dialog.
- **iconGeometryKey** (string) - Optional - Resource key for an icon to display in the header.
- **subHeader** (string) - Optional - Secondary text below the main header.
- **commands** (array) - Optional - An array of command items (see `PleasantDialog - Command Items` for details).
- **buttons** (array) - Optional - An array of `PleasantDialogButton` objects.
- **PleasantDialogButton**:
- **Text** (string) - Required - The text displayed on the button.
- **DialogResult** (string) - Required - The result returned when the button is clicked.
- **IsDefault** (bool) - Optional - If true, the button receives accent styling and is triggered by the Enter key.
- **footer** (string) - Optional - Content for the dialog's footer.
- **footerExpandable** (bool) - Optional - If true, the footer can be expanded or collapsed.
- **footerToggleText** (string) - Optional - Text for the footer toggle button.
### Request Example
```json
{
"header": "Sync settings",
"body": "Choose how your settings should be synchronized.",
"iconGeometryKey": "TuneRegular",
"subHeader": "Affects all connected accounts.",
"commands": [
{
"type": "PleasantDialogRadioButton",
"Text": "Sync automatically",
"IsChecked": true
},
{
"type": "PleasantDialogRadioButton",
"Text": "Ask before syncing"
},
{
"type": "PleasantDialogCheckBox",
"Text": "Remember my choice"
}
],
"buttons": [
{
"Text": "Save",
"DialogResult": "OK",
"IsDefault": true
},
{
"Text": "Cancel",
"DialogResult": "Cancel"
}
],
"footer": "Changes take effect after restart.",
"footerExpandable": true,
"footerToggleText": "More details"
}
```
### Response
#### Success Response (200)
- **result** (string) - The `DialogResult` of the selected button or command.
#### Response Example
```json
{
"result": "OK"
}
```
```
--------------------------------
### Basic Usage Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PleasantDrawer.md
Demonstrates the basic structure and usage of the PleasantDrawer component.
```APIDOC
## Basic Usage
```xml
```
```csharp
await drawer.ShowAsync(window);
```
```
--------------------------------
### Footer Content Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PleasantDrawer.md
Provides an example of how to add custom footer content to the PleasantDrawer.
```APIDOC
## Footer content
Add action buttons or other content at the bottom of the drawer:
```xml
```
```
--------------------------------
### Reading Selected Items Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/SelectionList.md
Provides a C# code example for retrieving the selected items from a SelectionList.
```APIDOC
## Reading Selected Items
```csharp
var selected = selectionList.SelectedItems?.Cast().ToList();
```
```
--------------------------------
### Loading State Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/ItemListPanel.md
Illustrates how to display a loading overlay using the `IsLoading`, `LoadingTitle`, and `LoadingSubtitle` properties.
```APIDOC
## Loading state
Show a loading overlay while data is being fetched:
```xml
```
```csharp
itemListPanel.IsLoading = true;
// ... load data ...
itemListPanel.IsLoading = false;
```
```
--------------------------------
### Multi-select Mode Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/ItemListPanel.md
Shows how to enable multi-select mode and configure the `BulkActionsContent` to display actions for selected items.
```APIDOC
## Multi-select mode
Enable multi-select mode to allow selecting multiple items:
```xml
```
```csharp
itemListPanel.IsMultiSelectMode = true;
var selectedItems = itemListPanel.GetSelectedItems();
itemListPanel.SelectAll();
itemListPanel.UnselectAll();
```
```
--------------------------------
### ViewModel for DownloadPanel
Source: https://github.com/onebeld/pleasantui/blob/main/docs/DownloadPanel.md
Example ViewModel demonstrating how to manage `DownloadPanel` state and commands, including pause/resume and cancellation logic.
```csharp
// ViewModel
public class DownloadViewModel
{
public DownloadPanel DownloadPanel { get; } = new();
public ICommand PauseResumeCommand => new RelayCommand(() =>
{
DownloadPanel.IsPaused = !DownloadPanel.IsPaused;
if (!DownloadPanel.IsPaused)
ResumeDownload();
else
PauseDownload();
});
public ICommand CancelCommand => new RelayCommand(CancelDownload);
private void UpdateProgress(double progress)
{
DownloadPanel.Progress = progress;
}
private void AddChunk(double start, double end)
{
DownloadPanel.Chunks.Add(new ChunkInfo
{
Start = start,
End = end,
Progress = 0.0
});
}
}
```
--------------------------------
### MarkedTextBox Example in a Login Form
Source: https://github.com/onebeld/pleasantui/blob/main/docs/MarkedTextBox.md
A practical example demonstrating the use of MarkedTextBox controls within a simple login form layout, including username/email and password fields.
```xml
```
--------------------------------
### Empty State Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/ItemListPanel.md
Provides an example of customizing the empty state display using `EmptyStateTitle` and `EmptyStateSubtitle` when no items are present.
```APIDOC
## Empty state
When the list is empty, an empty state is displayed automatically. Customize the title and subtitle:
```xml
```
```csharp
itemListPanel.EmptyStateTitle = "No results found";
itemListPanel.EmptyStateSubtitle = "Try a different search term";
```
```
--------------------------------
### PathPicker Basic Usage Examples
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PathPicker.md
Demonstrates basic configurations for opening single files, opening folders, and saving files using the PathPicker component.
```xml
```
```xml
```
```xml
```
--------------------------------
### Horizontal Layout Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/SelectionList.md
Demonstrates how to configure the SelectionList for a horizontal orientation.
```APIDOC
## Horizontal Layout
```xml
```
```
--------------------------------
### ShadowBorder Example with Complex Content
Source: https://github.com/onebeld/pleasantui/blob/main/docs/ShadowBorder.md
A comprehensive example of ShadowBorder usage, styling a card-like element with text content.
```xml
```
--------------------------------
### Complete MarkedNumericUpDown Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/MarkedNumericUpDown.md
An example demonstrating the integration of MarkedNumericUpDown controls within a StackPanel for order details, including quantity, price, and discount inputs.
```xml
```
--------------------------------
### PleasantFlyout with Menu Items
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PleasantFlyout.md
An example of using PleasantFlyout to display a menu with items, separators, and actions.
```xml
```
--------------------------------
### NavigationView Basic Usage
Source: https://github.com/onebeld/pleasantui/blob/main/docs/NavigationView.md
Demonstrates the basic setup of a NavigationView with left-aligned items.
```APIDOC
## NavigationView Basic Usage
### Description
This example shows a basic NavigationView with items positioned on the left. Each `NavigationViewItem` has a header, icon, title, and content associated with it.
### Method
N/A (UI Component Configuration)
### Endpoint
N/A (UI Component Configuration)
### Parameters
#### Path Parameters
N/A
#### Query Parameters
N/A
#### Request Body
N/A
### Request Example
```xml
```
### Response
N/A (UI Component Configuration)
#### Success Response (200)
N/A
#### Response Example
N/A
```
--------------------------------
### ViewModel Integration Example for LogViewerPanel
Source: https://github.com/onebeld/pleasantui/blob/main/docs/LogViewerPanel.md
Shows how to integrate a LogViewerPanel instance within a ViewModel, including appending entries.
```csharp
// In your ViewModel
public class MainViewModel
{
public LogViewerPanel LogViewer { get; } = new LogViewerPanel
{
Title = "Application Logs",
MaxEntries = 10000
};
private void LogOperation(string message, LogLevel level = LogLevel.Information)
{
LogViewer.Append(level, message, Source: "MainViewModel");
}
}
```
--------------------------------
### ProgressRing Sizes
Source: https://github.com/onebeld/pleasantui/blob/main/docs/ProgressRing.md
Examples of how to adjust the size of the ProgressRing for different use cases.
```APIDOC
## ProgressRing Sizes
### Description
This section provides examples of how to set different sizes for the `ProgressRing` component, suitable for various UI contexts from small inline indicators to larger hero elements.
### Method
N/A (UI Component)
### Endpoint
N/A (UI Component)
### Parameters
#### Path Parameters
N/A
#### Query Parameters
N/A
#### Request Body
N/A
### Request Example
```xml
```
### Response
N/A (UI Component)
#### Success Response (200)
N/A
#### Response Example
N/A
```
--------------------------------
### Data-bound List Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/SelectionList.md
Shows how to bind data to the SelectionList using `ItemsSource` and member bindings.
```APIDOC
## Data-bound List
```xml
```
```
--------------------------------
### Install PleasantUI DataGrid Package
Source: https://github.com/onebeld/pleasantui/blob/main/docs/DataGrid.md
Add this NuGet package reference to your project to include the PleasantUI DataGrid functionality.
```xml
```
--------------------------------
### DataGrid Usage Example
Source: https://context7.com/onebeld/pleasantui/llms.txt
Demonstrates how to use the DataGrid component with custom columns and row details template. Configure properties like ItemsSource, AutoGenerateColumns, and SelectionMode as needed.
```xml
```
--------------------------------
### Searching and Filtering Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/ItemListPanel.md
Demonstrates how to use the search functionality, including setting the search watermark and programmatically controlling the search text.
```APIDOC
## Searching and filtering
The panel includes a search box that filters items in real-time:
```xml
```
```csharp
// Set search text programmatically
itemListPanel.SearchText = "search term";
// Clear search
itemListPanel.ClearSearch();
```
```
--------------------------------
### Create a New Page Implementing IPage
Source: https://github.com/onebeld/pleasantui/blob/main/samples/PleasantUI.Example/README.md
Implement the IPage interface and InitializeComponent() in your custom page class. This example shows a basic structure for a new page.
```csharp
public class MyPage : UserControl, IPage
{
public MyPage()
{
InitializeComponent();
}
}
```
--------------------------------
### Footer Content Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/ItemListPanel.md
Shows how to add custom content to the footer slot, such as pagination controls.
```APIDOC
## Footer content
Add a footer for pagination or other controls:
```xml
```
```
--------------------------------
### Basic PleasantWindow Setup
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PleasantWindow.md
Defines a basic PleasantWindow in XAML and its corresponding C# code-behind. Ensure the C# class inherits from PleasantWindow.
```xml
```
```csharp
public partial class MainWindow : PleasantWindow
{
public MainWindow() => InitializeComponent();
}
```
--------------------------------
### ButtonPage Implementation
Source: https://github.com/onebeld/pleasantui/blob/main/samples/PleasantUI.Example/README.md
An example of a page implementing the LocalizedPage base class, specifying its title key, title visibility, and content creation.
```csharp
// Page implementation
public class ButtonPage : LocalizedPage
{
public override string TitleKey { get; } = "CardTitle/Button";
public override bool ShowTitle { get; } = true;
protected override Control CreateContent() => new ButtonPageView();
}
```
--------------------------------
### Selection Handling Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/ItemListPanel.md
Demonstrates how to handle the `SelectionChanged` event to react to item selections and access the `SelectedItem` and `SelectedCount` properties.
```APIDOC
## Selection handling
Handle selection changes:
```csharp
itemListPanel.SelectionChanged += (sender, e) =>
{
var selectedItem = itemListPanel.SelectedItem;
var selectedCount = itemListPanel.SelectedCount;
};
```
```
--------------------------------
### Data-bound Timeline Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/Timeline.md
Shows how to bind the Timeline component to an `ItemsSource` and configure member bindings for header, content, and time.
```APIDOC
## Data-bound Timeline Example
### Description
This example demonstrates how to use the `Timeline` component with an `ItemsSource`. It configures `HeaderMemberBinding`, `ContentMemberBinding`, and `TimeMemberBinding` to map data from the source to the timeline item's properties. The `TimeFormat` is also customized.
### Method
N/A (UI Component)
### Endpoint
N/A (UI Component)
### Request Body
N/A (UI Component)
### Request Example
```xml
```
### Response
N/A (UI Component)
### Response Example
N/A (UI Component)
```
--------------------------------
### PleasantMenuFlyout with Input Gestures
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PleasantMenuFlyout.md
An example of a PleasantMenuFlyout within a Button, showcasing menu items with associated keyboard input gestures.
```xml
```
--------------------------------
### Styling ProgressRing
Source: https://github.com/onebeld/pleasantui/blob/main/docs/ProgressRing.md
Provides an example of how to override the default styling of the ProgressRing using standard property setters for Foreground and Background.
```xml
```
--------------------------------
### Create Custom Theme Programmatically
Source: https://github.com/onebeld/pleasantui/blob/main/docs/ThemeEngine.md
Create a new custom theme by programmatically defining its colors. Start with a template dictionary, override specific colors like 'AccentColor', and then add it to PleasantTheme.CustomThemes.
```csharp
var colors = PleasantTheme.GetThemeTemplateDictionary(); // start from Light
colors["AccentColor"] = Color.Parse("#FF6B35"); // override accent
var custom = new CustomTheme
{
Name = "My Theme",
Colors = colors.ToColorPalette()
};
PleasantTheme.CustomThemes.Add(custom);
PleasantTheme.SelectedCustomTheme = custom;
```
--------------------------------
### Dynamic Tab Management with C#
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PleasantTabView.md
Provides C# code examples for dynamically managing tabs, including adding new tabs and handling tab closing events.
```APIDOC
## Dynamic Tab Management
```csharp
// Add a tab when + is clicked
tabView.ClickOnAddingButton += (_, _) =>
{
tabView.Items.Add(new PleasantTabItem
{
Header = $"Tab {tabView.Items.Count + 1}",
Content = new MyTabContent()
});
};
// Prevent closing a specific tab
tab.Closing += (_, e) =>
{
if (HasUnsavedChanges())
e.Handled = true; // cancel close
};
```
## Programmatic Close
```csharp
tab.CloseCore(); // removes the tab from its parent PleasantTabView
```
```
--------------------------------
### InstallWizard Basic Usage
Source: https://github.com/onebeld/pleasantui/blob/main/docs/InstallWizard.md
Demonstrates the basic structure and usage of the InstallWizard component with multiple WizardStep instances.
```APIDOC
## InstallWizard Basic Usage
### Description
This section shows how to define an `InstallWizard` with several `WizardStep` components, including their headers, descriptions, and content.
### Method
Not Applicable (UI Component Definition)
### Endpoint
Not Applicable (UI Component Definition)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```xml
```
### Response
#### Success Response (200)
Not Applicable (UI Component Definition)
#### Response Example
None
```
--------------------------------
### Basic ItemListPanel Usage
Source: https://github.com/onebeld/pleasantui/blob/main/docs/ItemListPanel.md
Demonstrates the fundamental setup of an ItemListPanel by binding its ItemsSource and ItemTemplate, and enabling two-way data binding for SearchText.
```xml
```
--------------------------------
### Install PleasantUI Packages
Source: https://github.com/onebeld/pleasantui/blob/main/README.md
Add these PackageReference elements to your project file to include PleasantUI components. Ensure you are using the correct version for your Avalonia framework.
```xml
```
--------------------------------
### Copy Project Directory
Source: https://github.com/onebeld/pleasantui/blob/main/samples/PleasantUI.Example/README.md
Use the xcopy command to copy the example application directory to a new location for your real-world application. Ensure to use the /E and /I flags for copying subdirectories and creating the destination directory if it doesn't exist.
```bash
# Copy the example app to your new project location
xcopy /E /I PleasantUI.Example AutoparkERP
# Navigate to the new project
cd AutoparkERP
# Rename files
ren PleasantUI.Example.csproj AutoparkERP.csproj
ren PleasantUiExampleApp.cs AutoparkERPApp.cs
```
--------------------------------
### Custom Arc Range for ProgressRing
Source: https://github.com/onebeld/pleasantui/blob/main/docs/ProgressRing.md
Demonstrates how to create a partial ring by specifying custom StartAngle and EndAngle values. This example shows the bottom half of the ring.
```xml
```
--------------------------------
### InstallWizard Programmatic Navigation
Source: https://github.com/onebeld/pleasantui/blob/main/docs/InstallWizard.md
Demonstrates how to control the wizard's steps programmatically.
```APIDOC
## Programmatic Navigation
### Description
Provides examples of navigating between wizard steps using code, including advancing, going back, and jumping to a specific step.
### Method
`wizard.GoNext()`, `wizard.GoBack()`, `wizard.CurrentStepIndex` assignment
### Endpoint
Not Applicable (Method Calls / Property Assignment)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```csharp
// Advance to the next step
wizard.GoNext(); // advance to next step (raises Finished on last step)
// Go back to the previous step
wizard.GoBack(); // go to previous step
// Jump directly to a specific step (e.g., the 3rd step, index 2)
wizard.CurrentStepIndex = 2; // jump directly to a step
```
### Response
#### Success Response (200)
Not Applicable (Method Return / Property Change)
#### Response Example
None
```
--------------------------------
### Custom Dialog Class Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/ContentDialog.md
Provides an example of subclassing ContentDialog to create a custom dialog, like a confirmation dialog.
```APIDOC
## Custom Dialog Class
### Description
This example shows how to create a custom dialog by subclassing `ContentDialog`. It includes a `ConfirmDialog` class with a static `Show` method for easy instantiation and display, demonstrating how to configure and show the dialog with a result.
### Method
C# Class Definition and Method Call
### Endpoint
N/A
### Parameters
N/A
### Request Example
```csharp
public class ConfirmDialog : ContentDialog
{
public ConfirmDialog()
{
InitializeComponent();
// wire up buttons
}
public static async Task Show(IPleasantWindow parent, string message)
{
var dialog = new ConfirmDialog();
// configure...
string? result = await dialog.ShowAsync(parent);
return result == "confirmed";
}
}
```
### Response
N/A
#### Success Response (200)
N/A
#### Response Example
N/A
```
--------------------------------
### InstallWizard Marking a Step Complete
Source: https://github.com/onebeld/pleasantui/blob/main/docs/InstallWizard.md
Shows how to manually mark a wizard step as complete and set its completion state.
```APIDOC
## Marking a Step Complete with a State
### Description
This example demonstrates how to programmatically mark the current wizard step as completed and assign a specific completion state (e.g., Warning).
### Method
`wizard.CurrentStep.IsCompleted` assignment, `wizard.CurrentStep.CompletionState` assignment, `wizard.GoNext()`
### Endpoint
Not Applicable (Property Assignment / Method Call)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```csharp
// Mark the current step as completed with a warning state
wizard.CurrentStep!.IsCompleted = true;
wizard.CurrentStep!.CompletionState = WizardStepCompletionState.Warning;
// Then, advance to the next step
wizard.GoNext();
```
### Response
#### Success Response (200)
Not Applicable (State Change)
#### Response Example
None
```
--------------------------------
### InstallWizard UI Definition
Source: https://context7.com/onebeld/pleasantui/llms.txt
Define an InstallWizard with a title, icon, footer, and event handlers for completion and cancellation. Steps are defined within InstallWizard.Steps, each with a Header, Description, and Content.
```xml
```
--------------------------------
### Initialize and Use Localization System
Source: https://context7.com/onebeld/pleasantui/llms.txt
Register resource managers and set the initial language in the App constructor. Switch languages at runtime and perform lookups with fallback options.
```csharp
// Register resource managers in App constructor
public App()
{
Localizer.AddRes(new ResourceManager(typeof(Properties.Localizations.App)));
Localizer.AddRes(new ResourceManager(typeof(LibraryStrings))); // multiple files
Localizer.ChangeLang("en"); // set initial language
}
// Switch language at runtime
Localizer.ChangeLang("ru");
// Code-behind lookups
string text = Localizer.Instance["WelcomeMessage"]; // simple lookup
string title = Localizer.TrDefault("DialogTitle", "Confirm"); // safe lookup with fallback
string label = Localizer.TrDefault("Save", "Save", "Settings"); // with context
string msg = Localizer.Tr("ItemCount", context: null, args: 42); // with format args
// Subscribe to language changes
Localizer.Instance.LocalizationChanged += lang =>
{
Console.WriteLine($"Language changed to: {lang}");
};
```
--------------------------------
### Basic CommandBar Usage
Source: https://github.com/onebeld/pleasantui/blob/main/docs/CommandBar.md
Demonstrates the fundamental structure of a CommandBar with primary and secondary commands.
```xml
```
--------------------------------
### Complex PleasantDatePicker Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PleasantDatePicker.md
An example showcasing multiple PleasantDatePicker instances within a StackPanel, each configured with different watermarks and date range restrictions. This demonstrates practical application in a UI layout.
```xml
```
--------------------------------
### Initialize Avalonia Application
Source: https://context7.com/onebeld/pleasantui/llms.txt
Standard Avalonia application initialization, including loading XAML and setting up the main window. Ensure AvaloniaXamlLoader.Load(this) is called.
```csharp
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this); // required
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
}
base.OnFrameworkInitializationCompleted();
}
}
```
--------------------------------
### Nested PleasantBorder Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PleasantBorder.md
Illustrates how PleasantBorder components can be nested to create complex UI structures with distinct elevation levels for each layer. This example shows a window, panel, and card hierarchy.
```xml
```
--------------------------------
### Programmatic Navigation for InstallWizard
Source: https://github.com/onebeld/pleasantui/blob/main/docs/InstallWizard.md
Provides methods for controlling the wizard's navigation programmatically, including advancing, going back, or directly jumping to a specific step.
```csharp
wizard.GoNext(); // advance to next step (raises Finished on last step)
wizard.GoBack(); // go to previous step
wizard.CurrentStepIndex = 2; // jump directly to a step
```
--------------------------------
### Basic LogViewerPanel Usage
Source: https://github.com/onebeld/pleasantui/blob/main/docs/LogViewerPanel.md
Demonstrates the basic instantiation of the LogViewerPanel with essential properties like IsOpen and Title.
```xml
```
--------------------------------
### Custom Empty State Example
Source: https://github.com/onebeld/pleasantui/blob/main/docs/SelectionList.md
Illustrates how to customize the empty state message for the SelectionList.
```APIDOC
## Custom Empty State
```xml
```
```
--------------------------------
### PleasantSnackbar With Title
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PleasantSnackbar.md
Example of displaying a snackbar with both a title and a message, creating a two-line notification.
```APIDOC
## PleasantSnackbar With Title
### Description
Shows a snackbar with a prominent title above the main message, useful for more detailed notifications.
### Method
`Show`
### Endpoint
N/A (Component Method)
### Parameters
See `PleasantSnackbarOptions`.
### Request Example
```csharp
PleasantSnackbar.Show(window, new PleasantSnackbarOptions("Your changes have been saved to the cloud.")
{
Title = "Saved",
Icon = MaterialIcons.CloudCheckOutline,
NotificationType = NotificationType.Success
});
```
### Response
None (This is a UI component display method)
```
--------------------------------
### PleasantSnackbar Severity Variants
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PleasantSnackbar.md
Examples of using different notification types for visual feedback.
```APIDOC
## PleasantSnackbar Severity Variants
### Description
Demonstrates how to display snackbars with different severity levels (Information, Success, Warning, Error) and associated icons.
### Examples
#### Information (Default)
```csharp
PleasantSnackbar.Show(window, new PleasantSnackbarOptions("Update available."));
```
#### Success
```csharp
PleasantSnackbar.Show(window, new PleasantSnackbarOptions("Saved.")
{ NotificationType = NotificationType.Success, Icon = MaterialIcons.CheckCircleOutline });
```
#### Warning
```csharp
PleasantSnackbar.Show(window, new PleasantSnackbarOptions("Low disk space.")
{ NotificationType = NotificationType.Warning, Icon = MaterialIcons.AlertOutline });
```
#### Error
```csharp
PleasantSnackbar.Show(window, new PleasantSnackbarOptions("Upload failed.")
{ NotificationType = NotificationType.Error, Icon = MaterialIcons.CloseCircleOutline });
```
```
--------------------------------
### Simple Row with OptionsDisplayItem
Source: https://context7.com/onebeld/pleasantui/llms.txt
Create a basic settings row with a header, description, and icon using OptionsDisplayItem.
```xml
```
--------------------------------
### Tray Icon Integration with PleasantTrayPopup
Source: https://github.com/onebeld/pleasantui/blob/main/docs/PleasantTrayPopup.md
Provides an example of integrating PleasantTrayPopup with a system tray icon.
```APIDOC
## Tray Icon Integration
### Description
This example demonstrates how to integrate PleasantTrayPopup with a system tray icon to show/hide the popup on icon click.
### Method
Event handling and method invocation
### Endpoint
N/A (Client-side component)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```csharp
TrayIcon trayIcon = new TrayIcon();
PleasantTrayPopup? popup = null;
trayIcon.Clicked += (_, _) =>
{
if (popup is { IsVisible: true })
{
popup.Dismiss();
return;
}
// Assuming MyTrayPopup is a derived class or configured PleasantTrayPopup
popup = new MyTrayPopup();
popup.Dismissed += (_, _) => popup = null;
popup.ShowNearTray();
};
```
### Response
#### Success Response (200)
N/A (Client-side component)
#### Response Example
None
```
--------------------------------
### InstallWizard Modal and Window Display
Source: https://context7.com/onebeld/pleasantui/llms.txt
Show the InstallWizard as a modal dialog or a standalone window. The ShowAsModalAsync method returns a boolean indicating if the wizard was finished.
```csharp
// Show as modal dialog
bool finished = await InstallWizard.ShowAsModalAsync(wizard, this);
if (finished)
CompleteInstallation();
// Show as standalone window
bool finished = await InstallWizard.ShowAsWindowAsync(wizard, owner: this, width: 760, height: 500);
```