JT
9 months ago
11 changed files with 721 additions and 17 deletions
@ -0,0 +1,403 @@ |
|||||||
|
<Styles xmlns="https://github.com/avaloniaui" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"> |
||||||
|
<Design.PreviewWith> |
||||||
|
<Border Padding="20"> |
||||||
|
<ui:CommandBar |
||||||
|
Margin="8" |
||||||
|
VerticalAlignment="Center" |
||||||
|
VerticalContentAlignment="Center" |
||||||
|
HorizontalAlignment="Left" |
||||||
|
HorizontalContentAlignment="Left" |
||||||
|
DefaultLabelPosition="Right"> |
||||||
|
<ui:CommandBar.PrimaryCommands> |
||||||
|
<ui:CommandBarButton Classes="success" Label="Success Button" Margin="8" |
||||||
|
HorizontalAlignment="Center" /> |
||||||
|
<ui:CommandBarButton Classes="accent" Label="FA Accent Button" Margin="8" |
||||||
|
HorizontalAlignment="Center" /> |
||||||
|
<ui:CommandBarButton Classes="systemaccent" Label="System Accent Button" Margin="8" |
||||||
|
HorizontalAlignment="Center" /> |
||||||
|
<ui:CommandBarButton Classes="danger" Label="Danger Button" Margin="8" HorizontalAlignment="Center" /> |
||||||
|
<ui:CommandBarButton Classes="info" Label="Info Button" Margin="8" HorizontalAlignment="Center" /> |
||||||
|
<ui:CommandBarButton Classes="transparent-info" Label="Semi-Transparent Info Button" Margin="8" |
||||||
|
HorizontalAlignment="Center" /> |
||||||
|
<ui:CommandBarButton Classes="transparent" Label="Transparent Button" Margin="8" |
||||||
|
HorizontalAlignment="Center" /> |
||||||
|
<ui:CommandBarButton Classes="transparent-full" Label="Transparent Button" Margin="8" |
||||||
|
HorizontalAlignment="Center" /> |
||||||
|
<ui:CommandBarButton Label="Disabled Button" Margin="8" IsEnabled="False" |
||||||
|
HorizontalAlignment="Center" /> |
||||||
|
</ui:CommandBar.PrimaryCommands> |
||||||
|
</ui:CommandBar> |
||||||
|
</Border> |
||||||
|
</Design.PreviewWith> |
||||||
|
|
||||||
|
<!-- Success --> |
||||||
|
<Style Selector="ui|CommandBarButton.success"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeGreenColor}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeGreenColor}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^ /template/ TextBlock#TextLabel"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" /> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pointerover"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeDarkGreenColor}"/> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeDarkGreenColor}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="Green" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pressed"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeDarkDarkGreenColor}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeDarkDarkGreenColor}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPressed}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:disabled"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundDisabled}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushDisabled}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<!-- Danger --> |
||||||
|
<Style Selector="ui|CommandBarButton.danger"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeRedColor}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeRedColor}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" /> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pointerover"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeDarkRedColor}"/> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeDarkRedColor}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pressed"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeDarkDarkRedColor}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeDarkDarkRedColor}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPressed}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:disabled"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundDisabled}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushDisabled}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<!-- Info --> |
||||||
|
<Style Selector="ui|CommandBarButton.info"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeLightBlueColor}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeLightBlueColor}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" /> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pointerover"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeBlueColor}"/> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBlueColor}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pressed"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeDarkBlueColor}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeDarkBlueColor}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPressed}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:disabled"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundDisabled}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushDisabled}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<!--Accent Button--> |
||||||
|
<Style Selector="ui|CommandBarButton.accent"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource AccentButtonBackground}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource AccentButtonBorderBrush}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource AccentButtonForeground}" /> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pointerover"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource AccentButtonBackgroundPointerOver}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource AccentButtonBorderBrushPointerOver}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource AccentButtonForegroundPointerOver}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pressed"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource AccentButtonBackgroundPressed}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource AccentButtonBorderBrushPressed}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource AccentButtonForegroundPressed}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:disabled"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource AccentButtonBackgroundDisabled}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource AccentButtonBorderBrushDisabled}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource AccentButtonForegroundDisabled}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<!-- SystemAccent --> |
||||||
|
<Style Selector="ui|CommandBarButton.systemaccent"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource SystemAccentColor}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColor}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" /> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pointerover"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource SystemAccentColorDark1}"/> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColorDark1}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pressed"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource SystemAccentColorDark2}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColorDark2}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPressed}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:disabled"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundDisabled}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushDisabled}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<!-- Transparent --> |
||||||
|
<Style Selector="ui|CommandBarButton.transparent"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource SystemControlTransparentBrush}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" /> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pointerover"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundDisabled}"/> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBackgroundDisabled}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pressed"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundPressed}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBackgroundPressed}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPressed}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:disabled"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundDisabled}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushDisabled}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<!-- Semi-Transparent Info --> |
||||||
|
<Style Selector="ui|CommandBarButton.transparent-info"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeLightBlueColorTransparent}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeLightBlueColorTransparent}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" /> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pointerover"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeBlueColorTransparent}"/> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBlueColorTransparent}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pressed"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeDarkBlueColorTransparent}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeDarkBlueColorTransparent}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPressed}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:disabled"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundDisabled}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushDisabled}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<!-- Transparent red --> |
||||||
|
<Style Selector="ui|CommandBarButton.transparent-red"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource SystemControlTransparentBrush}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" /> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pointerover"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeCoralRedColor}"/> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeCoralRedColor}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pressed"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ThemeDarkCoralRedColor}"/> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ThemeDarkCoralRedColor}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPressed}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:disabled"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundDisabled}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushDisabled}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<!-- Full Transparent --> |
||||||
|
<Style Selector="ui|CommandBarButton.transparent-full"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource SystemControlTransparentBrush}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlTransparentBrush}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" /> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pointerover"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundDisabled}"/> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBackgroundDisabled}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:pressed"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundPressed}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBackgroundPressed}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPressed}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style Selector="^:disabled"> |
||||||
|
<Style Selector="^ /template/ Border#AppBarButtonInnerBorder"> |
||||||
|
<Setter Property="Background" Value="{DynamicResource SystemControlTransparentBrush}" /> |
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlTransparentBrush}" /> |
||||||
|
</Style> |
||||||
|
<Style Selector="^"> |
||||||
|
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
</Style> |
||||||
|
</Styles> |
@ -1,18 +1,126 @@ |
|||||||
using FluentAvalonia.UI.Controls; |
using System; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using Avalonia.Threading; |
||||||
|
using AvaloniaEdit; |
||||||
|
using CommunityToolkit.Mvvm.ComponentModel; |
||||||
|
using CommunityToolkit.Mvvm.Input; |
||||||
|
using FluentAvalonia.UI.Controls; |
||||||
|
using StabilityMatrix.Avalonia.Services; |
||||||
using StabilityMatrix.Avalonia.ViewModels.Base; |
using StabilityMatrix.Avalonia.ViewModels.Base; |
||||||
using StabilityMatrix.Avalonia.Views; |
using StabilityMatrix.Avalonia.Views; |
||||||
using StabilityMatrix.Core.Attributes; |
using StabilityMatrix.Core.Attributes; |
||||||
|
using StabilityMatrix.Core.Helper; |
||||||
using StabilityMatrix.Core.Models; |
using StabilityMatrix.Core.Models; |
||||||
|
using StabilityMatrix.Core.Models.Packages; |
||||||
|
using StabilityMatrix.Core.Processes; |
||||||
|
using StabilityMatrix.Core.Services; |
||||||
using SymbolIconSource = FluentIcons.Avalonia.Fluent.SymbolIconSource; |
using SymbolIconSource = FluentIcons.Avalonia.Fluent.SymbolIconSource; |
||||||
|
|
||||||
namespace StabilityMatrix.Avalonia.ViewModels; |
namespace StabilityMatrix.Avalonia.ViewModels; |
||||||
|
|
||||||
[View(typeof(ConsoleOutputPage))] |
[View(typeof(ConsoleOutputPage))] |
||||||
public class RunningPackageViewModel(PackagePair runningPackage, ConsoleViewModel console) : PageViewModelBase |
public partial class RunningPackageViewModel : PageViewModelBase |
||||||
{ |
{ |
||||||
public PackagePair RunningPackage { get; } = runningPackage; |
private readonly INotificationService notificationService; |
||||||
public ConsoleViewModel Console { get; } = console; |
private string webUiUrl = string.Empty; |
||||||
|
|
||||||
|
public PackagePair RunningPackage { get; } |
||||||
|
public ConsoleViewModel Console { get; } |
||||||
public override string Title => RunningPackage.InstalledPackage.PackageName ?? "Running Package"; |
public override string Title => RunningPackage.InstalledPackage.PackageName ?? "Running Package"; |
||||||
public override IconSource IconSource => new SymbolIconSource(); |
public override IconSource IconSource => new SymbolIconSource(); |
||||||
|
|
||||||
|
[ObservableProperty] |
||||||
|
private bool autoScrollToEnd; |
||||||
|
|
||||||
|
[ObservableProperty] |
||||||
|
private bool showWebUiButton; |
||||||
|
|
||||||
|
[ObservableProperty] |
||||||
|
private bool isRunning = true; |
||||||
|
|
||||||
|
/// <inheritdoc/> |
||||||
|
public RunningPackageViewModel( |
||||||
|
ISettingsManager settingsManager, |
||||||
|
INotificationService notificationService, |
||||||
|
PackagePair runningPackage, |
||||||
|
ConsoleViewModel console |
||||||
|
) |
||||||
|
{ |
||||||
|
this.notificationService = notificationService; |
||||||
|
RunningPackage = runningPackage; |
||||||
|
Console = console; |
||||||
|
Console.Document.LineCountChanged += DocumentOnLineCountChanged; |
||||||
|
RunningPackage.BasePackage.StartupComplete += BasePackageOnStartupComplete; |
||||||
|
runningPackage.BasePackage.Exited += BasePackageOnExited; |
||||||
|
|
||||||
|
settingsManager.RelayPropertyFor( |
||||||
|
this, |
||||||
|
vm => vm.AutoScrollToEnd, |
||||||
|
settings => settings.AutoScrollLaunchConsoleToEnd, |
||||||
|
true |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
private void BasePackageOnExited(object? sender, int e) |
||||||
|
{ |
||||||
|
IsRunning = false; |
||||||
|
ShowWebUiButton = false; |
||||||
|
} |
||||||
|
|
||||||
|
private void BasePackageOnStartupComplete(object? sender, string url) |
||||||
|
{ |
||||||
|
webUiUrl = url.Replace("0.0.0.0", "127.0.0.1"); |
||||||
|
ShowWebUiButton = !string.IsNullOrWhiteSpace(webUiUrl); |
||||||
|
} |
||||||
|
|
||||||
|
private void DocumentOnLineCountChanged(object? sender, EventArgs e) |
||||||
|
{ |
||||||
|
if (AutoScrollToEnd) |
||||||
|
{ |
||||||
|
EventManager.Instance.OnScrollToBottomRequested(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
[RelayCommand] |
||||||
|
private void LaunchPackage() |
||||||
|
{ |
||||||
|
EventManager.Instance.OnPackageRelaunchRequested(RunningPackage.InstalledPackage); |
||||||
|
} |
||||||
|
|
||||||
|
[RelayCommand] |
||||||
|
private async Task Stop() |
||||||
|
{ |
||||||
|
await RunningPackage.BasePackage.WaitForShutdown(); |
||||||
|
Console.PostLine($"{Environment.NewLine}Stopped process at {DateTimeOffset.Now}"); |
||||||
|
await Console.StopUpdatesAsync(); |
||||||
|
IsRunning = false; |
||||||
|
} |
||||||
|
|
||||||
|
[RelayCommand] |
||||||
|
private void LaunchWebUi() |
||||||
|
{ |
||||||
|
if (string.IsNullOrEmpty(webUiUrl)) |
||||||
|
return; |
||||||
|
|
||||||
|
notificationService.TryAsync( |
||||||
|
Task.Run(() => ProcessRunner.OpenUrl(webUiUrl)), |
||||||
|
"Failed to open URL", |
||||||
|
$"{webUiUrl}" |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
[RelayCommand] |
||||||
|
private async Task SendToConsole(string input) |
||||||
|
{ |
||||||
|
Console.PostLine(input); |
||||||
|
if (RunningPackage?.BasePackage is BaseGitPackage gitPackage) |
||||||
|
{ |
||||||
|
var venv = gitPackage.VenvRunner; |
||||||
|
var process = venv?.Process; |
||||||
|
if (process is not null) |
||||||
|
{ |
||||||
|
await process.StandardInput.WriteLineAsync(input); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
} |
} |
||||||
|
@ -1,13 +1,54 @@ |
|||||||
using StabilityMatrix.Avalonia.Controls; |
using System; |
||||||
|
using Avalonia.Controls; |
||||||
|
using Avalonia.Controls.Primitives; |
||||||
|
using Avalonia.Interactivity; |
||||||
|
using Avalonia.Threading; |
||||||
|
using AvaloniaEdit; |
||||||
|
using StabilityMatrix.Avalonia.Controls; |
||||||
|
using StabilityMatrix.Avalonia.Helpers; |
||||||
|
using StabilityMatrix.Avalonia.Models; |
||||||
using StabilityMatrix.Core.Attributes; |
using StabilityMatrix.Core.Attributes; |
||||||
|
using StabilityMatrix.Core.Helper; |
||||||
|
|
||||||
namespace StabilityMatrix.Avalonia.Views; |
namespace StabilityMatrix.Avalonia.Views; |
||||||
|
|
||||||
[Transient] |
[Transient] |
||||||
public partial class ConsoleOutputPage : UserControlBase |
public partial class ConsoleOutputPage : UserControlBase |
||||||
{ |
{ |
||||||
|
private const int LineOffset = 5; |
||||||
|
|
||||||
public ConsoleOutputPage() |
public ConsoleOutputPage() |
||||||
{ |
{ |
||||||
InitializeComponent(); |
InitializeComponent(); |
||||||
} |
} |
||||||
|
|
||||||
|
protected override void OnApplyTemplate(TemplateAppliedEventArgs e) |
||||||
|
{ |
||||||
|
base.OnApplyTemplate(e); |
||||||
|
TextEditorConfigs.Configure(Console, TextEditorPreset.Console); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void OnUnloaded(RoutedEventArgs e) |
||||||
|
{ |
||||||
|
base.OnUnloaded(e); |
||||||
|
EventManager.Instance.ScrollToBottomRequested -= OnScrollToBottomRequested; |
||||||
|
} |
||||||
|
|
||||||
|
protected override void OnLoaded(RoutedEventArgs e) |
||||||
|
{ |
||||||
|
base.OnLoaded(e); |
||||||
|
EventManager.Instance.ScrollToBottomRequested += OnScrollToBottomRequested; |
||||||
|
} |
||||||
|
|
||||||
|
private void OnScrollToBottomRequested(object? sender, EventArgs e) |
||||||
|
{ |
||||||
|
Dispatcher.UIThread.Invoke(() => |
||||||
|
{ |
||||||
|
var editor = this.FindControl<TextEditor>("Console"); |
||||||
|
if (editor?.Document == null) |
||||||
|
return; |
||||||
|
var line = Math.Max(editor.Document.LineCount - LineOffset, 1); |
||||||
|
editor.ScrollToLine(line); |
||||||
|
}); |
||||||
|
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue