mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Profile settigns - Added activation condition visual scripting
This commit is contained in:
1 parent
bcd03becc7
commit
d563d17270
8 files changed
+173
-179
No files matched your search
@@ -14,13 +14,6 @@
|
||||
<Border Classes="router-container">
|
||||
<ScrollViewer>
|
||||
<StackPanel Margin="12" Spacing="5">
|
||||
<Border Classes="card">
|
||||
<StackPanel Spacing="5">
|
||||
<TextBlock Classes="h4">Nodes tests</TextBlock>
|
||||
<!-- <dataModelPicker:DataModelPickerButton Placement="BottomEdgeAlignedLeft"/> -->
|
||||
<ContentControl Content="{CompiledBinding VisualEditorViewModel}" HorizontalAlignment="Stretch" Height="800"></ContentControl>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Classes="card">
|
||||
<StackPanel Spacing="5">
|
||||
<TextBlock Classes="h4">Notification tests</TextBlock>
|
||||
|
||||
@@ -1,96 +1,63 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.VisualScripting;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Builders;
|
||||
using Artemis.VisualScripting.Nodes;
|
||||
using Artemis.VisualScripting.Nodes.Operators;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop
|
||||
namespace Artemis.UI.Screens.Workshop;
|
||||
|
||||
public class WorkshopViewModel : MainScreenViewModel
|
||||
{
|
||||
public class WorkshopViewModel : MainScreenViewModel
|
||||
private readonly ObservableAsPropertyHelper<Cursor> _cursor;
|
||||
private readonly INotificationService _notificationService;
|
||||
|
||||
private ColorGradient _colorGradient = new()
|
||||
{
|
||||
private static NodeScript<bool>? _testScript = null;
|
||||
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 readonly INotificationService _notificationService;
|
||||
private StandardCursorType _selectedCursor;
|
||||
private readonly ObservableAsPropertyHelper<Cursor> _cursor;
|
||||
private StandardCursorType _selectedCursor;
|
||||
|
||||
private ColorGradient _colorGradient = new()
|
||||
{
|
||||
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),
|
||||
};
|
||||
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);
|
||||
|
||||
public WorkshopViewModel(IScreen hostScreen, INotificationService notificationService, INodeVmFactory nodeVmFactory) : base(hostScreen, "workshop")
|
||||
{
|
||||
_notificationService = notificationService;
|
||||
_cursor = this.WhenAnyValue(vm => vm.SelectedCursor).Select(c => new Cursor(c)).ToProperty(this, vm => vm.Cursor);
|
||||
DisplayName = "Workshop";
|
||||
ShowNotification = ReactiveCommand.Create<NotificationSeverity>(ExecuteShowNotification);
|
||||
}
|
||||
|
||||
DisplayName = "Workshop";
|
||||
ShowNotification = ReactiveCommand.Create<NotificationSeverity>(ExecuteShowNotification);
|
||||
public ReactiveCommand<NotificationSeverity, Unit> ShowNotification { get; set; }
|
||||
|
||||
if (_testScript == null)
|
||||
{
|
||||
_testScript = new NodeScript<bool>("Test script", "A test script");
|
||||
INode exitNode = _testScript.Nodes.Last();
|
||||
exitNode.X = 300;
|
||||
exitNode.Y = 150;
|
||||
public StandardCursorType SelectedCursor
|
||||
{
|
||||
get => _selectedCursor;
|
||||
set => RaiseAndSetIfChanged(ref _selectedCursor, value);
|
||||
}
|
||||
|
||||
OrNode orNode = new() {X = 100, Y = 100};
|
||||
_testScript.AddNode(orNode);
|
||||
orNode.Result.ConnectTo(exitNode.Pins.First());
|
||||
}
|
||||
public Cursor Cursor => _cursor.Value;
|
||||
|
||||
VisualEditorViewModel = nodeVmFactory.NodeScriptViewModel(_testScript, false);
|
||||
public ColorGradient ColorGradient
|
||||
{
|
||||
get => _colorGradient;
|
||||
set => RaiseAndSetIfChanged(ref _colorGradient, value);
|
||||
}
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
DispatcherTimer updateTimer = new(TimeSpan.FromMilliseconds(20), DispatcherPriority.Normal, (_, _) => _testScript?.Run());
|
||||
updateTimer.Start();
|
||||
Disposable.Create(() => updateTimer.Stop()).DisposeWith(d);
|
||||
});
|
||||
}
|
||||
public void CreateRandomGradient()
|
||||
{
|
||||
ColorGradient = ColorGradient.GetRandom(6);
|
||||
}
|
||||
|
||||
public NodeScriptViewModel VisualEditorViewModel { get; }
|
||||
|
||||
public ReactiveCommand<NotificationSeverity, Unit> ShowNotification { get; set; }
|
||||
|
||||
public StandardCursorType SelectedCursor
|
||||
{
|
||||
get => _selectedCursor;
|
||||
set => RaiseAndSetIfChanged(ref _selectedCursor, value);
|
||||
}
|
||||
|
||||
public Cursor Cursor => _cursor.Value;
|
||||
|
||||
public ColorGradient ColorGradient
|
||||
{
|
||||
get => _colorGradient;
|
||||
set => RaiseAndSetIfChanged(ref _colorGradient, value);
|
||||
}
|
||||
|
||||
public void CreateRandomGradient()
|
||||
{
|
||||
ColorGradient = ColorGradient.GetRandom(6);
|
||||
}
|
||||
|
||||
private void ExecuteShowNotification(NotificationSeverity severity)
|
||||
{
|
||||
_notificationService.CreateNotification().WithTitle("Test title").WithMessage("Test message").WithSeverity(severity).Show();
|
||||
}
|
||||
private void ExecuteShowNotification(NotificationSeverity severity)
|
||||
{
|
||||
_notificationService.CreateNotification().WithTitle("Test title").WithMessage("Test message").WithSeverity(severity).Show();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user