mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-02-04 02:43:32 +00:00
Initial setup of the models and view models
This commit is contained in:
parent
46511022d6
commit
3004293051
@ -0,0 +1,25 @@
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a configuration item that accepts boolean input from the user.
|
||||
/// </summary>
|
||||
public class ConfigurationBooleanItem : ConfigurationInputItem<bool>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the display text shown when the boolean value is true.
|
||||
/// </summary>
|
||||
public required string TrueText
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the display text shown when the boolean value is false.
|
||||
/// </summary>
|
||||
public required string FalseText
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a single option in a configuration dropdown list.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the value that this dropdown option represents.</typeparam>
|
||||
public class ConfigurationDropdownValue<T> : CorePropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the display name shown to the user for this dropdown option.
|
||||
/// </summary>
|
||||
public required string DisplayName
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the actual value associated with this dropdown option.
|
||||
/// </summary>
|
||||
public required T Value
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a generic base class for configuration items that accept user input.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the value that this configuration item holds.</typeparam>
|
||||
public class ConfigurationInputItem<T> : CorePropertyChanged, IConfigurationItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the display name of the configuration item.
|
||||
/// </summary>
|
||||
public required string Name
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the description text that explains the purpose of this configuration item.
|
||||
/// </summary>
|
||||
public string? Description
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current value of the configuration item.
|
||||
/// </summary>
|
||||
public T? Value
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the collection of dropdown values for this configuration item.
|
||||
/// When populated, the configuration item will be rendered as a dropdown/combo box.
|
||||
/// </summary>
|
||||
public ObservableCollection<ConfigurationDropdownValue<T>>? DropdownValues
|
||||
{
|
||||
get;
|
||||
set
|
||||
{
|
||||
if (Equals(value, field))
|
||||
return;
|
||||
field = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
} = [];
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a configuration item that accepts numeric input from the user.
|
||||
/// </summary>
|
||||
public class ConfigurationNumericItem : ConfigurationInputItem<Numeric>
|
||||
{
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a configuration item that accepts SKColor input from the user.
|
||||
/// </summary>
|
||||
public class ConfigurationSKColorItem : ConfigurationInputItem<SKColor>
|
||||
{
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a configuration section that contains a collection of configuration items.
|
||||
/// </summary>
|
||||
public class ConfigurationSection : CorePropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the configuration section.
|
||||
/// </summary>
|
||||
public required string Name
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the slot number of the configuration section.
|
||||
/// </summary>
|
||||
public int Slot
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of configuration items in this section.
|
||||
/// </summary>
|
||||
public ObservableCollection<IConfigurationItem> Items { get; } = [];
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a configuration item that accepts string input from the user.
|
||||
/// </summary>
|
||||
public class ConfigurationStringItem : ConfigurationInputItem<string>
|
||||
{
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a configuration item that displays static text.
|
||||
/// </summary>
|
||||
public class ConfigurationTextItem : CorePropertyChanged, IConfigurationItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the text content to display.
|
||||
/// </summary>
|
||||
public required string Text
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Defines a contract for configuration items that can be added to a configuration section.
|
||||
/// </summary>
|
||||
public interface IConfigurationItem
|
||||
{
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Modules;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
@ -16,26 +17,12 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public static readonly ProfileConfiguration Empty = new(ProfileCategory.Empty, "Empty", "Empty");
|
||||
|
||||
private ActivationBehaviour _activationBehaviour;
|
||||
private bool _activationConditionMet;
|
||||
private ProfileCategory _category;
|
||||
private Hotkey? _disableHotkey;
|
||||
private bool _disposed;
|
||||
private Hotkey? _enableHotkey;
|
||||
private ProfileConfigurationHotkeyMode _hotkeyMode;
|
||||
private bool _isMissingModule;
|
||||
private bool _isSuspended;
|
||||
private bool _fadeInAndOut;
|
||||
private Module? _module;
|
||||
|
||||
private string _name;
|
||||
private int _order;
|
||||
private Profile? _profile;
|
||||
|
||||
internal ProfileConfiguration(ProfileCategory category, string name, string icon)
|
||||
{
|
||||
_name = name;
|
||||
_category = category;
|
||||
Name = name;
|
||||
Category = category;
|
||||
|
||||
Entity = new ProfileContainerEntity();
|
||||
Icon = new ProfileConfigurationIcon(Entity);
|
||||
@ -49,8 +36,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
internal ProfileConfiguration(ProfileCategory category, ProfileContainerEntity entity)
|
||||
{
|
||||
// Will be loaded from the entity
|
||||
_name = null!;
|
||||
_category = category;
|
||||
Name = null!;
|
||||
Category = category;
|
||||
|
||||
Entity = entity;
|
||||
Icon = new ProfileConfigurationIcon(Entity);
|
||||
@ -64,8 +51,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => SetAndNotify(ref _name, value);
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -73,8 +60,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public int Order
|
||||
{
|
||||
get => _order;
|
||||
set => SetAndNotify(ref _order, value);
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -83,8 +70,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public bool IsSuspended
|
||||
{
|
||||
get => _isSuspended;
|
||||
set => SetAndNotify(ref _isSuspended, value);
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -92,8 +79,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public bool IsMissingModule
|
||||
{
|
||||
get => _isMissingModule;
|
||||
private set => SetAndNotify(ref _isMissingModule, value);
|
||||
get;
|
||||
private set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -101,8 +88,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public ProfileCategory Category
|
||||
{
|
||||
get => _category;
|
||||
internal set => SetAndNotify(ref _category, value);
|
||||
get;
|
||||
internal set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -110,8 +97,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public ProfileConfigurationHotkeyMode HotkeyMode
|
||||
{
|
||||
get => _hotkeyMode;
|
||||
set => SetAndNotify(ref _hotkeyMode, value);
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -119,8 +106,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public Hotkey? EnableHotkey
|
||||
{
|
||||
get => _enableHotkey;
|
||||
set => SetAndNotify(ref _enableHotkey, value);
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -128,8 +115,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public Hotkey? DisableHotkey
|
||||
{
|
||||
get => _disableHotkey;
|
||||
set => SetAndNotify(ref _disableHotkey, value);
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -137,8 +124,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public ActivationBehaviour ActivationBehaviour
|
||||
{
|
||||
get => _activationBehaviour;
|
||||
set => SetAndNotify(ref _activationBehaviour, value);
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -146,8 +133,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public bool ActivationConditionMet
|
||||
{
|
||||
get => _activationConditionMet;
|
||||
private set => SetAndNotify(ref _activationConditionMet, value);
|
||||
get;
|
||||
private set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -155,8 +142,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public Profile? Profile
|
||||
{
|
||||
get => _profile;
|
||||
internal set => SetAndNotify(ref _profile, value);
|
||||
get;
|
||||
internal set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -164,8 +151,17 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public bool FadeInAndOut
|
||||
{
|
||||
get => _fadeInAndOut;
|
||||
set => SetAndNotify(ref _fadeInAndOut, value);
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether this profile is configurable via its <see cref="ConfigurationSections"/>.
|
||||
/// </summary>
|
||||
public bool IsConfigurable
|
||||
{
|
||||
get;
|
||||
set => SetAndNotify(ref field, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -173,14 +169,19 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
/// </summary>
|
||||
public Module? Module
|
||||
{
|
||||
get => _module;
|
||||
get;
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _module, value);
|
||||
SetAndNotify(ref field, value);
|
||||
IsMissingModule = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the configuration sections of this profile configuration.
|
||||
/// </summary>
|
||||
public ObservableCollection<ConfigurationSection> ConfigurationSections { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the icon configuration
|
||||
/// </summary>
|
||||
@ -301,6 +302,30 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
|
||||
|
||||
EnableHotkey = Entity.ProfileConfiguration.EnableHotkey != null ? new Hotkey(Entity.ProfileConfiguration.EnableHotkey) : null;
|
||||
DisableHotkey = Entity.ProfileConfiguration.DisableHotkey != null ? new Hotkey(Entity.ProfileConfiguration.DisableHotkey) : null;
|
||||
|
||||
// Placeholder configuration sections
|
||||
ConfigurationSections.Clear();
|
||||
ConfigurationSections.Add(new ConfigurationSection()
|
||||
{
|
||||
Name = "General (slot 0)",
|
||||
Slot = 0,
|
||||
});
|
||||
ConfigurationSections.Add(new ConfigurationSection()
|
||||
{
|
||||
Name = "Other (slot 1)",
|
||||
Slot = 1
|
||||
});
|
||||
ConfigurationSections.Add(new ConfigurationSection()
|
||||
{
|
||||
Name = "Something else (slot 2)",
|
||||
Slot = 2
|
||||
});
|
||||
ConfigurationSections[0].Items.Add(new ConfigurationTextItem() {Text = "This is a placeholder text item in the General section."});
|
||||
ConfigurationSections[0].Items.Add(new ConfigurationNumericItem() {Name = "Numeric item"});
|
||||
ConfigurationSections[0].Items.Add(new ConfigurationBooleanItem() {Name = "Do the thing?", TrueText = "Absolutely", FalseText = "Nope"});
|
||||
ConfigurationSections[1].Items.Add(new ConfigurationTextItem() {Text = "This is a placeholder text item in the Other section."});
|
||||
ConfigurationSections[2].Items.Add(new ConfigurationTextItem() {Text = "This is a placeholder text item in the Something else section."});
|
||||
ConfigurationSections[2].Items.Add(new ConfigurationTextItem() {Text = "This is another placeholder text item in the Something else section."});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -25,6 +25,9 @@ internal class InputService : IInputService
|
||||
BustIdentifierCache();
|
||||
}
|
||||
|
||||
public int CursorX { get; private set; }
|
||||
public int CursorY { get; private set; }
|
||||
|
||||
protected virtual void OnKeyboardKeyUpDown(ArtemisKeyboardKeyUpDownEventArgs e)
|
||||
{
|
||||
KeyboardKeyUpDown?.Invoke(this, e);
|
||||
@ -426,6 +429,9 @@ internal class InputService : IInputService
|
||||
|
||||
private void InputProviderOnMouseMoveDataReceived(object? sender, InputProviderMouseMoveEventArgs e)
|
||||
{
|
||||
CursorX = e.CursorX;
|
||||
CursorY = e.CursorY;
|
||||
|
||||
OnMouseMove(new ArtemisMouseMoveEventArgs(e.Device, e.CursorX, e.CursorY, e.DeltaX, e.DeltaY));
|
||||
// _logger.Verbose("Mouse move data: XY: {X},{Y} - delta XY: {deltaX},{deltaY} - device: {device} ", e.CursorX, e.CursorY, e.DeltaX, e.DeltaY, e.Device);
|
||||
}
|
||||
|
||||
@ -12,6 +12,16 @@ public interface IInputService : IArtemisService, IDisposable
|
||||
/// </summary>
|
||||
KeyboardToggleStatus KeyboardToggleStatus { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last reported cursor X position
|
||||
/// </summary>
|
||||
public int CursorX { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last reported cursor Y position
|
||||
/// </summary>
|
||||
public int CursorY { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds an input provided
|
||||
/// </summary>
|
||||
|
||||
@ -12,6 +12,7 @@ public class NavigationArguments
|
||||
Router = router;
|
||||
Options = options;
|
||||
Path = path;
|
||||
PathSegments = path.Split('/', StringSplitOptions.RemoveEmptyEntries);
|
||||
RouteParameters = routeParameters;
|
||||
SegmentParameters = [];
|
||||
}
|
||||
@ -31,6 +32,11 @@ public class NavigationArguments
|
||||
/// </summary>
|
||||
public string Path { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the segments of the path that is being navigated to.
|
||||
/// </summary>
|
||||
public string[] PathSegments { get; }
|
||||
|
||||
/// <summary>
|
||||
/// GEts an array of all parameters provided to this route.
|
||||
/// </summary>
|
||||
|
||||
@ -35,4 +35,15 @@
|
||||
<ItemGroup>
|
||||
<AvaloniaResource Include="Assets\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Screens\ProfileEditor\DesignPanels\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Screens\ProfileEditor\DesignProfileView.axaml.cs">
|
||||
<DependentUpon>DesignProfileView.axaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -67,6 +67,8 @@ namespace Artemis.UI.Routing
|
||||
]),
|
||||
new RouteRegistration<ProfileViewModel>("profile/{profileConfigurationId:guid}", [
|
||||
new RouteRegistration<ProfileEditorViewModel>("editor"),
|
||||
new RouteRegistration<ConfigureProfileViewModel>("configure"),
|
||||
new RouteRegistration<DesignProfileViewModel>("design"),
|
||||
new RouteRegistration<WorkshopProfileViewModel>("workshop")
|
||||
]),
|
||||
];
|
||||
|
||||
@ -0,0 +1,71 @@
|
||||
<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:preview="clr-namespace:Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Preview"
|
||||
xmlns:core="clr-namespace:Artemis.Core;assembly=Artemis.Core"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
xmlns:vis="clr-namespace:Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Preview.PreviewView"
|
||||
x:DataType="preview:PreviewViewModel">
|
||||
<UserControl.Resources>
|
||||
<VisualBrush x:Key="LargeCheckerboardBrush" TileMode="Tile" Stretch="Uniform" SourceRect="0,0,20,20">
|
||||
<VisualBrush.Visual>
|
||||
<Canvas Width="20" Height="20">
|
||||
<Rectangle Width="10" Height="10" Fill="Black" Opacity="0.15" />
|
||||
<Rectangle Width="10" Height="10" Canvas.Left="10" />
|
||||
<Rectangle Width="10" Height="10" Canvas.Top="10" />
|
||||
<Rectangle Width="10" Height="10" Canvas.Left="10" Canvas.Top="10" Fill="Black" Opacity="0.15" />
|
||||
</Canvas>
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
</UserControl.Resources>
|
||||
<ZoomBorder Name="ZoomBorder"
|
||||
Stretch="None"
|
||||
ClipToBounds="True"
|
||||
Focusable="True"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalAlignment="Stretch"
|
||||
Background="{StaticResource LargeCheckerboardBrush}"
|
||||
ZoomChanged="ZoomBorder_OnZoomChanged">
|
||||
<Grid Name="ContainerGrid" Background="Transparent">
|
||||
<Grid.Transitions>
|
||||
<Transitions>
|
||||
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.2" Easing="CubicEaseOut" />
|
||||
</Transitions>
|
||||
</Grid.Transitions>
|
||||
|
||||
<!-- The bottom layer consists of devices -->
|
||||
<ItemsControl Name="DevicesContainer" ItemsSource="{CompiledBinding Devices}" ClipToBounds="False">
|
||||
<ItemsControl.Styles>
|
||||
<Style Selector="ContentPresenter" x:DataType="core:ArtemisDevice">
|
||||
<Setter Property="Canvas.Left" Value="{CompiledBinding X}" />
|
||||
<Setter Property="Canvas.Top" Value="{CompiledBinding Y}" />
|
||||
</Style>
|
||||
</ItemsControl.Styles>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Canvas />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="core:ArtemisDevice">
|
||||
<shared:DeviceVisualizer Device="{CompiledBinding}" ShowColors="True" RenderOptions.BitmapInterpolationMode="MediumQuality" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<Border CornerRadius="0 0 8 0"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Left"
|
||||
Background="{DynamicResource ControlFillColorDefaultBrush}"
|
||||
IsVisible="{CompiledBinding ProfileConfiguration, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<StackPanel Orientation="Horizontal" Margin="8">
|
||||
<shared:ProfileConfigurationIcon ConfigurationIcon="{CompiledBinding ProfileConfiguration.Icon}" Width="18" Height="18" CornerRadius="3" Margin="0 0 5 0" />
|
||||
<TextBlock Text="{CompiledBinding ProfileConfiguration.Name}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ZoomBorder>
|
||||
</UserControl>
|
||||
@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Disposables.Fluent;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.UI.Screens.ProfileEditor.VisualEditor;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.PanAndZoom;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Avalonia;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Preview;
|
||||
|
||||
public partial class PreviewView : ReactiveUserControl<PreviewViewModel>
|
||||
{
|
||||
private bool _movedByUser;
|
||||
|
||||
public PreviewView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ZoomBorder.PropertyChanged += ZoomBorderOnPropertyChanged;
|
||||
ZoomBorder.PointerMoved += ZoomBorderOnPointerMoved;
|
||||
ZoomBorder.PointerWheelChanged += ZoomBorderOnPointerWheelChanged;
|
||||
UpdateZoomBorderBackground();
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
PreviewViewModel vm = ViewModel!;
|
||||
vm.AutoFitRequested += ViewModelOnAutoFitRequested;
|
||||
Disposable.Create(() => vm.AutoFitRequested -= ViewModelOnAutoFitRequested).DisposeWith(d);
|
||||
});
|
||||
|
||||
this.WhenAnyValue(v => v.Bounds).Where(_ => !_movedByUser).Subscribe(_ => AutoFit(true));
|
||||
}
|
||||
|
||||
private void ZoomBorderOnPointerWheelChanged(object? sender, PointerWheelEventArgs e)
|
||||
{
|
||||
_movedByUser = true;
|
||||
}
|
||||
|
||||
private void ZoomBorderOnPointerMoved(object? sender, PointerEventArgs e)
|
||||
{
|
||||
if (e.GetCurrentPoint(ZoomBorder).Properties.IsMiddleButtonPressed)
|
||||
_movedByUser = true;
|
||||
}
|
||||
|
||||
private void ViewModelOnAutoFitRequested(object? sender, EventArgs e)
|
||||
{
|
||||
Dispatcher.UIThread.Post(() => AutoFit(false));
|
||||
}
|
||||
|
||||
private void ZoomBorderOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.Property.Name == nameof(ZoomBorder.Background))
|
||||
UpdateZoomBorderBackground();
|
||||
}
|
||||
|
||||
private void UpdateZoomBorderBackground()
|
||||
{
|
||||
if (ZoomBorder.Background is VisualBrush visualBrush)
|
||||
visualBrush.DestinationRect = new RelativeRect(ZoomBorder.OffsetX, ZoomBorder.OffsetY, 20, 20, RelativeUnit.Absolute);
|
||||
}
|
||||
|
||||
|
||||
private void ZoomBorder_OnZoomChanged(object sender, ZoomChangedEventArgs e)
|
||||
{
|
||||
UpdateZoomBorderBackground();
|
||||
}
|
||||
|
||||
private void AutoFit(bool skipTransitions)
|
||||
{
|
||||
if (ViewModel == null || !ViewModel.Devices.Any())
|
||||
return;
|
||||
|
||||
double left = ViewModel.Devices.Select(d => d.Rectangle.Left).Min();
|
||||
double top = ViewModel.Devices.Select(d => d.Rectangle.Top).Min();
|
||||
double bottom = ViewModel.Devices.Select(d => d.Rectangle.Bottom).Max();
|
||||
double right = ViewModel.Devices.Select(d => d.Rectangle.Right).Max();
|
||||
|
||||
// Add a 10 pixel margin around the rect
|
||||
Rect scriptRect = new(new Point(left - 10, top - 10), new Point(right + 10, bottom + 10));
|
||||
|
||||
// The scale depends on the available space
|
||||
double scale = Math.Min(3, Math.Min(Bounds.Width / scriptRect.Width, Bounds.Height / scriptRect.Height));
|
||||
|
||||
// Pan and zoom to make the script fit
|
||||
ZoomBorder.Zoom(scale, 0, 0, skipTransitions);
|
||||
ZoomBorder.Pan(Bounds.Center.X - scriptRect.Center.X * scale, Bounds.Center.Y - scriptRect.Center.Y * scale, skipTransitions);
|
||||
|
||||
_movedByUser = false;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables.Fluent;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Preview;
|
||||
|
||||
public class PreviewViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private ObservableAsPropertyHelper<ProfileConfiguration?>? _profileConfiguration;
|
||||
|
||||
public PreviewViewModel(IProfileEditorService profileEditorService, IDeviceService deviceService)
|
||||
{
|
||||
Devices = new ObservableCollection<ArtemisDevice>(deviceService.EnabledDevices.OrderBy(d => d.ZIndex));
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
_profileConfiguration = profileEditorService.ProfileConfiguration.ToProperty(this, vm => vm.ProfileConfiguration).DisposeWith(d);
|
||||
});
|
||||
}
|
||||
|
||||
public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value;
|
||||
public ObservableCollection<ArtemisDevice> Devices { get; }
|
||||
|
||||
public void RequestAutoFit()
|
||||
{
|
||||
AutoFitRequested?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event EventHandler? AutoFitRequested;
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
<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:section="clr-namespace:Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Section"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Section.ConfigurationSectionView"
|
||||
x:DataType="section:ConfigurationSectionViewModel">
|
||||
<Border Classes="card" VerticalAlignment="Top">
|
||||
<StackPanel>
|
||||
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}" Text="{CompiledBinding ConfigurationSection.Name}"/>
|
||||
<Border Classes="card-separator" />
|
||||
<ScrollViewer>
|
||||
<TextBlock>Test</TextBlock>
|
||||
</ScrollViewer>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@ -0,0 +1,14 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ReactiveUI.Avalonia;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Section;
|
||||
|
||||
public partial class ConfigurationSectionView: ReactiveUserControl<ConfigurationSectionViewModel>
|
||||
{
|
||||
public ConfigurationSectionView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Section;
|
||||
|
||||
public class ConfigurationSectionViewModel : ActivatableViewModelBase
|
||||
{
|
||||
public ConfigurationSection ConfigurationSection { get; }
|
||||
|
||||
public ConfigurationSectionViewModel(ConfigurationSection configurationSection)
|
||||
{
|
||||
ConfigurationSection = configurationSection;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
<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:slot="clr-namespace:Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Slot"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Slot.SlotView"
|
||||
x:DataType="slot:SlotViewModel">
|
||||
Welcome to Avalonia!
|
||||
</UserControl>
|
||||
@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Slot;
|
||||
|
||||
public partial class SlotView : UserControl
|
||||
{
|
||||
public SlotView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
using Artemis.UI.Shared;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Slot;
|
||||
|
||||
public class SlotViewModel : ActivatableViewModelBase
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
<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:profileEditor="clr-namespace:Artemis.UI.Screens.ProfileEditor"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.ConfigureProfileView"
|
||||
x:DataType="profileEditor:ConfigureProfileViewModel">
|
||||
<Border Classes="router-container" Padding="8">
|
||||
<Grid RowDefinitions="0.6*, 0.6*" ColumnDefinitions="0.3*, 0.3*, 0.4*" ColumnSpacing="8" RowSpacing="8">
|
||||
<ContentControl Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Content="{CompiledBinding PreviewViewModel}" />
|
||||
|
||||
<ItemsControl Grid.Column="0" Grid.Row="1" ItemsSource="{CompiledBinding BottomLeftSections}"/>
|
||||
<ItemsControl Grid.Column="1" Grid.Row="1" ItemsSource="{CompiledBinding BottomRightSections}"/>
|
||||
<ItemsControl Grid.Column="2" Grid.Row="0" Grid.RowSpan="2" ItemsSource="{CompiledBinding SideSections}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@ -0,0 +1,11 @@
|
||||
using ReactiveUI.Avalonia;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor;
|
||||
|
||||
public partial class ConfigureProfileView : ReactiveUserControl<ConfigureProfileViewModel>
|
||||
{
|
||||
public ConfigureProfileView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Preview;
|
||||
using Artemis.UI.Screens.ProfileEditor.ConfigurationPanels.Section;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using DynamicData;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor;
|
||||
|
||||
public partial class ConfigureProfileViewModel : RoutableScreen<ProfileViewModelParameters>
|
||||
{
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly SourceList<ConfigurationSection> _configurationSections;
|
||||
|
||||
[Notify] private ProfileConfiguration? _profileConfiguration;
|
||||
|
||||
public ConfigureProfileViewModel(IProfileService profileService, IProfileEditorService profileEditorService, PreviewViewModel previewViewModel,
|
||||
Func<ConfigurationSection, ConfigurationSectionViewModel> getConfigurationSectionViewModel)
|
||||
{
|
||||
_profileService = profileService;
|
||||
_profileEditorService = profileEditorService;
|
||||
ParameterSource = ParameterSource.Route;
|
||||
|
||||
PreviewViewModel = previewViewModel;
|
||||
|
||||
_configurationSections = new SourceList<ConfigurationSection>();
|
||||
_configurationSections.Connect()
|
||||
.Filter(s => s.Slot == 0)
|
||||
.Transform(getConfigurationSectionViewModel)
|
||||
.Bind(out ReadOnlyObservableCollection<ConfigurationSectionViewModel> bottomLeftSections)
|
||||
.Subscribe();
|
||||
_configurationSections.Connect()
|
||||
.Filter(s => s.Slot == 1)
|
||||
.Transform(getConfigurationSectionViewModel)
|
||||
.Bind(out ReadOnlyObservableCollection<ConfigurationSectionViewModel> bottomRightSections)
|
||||
.Subscribe();
|
||||
_configurationSections.Connect()
|
||||
.Filter(s => s.Slot == 2)
|
||||
.Transform(getConfigurationSectionViewModel)
|
||||
.Bind(out ReadOnlyObservableCollection<ConfigurationSectionViewModel> sideSections)
|
||||
.Subscribe();
|
||||
|
||||
BottomLeftSections = bottomLeftSections;
|
||||
BottomRightSections = bottomRightSections;
|
||||
SideSections = sideSections;
|
||||
}
|
||||
|
||||
public PreviewViewModel PreviewViewModel { get; }
|
||||
public ReadOnlyObservableCollection<ConfigurationSectionViewModel> BottomLeftSections { get; private set; }
|
||||
public ReadOnlyObservableCollection<ConfigurationSectionViewModel> BottomRightSections { get; private set; }
|
||||
public ReadOnlyObservableCollection<ConfigurationSectionViewModel> SideSections { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task OnNavigating(ProfileViewModelParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
|
||||
{
|
||||
ProfileConfiguration? profileConfiguration = _profileService.ProfileCategories.SelectMany(c => c.ProfileConfigurations).FirstOrDefault(c => c.ProfileId == parameters.ProfileId);
|
||||
|
||||
// If the profile doesn't exist, cancel navigation
|
||||
if (profileConfiguration == null)
|
||||
{
|
||||
args.Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
await _profileEditorService.ChangeCurrentProfileConfiguration(profileConfiguration);
|
||||
ProfileConfiguration = profileConfiguration;
|
||||
_configurationSections.Edit(editableSections =>
|
||||
{
|
||||
editableSections.Clear();
|
||||
editableSections.AddRange(profileConfiguration.ConfigurationSections);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task OnClosing(NavigationArguments args)
|
||||
{
|
||||
if (!args.Path.StartsWith("profile"))
|
||||
{
|
||||
ProfileConfiguration = null;
|
||||
await _profileEditorService.ChangeCurrentProfileConfiguration(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
14
src/Artemis.UI/Screens/ProfileEditor/DesignProfileView.axaml
Normal file
14
src/Artemis.UI/Screens/ProfileEditor/DesignProfileView.axaml
Normal file
@ -0,0 +1,14 @@
|
||||
<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:profileEditor="clr-namespace:Artemis.UI.Screens.ProfileEditor"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.DesignProfileView"
|
||||
x:DataType="profileEditor:DesignProfileViewModel">
|
||||
<Border Classes="router-container">
|
||||
|
||||
<TextBlock>Design</TextBlock>
|
||||
|
||||
</Border>
|
||||
</UserControl>
|
||||
@ -0,0 +1,11 @@
|
||||
using ReactiveUI.Avalonia;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor;
|
||||
|
||||
public partial class DesignProfileView : ReactiveUserControl<DesignProfileViewModel>
|
||||
{
|
||||
public DesignProfileView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Screens.Workshop.Library.Tabs;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.WebClient.Workshop.Models;
|
||||
using Artemis.WebClient.Workshop.Services;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor;
|
||||
|
||||
public partial class DesignProfileViewModel : RoutableScreen<ProfileViewModelParameters>
|
||||
{
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IWorkshopService _workshopService;
|
||||
private readonly IRouter _router;
|
||||
private readonly Func<InstalledEntry, InstalledTabItemViewModel> _getInstalledTabItemViewModel;
|
||||
|
||||
[Notify] private ProfileConfiguration? _profileConfiguration;
|
||||
[Notify] private InstalledEntry? _workshopEntry;
|
||||
[Notify] private InstalledTabItemViewModel? _entryViewModel;
|
||||
|
||||
public DesignProfileViewModel(IProfileService profileService, IWorkshopService workshopService, IRouter router, Func<InstalledEntry, InstalledTabItemViewModel> getInstalledTabItemViewModel)
|
||||
{
|
||||
_profileService = profileService;
|
||||
_workshopService = workshopService;
|
||||
_router = router;
|
||||
_getInstalledTabItemViewModel = getInstalledTabItemViewModel;
|
||||
ParameterSource = ParameterSource.Route;
|
||||
}
|
||||
|
||||
public async Task DisableAutoUpdate()
|
||||
{
|
||||
if (WorkshopEntry != null)
|
||||
{
|
||||
_workshopService.SetAutoUpdate(WorkshopEntry, false);
|
||||
}
|
||||
|
||||
if (ProfileConfiguration != null)
|
||||
{
|
||||
await _router.Navigate($"profile/{ProfileConfiguration.ProfileId}/editor");
|
||||
}
|
||||
}
|
||||
|
||||
public override Task OnNavigating(ProfileViewModelParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
|
||||
{
|
||||
ProfileConfiguration = _profileService.ProfileCategories.SelectMany(c => c.ProfileConfigurations).FirstOrDefault(c => c.ProfileId == parameters.ProfileId);
|
||||
|
||||
// If the profile doesn't exist, cancel navigation
|
||||
if (ProfileConfiguration == null)
|
||||
{
|
||||
args.Cancel();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
WorkshopEntry = _workshopService.GetInstalledEntryByProfile(ProfileConfiguration);
|
||||
EntryViewModel = WorkshopEntry != null ? _getInstalledTabItemViewModel(WorkshopEntry) : null;
|
||||
if (EntryViewModel != null)
|
||||
EntryViewModel.DisplayManagement = false;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@ -61,7 +61,7 @@ public partial class VisualEditorView : ReactiveUserControl<VisualEditorViewMode
|
||||
private void UpdateZoomBorderBackground()
|
||||
{
|
||||
if (ZoomBorder.Background is VisualBrush visualBrush)
|
||||
visualBrush.DestinationRect = new RelativeRect(ZoomBorder.OffsetX * -1, ZoomBorder.OffsetY * -1, 20, 20, RelativeUnit.Absolute);
|
||||
visualBrush.DestinationRect = new RelativeRect(ZoomBorder.OffsetX, ZoomBorder.OffsetY, 20, 20, RelativeUnit.Absolute);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -43,17 +43,25 @@ public class ProfileViewModel : RoutableHostScreen<RoutableScreen, ProfileViewMo
|
||||
return;
|
||||
}
|
||||
|
||||
// If the profile is from the workshop, redirect to the workshop page
|
||||
// Redirect to the correct sub-page if no sub-page is specified
|
||||
if (args.PathSegments.Length >= 3)
|
||||
return;
|
||||
|
||||
// If the profile is configurable, go to the configuration page
|
||||
if (profileConfiguration.IsConfigurable)
|
||||
{
|
||||
await args.Router.Navigate($"profile/{parameters.ProfileId}/configure");
|
||||
}
|
||||
// Otherwise either the workshop notice or the editor
|
||||
else
|
||||
{
|
||||
InstalledEntry? workshopEntry = _workshopService.GetInstalledEntryByProfile(profileConfiguration);
|
||||
if (workshopEntry != null && workshopEntry.AutoUpdate)
|
||||
{
|
||||
if (!args.Path.EndsWith("workshop"))
|
||||
await args.Router.Navigate($"profile/{parameters.ProfileId}/workshop");
|
||||
}
|
||||
// Otherwise, show the profile editor if not already on the editor page
|
||||
else if (!args.Path.EndsWith("editor"))
|
||||
else
|
||||
await args.Router.Navigate($"profile/{parameters.ProfileId}/editor");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ProfileViewModelParameters
|
||||
|
||||
@ -65,7 +65,7 @@ public partial class SidebarCategoryViewModel : ActivatableViewModelBase
|
||||
// Navigate on selection change
|
||||
this.WhenAnyValue(vm => vm.SelectedProfileConfiguration)
|
||||
.WhereNotNull()
|
||||
.Subscribe(s => _router.Navigate($"profile/{s.ProfileConfiguration.ProfileId}/editor", new RouterNavigationOptions {IgnoreOnPartialMatch = true, RecycleScreens = false}))
|
||||
.Subscribe(s => _router.Navigate($"profile/{s.ProfileConfiguration.ProfileId}", new RouterNavigationOptions {IgnoreOnPartialMatch = true, RecycleScreens = false}))
|
||||
.DisposeWith(d);
|
||||
|
||||
_router.CurrentPath.WhereNotNull().Subscribe(r => SelectedProfileConfiguration = ProfileConfigurations.FirstOrDefault(c => c.Matches(r))).DisposeWith(d);
|
||||
|
||||
@ -48,6 +48,6 @@ public partial class SurfaceEditorView : ReactiveUserControl<SurfaceEditorViewMo
|
||||
private void UpdateZoomBorderBackground()
|
||||
{
|
||||
if (ContainerZoomBorder.Background is VisualBrush visualBrush)
|
||||
visualBrush.DestinationRect = new RelativeRect(ContainerZoomBorder.OffsetX * -1, ContainerZoomBorder.OffsetY * -1, 20, 20, RelativeUnit.Absolute);
|
||||
visualBrush.DestinationRect = new RelativeRect(ContainerZoomBorder.OffsetX, ContainerZoomBorder.OffsetY, 20, 20, RelativeUnit.Absolute);
|
||||
}
|
||||
}
|
||||
@ -130,7 +130,7 @@ public partial class NodeScriptView : ReactiveUserControl<NodeScriptViewModel>
|
||||
private void UpdateZoomBorderBackground()
|
||||
{
|
||||
if (NodeScriptZoomBorder.Background is VisualBrush visualBrush)
|
||||
visualBrush.DestinationRect = new RelativeRect(NodeScriptZoomBorder.OffsetX * -1, NodeScriptZoomBorder.OffsetY * -1, 20, 20, RelativeUnit.Absolute);
|
||||
visualBrush.DestinationRect = new RelativeRect(NodeScriptZoomBorder.OffsetX, NodeScriptZoomBorder.OffsetY, 20, 20, RelativeUnit.Absolute);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ public partial class ProfilePreviewView : ReactiveUserControl<ProfilePreviewView
|
||||
private void UpdateZoomBorderBackground()
|
||||
{
|
||||
if (ZoomBorder.Background is VisualBrush visualBrush)
|
||||
visualBrush.DestinationRect = new RelativeRect(ZoomBorder.OffsetX * -1, ZoomBorder.OffsetY * -1, 20, 20, RelativeUnit.Absolute);
|
||||
visualBrush.DestinationRect = new RelativeRect(ZoomBorder.OffsetX, ZoomBorder.OffsetY, 20, 20, RelativeUnit.Absolute);
|
||||
}
|
||||
|
||||
private void ZoomBorder_OnZoomChanged(object sender, ZoomChangedEventArgs e)
|
||||
|
||||
@ -29,7 +29,7 @@ public class ProfileAdaptionHintsStepViewModel : SubmissionViewModel
|
||||
_layers.Connect().Bind(out ReadOnlyObservableCollection<ProfileAdaptionHintsLayerViewModel> layers).Subscribe();
|
||||
|
||||
GoBack = ReactiveCommand.Create(() => State.ChangeScreen<ProfileSelectionStepViewModel>());
|
||||
Continue = ReactiveCommand.Create(ExecuteContinue, _layers.Connect().AutoRefresh(l => l.AdaptionHintCount).Filter(l => l.AdaptionHintCount == 0).IsEmpty());
|
||||
Continue = ReactiveCommand.Create(ExecuteContinue);
|
||||
EditAdaptionHints = ReactiveCommand.CreateFromTask<Layer>(ExecuteEditAdaptionHints);
|
||||
Layers = layers;
|
||||
|
||||
|
||||
@ -4,10 +4,10 @@ public static class WorkshopConstants
|
||||
{
|
||||
// This is so I can never accidentally release with localhost
|
||||
#if DEBUG
|
||||
public const string AUTHORITY_URL = "https://localhost:5001";
|
||||
public const string WORKSHOP_URL = "https://localhost:7281";
|
||||
// public const string AUTHORITY_URL = "https://identity.artemis-rgb.com";
|
||||
// public const string WORKSHOP_URL = "https://workshop.artemis-rgb.com";
|
||||
// public const string AUTHORITY_URL = "https://localhost:5001";
|
||||
// public const string WORKSHOP_URL = "https://localhost:7281";
|
||||
public const string AUTHORITY_URL = "https://identity.artemis-rgb.com";
|
||||
public const string WORKSHOP_URL = "https://workshop.artemis-rgb.com";
|
||||
#else
|
||||
public const string AUTHORITY_URL = "https://identity.artemis-rgb.com";
|
||||
public const string WORKSHOP_URL = "https://workshop.artemis-rgb.com";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user