Initial workshop commit

This commit is contained in:
Robert committed 2023-06-11 18:52:17 +02:00
1 parent 70b6035b0d
commit bde4e861c2
18 files changed
+441 -133

No files matched your search

@@ -10,62 +10,26 @@
xmlns:controls="clr-namespace:Artemis.UI.Shared.Controls;assembly=Artemis.UI.Shared"
xmlns:gradientPicker="clr-namespace:Artemis.UI.Shared.Controls.GradientPicker;assembly=Artemis.UI.Shared"
xmlns:materialIconPicker="clr-namespace:Artemis.UI.Shared.MaterialIconPicker;assembly=Artemis.UI.Shared"
xmlns:workshop1="clr-namespace:Artemis.WebClient.Workshop;assembly=Artemis.WebClient.Workshop"
mc:Ignorable="d" d:DesignWidth="800"
x:Class="Artemis.UI.Screens.Workshop.WorkshopView"
x:DataType="workshop:WorkshopViewModel">
<Border Classes="router-container">
<ScrollViewer>
<StackPanel Margin="12" Spacing="5">
<Border Classes="card">
<StackPanel Spacing="5">
<TextBlock Classes="h4">Notification tests</TextBlock>
<Button Command="{CompiledBinding ShowNotification}" CommandParameter="{x:Static builders:NotificationSeverity.Informational}">
Notification test (default)
</Button>
<Button Command="{CompiledBinding ShowNotification}" CommandParameter="{x:Static builders:NotificationSeverity.Warning}">
Notification test (warning)
</Button>
<Button Command="{CompiledBinding ShowNotification}" CommandParameter="{x:Static builders:NotificationSeverity.Error}">
Notification test (error)
</Button>
<Button Command="{CompiledBinding ShowNotification}" CommandParameter="{x:Static builders:NotificationSeverity.Success}">
Notification test (success)
</Button>
<shared:HotkeyBox Watermark="Some hotkey" Width="250" HorizontalAlignment="Left" />
<controls1:NumberBox
attachedProperties:NumberBoxAssist.PrefixText="$"
attachedProperties:NumberBoxAssist.SuffixText="%">
</controls1:NumberBox>
<TextBox
attachedProperties:TextBoxAssist.PrefixText="$"
attachedProperties:TextBoxAssist.SuffixText="%">
</TextBox>
<TextBlock Classes="h4" Text="{CompiledBinding TestValue}"/>
<controls1:NumberBox Value="{CompiledBinding TestValue}"/>
<controls:DraggableNumberBox Value="{CompiledBinding TestValue}"/>
<controls:DraggableNumberBox Value="{CompiledBinding TestValue}" Classes="condensed"/>
<StackPanel Orientation="Horizontal" Spacing="5">
<Border Classes="card" Cursor="{CompiledBinding Cursor}">
<TextBlock Text="{CompiledBinding SelectedCursor}"></TextBlock>
</Border>
<shared:EnumComboBox Value="{CompiledBinding SelectedCursor}"></shared:EnumComboBox>
</StackPanel>
<Button Command="{CompiledBinding CreateRandomGradient}">
Create random gradient
</Button>
<gradientPicker:GradientPickerButton ColorGradient="{CompiledBinding ColorGradient}" IsCompact="True" />
<materialIconPicker:MaterialIconPickerButton Name="IconPicker" Value="Abc"/>
<TextBlock Text="{CompiledBinding #IconPicker.Value}"></TextBlock>
</StackPanel>
</Border>
</StackPanel>
</ScrollViewer>
<Grid ColumnDefinitions="300,*" Margin="0 10">
<Border Classes="card-condensed" Grid.Column="0" Margin="0 0 10 0">
<ListBox ItemsSource="{CompiledBinding Test}">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="workshop1:IGetEntries_Entries_Nodes">
<Panel>
<StackPanel Margin="4">
<TextBlock Text="{CompiledBinding Name}" VerticalAlignment="Center" />
<TextBlock Text="{CompiledBinding Author}" VerticalAlignment="Center" Classes="subtitle" FontSize="13" />
</StackPanel>
</Panel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
</Grid>
</Border>
</UserControl>
@@ -1,70 +1,52 @@
using System.Reactive;
using System;
using System.Collections.ObjectModel;
using System.Reactive;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Artemis.Core;
using Artemis.UI.Shared.Services;
using Artemis.UI.Shared.Services.Builders;
using Artemis.WebClient.Workshop;
using Avalonia.Input;
using ReactiveUI;
using SkiaSharp;
using StrawberryShake;
namespace Artemis.UI.Screens.Workshop;
public class WorkshopViewModel : MainScreenViewModel
{
private readonly ObservableAsPropertyHelper<Cursor> _cursor;
private readonly INotificationService _notificationService;
private readonly IWorkshopClient _workshopClient;
private ColorGradient _colorGradient = new()
public WorkshopViewModel(IScreen hostScreen, IWorkshopClient workshopClient) : base(hostScreen, "workshop")
{
new ColorGradientStop(new SKColor(0xFFFF6D00), 0f),
new ColorGradientStop(new SKColor(0xFFFE6806), 0.2f),
new ColorGradientStop(new SKColor(0xFFEF1788), 0.4f),
new ColorGradientStop(new SKColor(0xFFEF1788), 0.6f),
new ColorGradientStop(new SKColor(0xFF00FCCC), 0.8f),
new ColorGradientStop(new SKColor(0xFF00FCCC), 1f)
};
private StandardCursorType _selectedCursor;
private double _testValue;
public WorkshopViewModel(IScreen hostScreen, INotificationService notificationService) : base(hostScreen, "workshop")
{
_notificationService = notificationService;
_cursor = this.WhenAnyValue(vm => vm.SelectedCursor).Select(c => new Cursor(c)).ToProperty(this, vm => vm.Cursor);
_workshopClient = workshopClient;
DisplayName = "Workshop";
ShowNotification = ReactiveCommand.Create<NotificationSeverity>(ExecuteShowNotification);
Task.Run(() => GetEntries());
}
public ReactiveCommand<NotificationSeverity, Unit> ShowNotification { get; set; }
public ObservableCollection<IGetEntries_Entries_Nodes> Test { get; set; } = new();
public StandardCursorType SelectedCursor
private async Task GetEntries()
{
get => _selectedCursor;
set => RaiseAndSetIfChanged(ref _selectedCursor, value);
}
public Cursor Cursor => _cursor.Value;
public ColorGradient ColorGradient
{
get => _colorGradient;
set => RaiseAndSetIfChanged(ref _colorGradient, value);
}
public double TestValue
{
get => _testValue;
set => RaiseAndSetIfChanged(ref _testValue, value);
}
public void CreateRandomGradient()
{
ColorGradient = ColorGradient.GetRandom(6);
}
private void ExecuteShowNotification(NotificationSeverity severity)
{
_notificationService.CreateNotification().WithTitle("Test title").WithMessage("Test message").WithSeverity(severity).Show();
try
{
IOperationResult<IGetEntriesResult> entries = await _workshopClient.GetEntries.ExecuteAsync();
if (entries.Data?.Entries?.Nodes == null)
return;
foreach (IGetEntries_Entries_Nodes getEntriesEntriesNodes in entries.Data.Entries.Nodes)
{
Console.WriteLine(getEntriesEntriesNodes);
Test.Add(getEntriesEntriesNodes);
}
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
}