mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Meta - Replace WPF projects with Avalonia projects
This commit is contained in:
1 parent
fcf0376a9a
commit
d7f3ee1190
1110 files changed
+10872
-52240
No files matched your search
@@ -0,0 +1,52 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:core="clr-namespace:Artemis.Core;assembly=Artemis.Core"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="23"
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.StatusBar.StatusBarView">
|
||||
<UserControl.Styles>
|
||||
<Style Selector="Border.status-message-border">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}"></Setter>
|
||||
<Setter Property="BorderThickness" Value="1 0 0 0"></Setter>
|
||||
<Setter Property="Margin" Value="5 2 0 2"></Setter>
|
||||
<Setter Property="Transitions">
|
||||
<Setter.Value>
|
||||
<Transitions>
|
||||
<DoubleTransition Property="Opacity" Duration="0.2"></DoubleTransition>
|
||||
</Transitions>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style Selector="Border.status-message-border.hidden">
|
||||
<Setter Property="Opacity" Value="0" />
|
||||
</Style>
|
||||
</UserControl.Styles>
|
||||
<Grid ColumnDefinitions="Auto, Auto,*,*" Height="23" Margin="5 0">
|
||||
<ContentControl Grid.Column="0" Content="{Binding ProfileElement}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="core:Folder">
|
||||
<avalonia:MaterialIcon Kind="Folder" Margin="0 0 5 0" />
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="core:Layer">
|
||||
<avalonia:MaterialIcon Kind="{Binding LayerBrush.Descriptor.Icon}" Margin="0 0 5 0" />
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
|
||||
<TextBlock Grid.Column="1" Text="{Binding ProfileElement.Name, FallbackValue=Select a layer to get started}" VerticalAlignment="Center" />
|
||||
|
||||
<Border Grid.Column="2" Classes="status-message-border" Classes.hidden="{Binding !ShowStatusMessage}">
|
||||
<TextBlock Margin="5 0 0 0" Text="{Binding StatusMessage}" />
|
||||
</Border>
|
||||
|
||||
<Slider Grid.Column="3"
|
||||
Margin="0 -11 0 0"
|
||||
Minimum="31"
|
||||
Maximum="350"
|
||||
Width="319"
|
||||
Value="{Binding PixelsPerSecond}"
|
||||
HorizontalAlignment="Right"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,18 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.StatusBar
|
||||
{
|
||||
public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
|
||||
{
|
||||
public StatusBarView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using Avalonia.Controls.Mixins;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.StatusBar;
|
||||
|
||||
public class StatusBarViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private ObservableAsPropertyHelper<ProfileEditorHistory?>? _history;
|
||||
private ObservableAsPropertyHelper<int>? _pixelsPerSecond;
|
||||
private ObservableAsPropertyHelper<RenderProfileElement?>? _profileElement;
|
||||
private bool _showStatusMessage;
|
||||
private string? _statusMessage;
|
||||
|
||||
public StatusBarViewModel(IProfileEditorService profileEditorService)
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
_profileElement = profileEditorService.ProfileElement.ToProperty(this, vm => vm.ProfileElement).DisposeWith(d);
|
||||
_history = profileEditorService.History.ToProperty(this, vm => vm.History).DisposeWith(d);
|
||||
_pixelsPerSecond = profileEditorService.PixelsPerSecond.ToProperty(this, vm => vm.PixelsPerSecond);
|
||||
});
|
||||
|
||||
this.WhenAnyValue(vm => vm.History)
|
||||
.Select(h => h?.Undo ?? Observable.Never<IProfileEditorCommand?>())
|
||||
.Switch()
|
||||
.Subscribe(c =>
|
||||
{
|
||||
StatusMessage = c != null ? $"Undid '{c.DisplayName}'." : "Nothing to undo.";
|
||||
ShowStatusMessage = true;
|
||||
});
|
||||
this.WhenAnyValue(vm => vm.History)
|
||||
.Select(h => h?.Redo ?? Observable.Never<IProfileEditorCommand?>())
|
||||
.Switch()
|
||||
.Subscribe(c =>
|
||||
{
|
||||
StatusMessage = c != null ? $"Redid '{c.DisplayName}'." : "Nothing to redo.";
|
||||
ShowStatusMessage = true;
|
||||
});
|
||||
|
||||
this.WhenAnyValue(vm => vm.ShowStatusMessage).Where(v => v).Throttle(TimeSpan.FromSeconds(3)).Subscribe(_ => ShowStatusMessage = false);
|
||||
}
|
||||
|
||||
public RenderProfileElement? ProfileElement => _profileElement?.Value;
|
||||
public ProfileEditorHistory? History => _history?.Value;
|
||||
|
||||
public int PixelsPerSecond
|
||||
{
|
||||
get => _pixelsPerSecond?.Value ?? 0;
|
||||
set => _profileEditorService.ChangePixelsPerSecond(value);
|
||||
}
|
||||
|
||||
public string? StatusMessage
|
||||
{
|
||||
get => _statusMessage;
|
||||
set => RaiseAndSetIfChanged(ref _statusMessage, value);
|
||||
}
|
||||
|
||||
public bool ShowStatusMessage
|
||||
{
|
||||
get => _showStatusMessage;
|
||||
set => RaiseAndSetIfChanged(ref _showStatusMessage, value);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user