mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Sidebar - Refactored category VM to fix all issues with it I could find
Sidebar - Streamlined design Sidebar - Increase width on wide window sizes Profile editor - Implement File and Help menus
This commit is contained in:
parent
35f83e58e5
commit
78479c0fa2
7
src/.idea/.idea.Artemis/.idea/avalonia.xml
generated
7
src/.idea/.idea.Artemis/.idea/avalonia.xml
generated
@ -18,8 +18,11 @@
|
||||
<entry key="Artemis.UI.Windows/App.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
|
||||
<entry key="Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
|
||||
<entry key="Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/MainWindow.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/Plugins/PluginFeatureView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/Plugins/PluginSettingsView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/MenuBar/MenuBarView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/ProfileTreeView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/Dialogs/AddEffectView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertiesView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/Tree/ContentDialogs/LayerEffectRenameView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
@ -28,9 +31,13 @@
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/Tree/TreePropertyView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/Windows/EffectConfigurationWindowView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Tools/TransformToolView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/Root/SplashView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/Settings/Tabs/GeneralTabView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/Sidebar/SidebarCategoryView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/Sidebar/SidebarProfileConfigurationView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/Sidebar/SidebarView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/VisualScripting/NodeView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Avalonia/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugView.axaml" value="Avalonia/Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Avalonia/Artemis.UI/Styles/Artemis.axaml" value="Avalonia/Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
|
||||
@ -141,6 +141,20 @@ public interface IProfileEditorService : IArtemisSharedUIService
|
||||
/// <returns>The rounded time.</returns>
|
||||
TimeSpan RoundTime(TimeSpan time);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new folder as a sibling or child of the given target.
|
||||
/// </summary>
|
||||
/// <param name="target">The target, if this is a layer the new layer will become a sibling, otherwise a child.</param>
|
||||
/// <returns>The resulting folder.</returns>
|
||||
Folder CreateAndAddFolder(ProfileElement target);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new layer with the default brush and all current LEDs as a sibling or child of the given target.
|
||||
/// </summary>
|
||||
/// <param name="target">The target, if this is a layer the new layer will become a sibling, otherwise a child.</param>
|
||||
/// <returns>The resulting layer.</returns>
|
||||
Layer CreateAndAddLayer(ProfileElement target);
|
||||
|
||||
/// <summary>
|
||||
/// Executes the provided command and adds it to the history.
|
||||
/// </summary>
|
||||
|
||||
@ -18,6 +18,8 @@ internal class ProfileEditorService : IProfileEditorService
|
||||
private readonly BehaviorSubject<ILayerProperty?> _layerPropertySubject = new(null);
|
||||
private readonly ILogger _logger;
|
||||
private readonly IModuleService _moduleService;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly ILayerBrushService _layerBrushService;
|
||||
private readonly BehaviorSubject<int> _pixelsPerSecondSubject = new(120);
|
||||
private readonly BehaviorSubject<bool> _playingSubject = new(false);
|
||||
private readonly BehaviorSubject<ProfileConfiguration?> _profileConfigurationSubject = new(null);
|
||||
@ -30,11 +32,18 @@ internal class ProfileEditorService : IProfileEditorService
|
||||
private readonly IWindowService _windowService;
|
||||
private ProfileEditorCommandScope? _profileEditorHistoryScope;
|
||||
|
||||
public ProfileEditorService(ILogger logger, IProfileService profileService, IModuleService moduleService, IWindowService windowService)
|
||||
public ProfileEditorService(ILogger logger,
|
||||
IProfileService profileService,
|
||||
IModuleService moduleService,
|
||||
IRgbService rgbService,
|
||||
ILayerBrushService layerBrushService,
|
||||
IWindowService windowService)
|
||||
{
|
||||
_logger = logger;
|
||||
_profileService = profileService;
|
||||
_moduleService = moduleService;
|
||||
_rgbService = rgbService;
|
||||
_layerBrushService = layerBrushService;
|
||||
_windowService = windowService;
|
||||
|
||||
ProfileConfiguration = _profileConfigurationSubject.AsObservable();
|
||||
@ -293,6 +302,48 @@ internal class ProfileEditorService : IProfileEditorService
|
||||
return TimeSpan.FromMilliseconds(Math.Round(time.TotalMilliseconds));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Folder CreateAndAddFolder(ProfileElement target)
|
||||
{
|
||||
if (target is Layer targetLayer)
|
||||
{
|
||||
Folder folder = new(targetLayer.Parent, targetLayer.Parent.GetNewFolderName());
|
||||
ExecuteCommand(new AddProfileElement(folder, targetLayer.Parent, targetLayer.Order));
|
||||
return folder;
|
||||
}
|
||||
else
|
||||
{
|
||||
Folder folder = new(target, target.GetNewFolderName());
|
||||
ExecuteCommand(new AddProfileElement(folder, target, 0));
|
||||
return folder;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Layer CreateAndAddLayer(ProfileElement target)
|
||||
{
|
||||
if (target is Layer targetLayer)
|
||||
{
|
||||
Layer layer = new(targetLayer.Parent, targetLayer.GetNewLayerName());
|
||||
_layerBrushService.ApplyDefaultBrush(layer);
|
||||
|
||||
layer.AddLeds(_rgbService.EnabledDevices.SelectMany(d => d.Leds));
|
||||
ExecuteCommand(new AddProfileElement(layer, targetLayer.Parent, targetLayer.Order));
|
||||
|
||||
return layer;
|
||||
}
|
||||
else
|
||||
{
|
||||
Layer layer = new(target, target.GetNewLayerName());
|
||||
_layerBrushService.ApplyDefaultBrush(layer);
|
||||
|
||||
layer.AddLeds(_rgbService.EnabledDevices.SelectMany(d => d.Leds));
|
||||
ExecuteCommand(new AddProfileElement(layer, target, 0));
|
||||
|
||||
return layer;
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangePixelsPerSecond(int pixelsPerSecond)
|
||||
{
|
||||
_pixelsPerSecondSubject.OnNext(pixelsPerSecond);
|
||||
|
||||
@ -7,9 +7,15 @@
|
||||
x:Class="Artemis.UI.MainWindow"
|
||||
Icon="/Assets/Images/Logo/application.ico"
|
||||
Title="Artemis 2.0">
|
||||
<Panel>
|
||||
<Panel Name="RootPanel">
|
||||
<DockPanel>
|
||||
<ContentControl Content="{Binding SidebarViewModel}" DockPanel.Dock="Left"></ContentControl>
|
||||
<ContentControl Name="SidebarContentControl" Content="{Binding SidebarViewModel}" DockPanel.Dock="Left" Width="240">
|
||||
<ContentControl.Transitions>
|
||||
<Transitions>
|
||||
<DoubleTransition Property="Width" Duration="0:0:0.2" Easing="CubicEaseOut"></DoubleTransition>
|
||||
</Transitions>
|
||||
</ContentControl.Transitions>
|
||||
</ContentControl>
|
||||
<Border Background="Transparent" Name="TitleBar" DockPanel.Dock="Top">
|
||||
<ContentControl Content="{Binding TitleBarViewModel}" />
|
||||
</Border>
|
||||
|
||||
@ -12,15 +12,28 @@ namespace Artemis.UI
|
||||
{
|
||||
public class MainWindow : ReactiveCoreWindow<RootViewModel>
|
||||
{
|
||||
private readonly Panel _rootPanel;
|
||||
private readonly ContentControl _sidebarContentControl;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
Opened += OnOpened;
|
||||
InitializeComponent();
|
||||
_rootPanel = this.Get<Panel>("RootPanel");
|
||||
_sidebarContentControl = this.Get<ContentControl>("SidebarContentControl");
|
||||
_rootPanel.LayoutUpdated += OnLayoutUpdated;
|
||||
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: Replace with a media query once https://github.com/AvaloniaUI/Avalonia/pull/7938 is implemented
|
||||
private void OnLayoutUpdated(object? sender, EventArgs e)
|
||||
{
|
||||
_sidebarContentControl.Width = _rootPanel.Bounds.Width >= 1800 ? 300 : 240;
|
||||
}
|
||||
|
||||
private void OnOpened(object? sender, EventArgs e)
|
||||
{
|
||||
Opened -= OnOpened;
|
||||
@ -32,12 +45,6 @@ namespace Artemis.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupTitlebar()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
|
||||
@ -13,19 +13,19 @@
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Plus" />
|
||||
</MenuItem.Icon>
|
||||
<MenuItem Header="Folder" Command="{Binding AddFolder}">
|
||||
<MenuItem Header="Folder" Command="{CompiledBinding AddFolder}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Folder" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Layer" Command="{Binding AddLayer}">
|
||||
<MenuItem Header="Layer" Command="{CompiledBinding AddLayer}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Layers" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="View Properties" Command="{Binding ViewProperties}">
|
||||
<MenuItem Header="View Properties" Command="{CompiledBinding ViewProperties}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Settings" />
|
||||
</MenuItem.Icon>
|
||||
@ -40,112 +40,93 @@
|
||||
<avalonia:MaterialIcon Kind="Magic" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Suspend Profile" IsSelected="{CompiledBinding IsSuspended}">
|
||||
<MenuItem Header="Suspend Profile" Command="{CompiledBinding ToggleSuspended}">
|
||||
<MenuItem.Icon>
|
||||
<CheckBox BorderThickness="0"
|
||||
IsHitTestVisible="False"
|
||||
IsChecked="{CompiledBinding IsSuspended}"/>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding IsSuspended}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="Export Profile" Command="{Binding ExportProfile}">
|
||||
<MenuItem Header="Export Profile" Command="{CompiledBinding ExportProfile}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Export" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Duplicate Profile" Command="{Binding DuplicateProfile}">
|
||||
<MenuItem Header="Duplicate Profile" Command="{CompiledBinding DuplicateProfile}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="ContentDuplicate" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="Delete Profile" Command="{Binding DeleteProfile}">
|
||||
<MenuItem Header="Delete Profile" Command="{CompiledBinding DeleteProfile}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Trash" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Edit" SubmenuOpened="MenuItem_OnSubmenuOpened">
|
||||
<MenuItem Header="_Undo"
|
||||
Command="{Binding History.Undo}"
|
||||
HotKey="Ctrl+Z"
|
||||
InputGesture="Ctrl+Z">
|
||||
<MenuItem Header="_Undo" Command="{CompiledBinding History.Undo}" InputGesture="Ctrl+Z">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Undo" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Redo"
|
||||
Command="{Binding History.Redo}"
|
||||
HotKey="Ctrl+Y"
|
||||
InputGesture="Ctrl+Y">
|
||||
<MenuItem Header="_Redo" Command="{CompiledBinding History.Redo}" InputGesture="Ctrl+Y">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Redo" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="_Duplicate"
|
||||
Command="{Binding Duplicate}"
|
||||
HotKey="Ctrl+D"
|
||||
IsEnabled="{Binding HasSelectedElement}">
|
||||
<MenuItem Header="_Duplicate" Command="{Binding Duplicate}" InputGesture="Ctrl+D">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="ContentDuplicate" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Copy"
|
||||
Command="{Binding Copy}"
|
||||
HotKey="Ctrl+C"
|
||||
IsEnabled="{Binding HasSelectedElement}">
|
||||
<MenuItem Header="_Copy" Command="{Binding Copy}" InputGesture="Ctrl+C">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="ContentCopy" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Paste"
|
||||
Command="{Binding Paste}"
|
||||
HotKey="Ctrl+V">
|
||||
<MenuItem Header="_Paste" Command="{Binding Paste}" InputGesture="Ctrl+V">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIconExt Kind="ContentPaste" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Run">
|
||||
<MenuItem Header="_Switch run mode"
|
||||
Command="{Binding ToggleSuspend}"
|
||||
HotKey="F5">
|
||||
<MenuItem Header="_Switch run mode" Command="{CompiledBinding ToggleSuspendedEditing}" InputGesture="F5">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="SwapHorizontal" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Run Profile on Focus Loss"
|
||||
<MenuItem Header="Switch Run Mode on Focus Loss"
|
||||
ToolTip.Tip="If enabled, run mode is set to normal on focus loss"
|
||||
HotKey="Shift+F5">
|
||||
InputGesture="Shift+F5"
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
CommandParameter="{CompiledBinding AutoSuspend}">
|
||||
<MenuItem.Icon>
|
||||
<CheckBox BorderThickness="0"
|
||||
IsHitTestVisible="False"
|
||||
IsChecked="{Binding StopOnFocusLoss.Value}" />
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding AutoSuspend.Value}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Options">
|
||||
<MenuItem Header="Focus Selected Layer"
|
||||
ToolTip.Tip="If enabled, displays only the layer you currently have selected"
|
||||
<MenuItem Header="Focus Selected Layer" ToolTip.Tip="If enabled, displays only the layer you currently have selected"
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
CommandParameter="{CompiledBinding FocusSelectedLayer}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding FocusSelectedLayer.Value}"></avalonia:MaterialIcon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding FocusSelectedLayer.Value}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Display Data Model Values"
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
CommandParameter="{CompiledBinding ShowDataModelValues}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding ShowDataModelValues.Value}"></avalonia:MaterialIcon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding ShowDataModelValues.Value}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Display Full Condition Paths"
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
CommandParameter="{CompiledBinding ShowFullPaths}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding ShowFullPaths.Value}"></avalonia:MaterialIcon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding ShowFullPaths.Value}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Always Display Cable Values"
|
||||
@ -153,7 +134,7 @@
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
CommandParameter="{CompiledBinding AlwaysShowValues}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding AlwaysShowValues.Value}"></avalonia:MaterialIcon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding AlwaysShowValues.Value}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Apply All Data Bindings During Edit"
|
||||
@ -161,54 +142,54 @@
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
CommandParameter="{CompiledBinding AlwaysApplyDataBindings}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding AlwaysApplyDataBindings.Value}"></avalonia:MaterialIcon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding AlwaysApplyDataBindings.Value}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Help">
|
||||
<MenuItem Header="Artemis Wiki" Command="{Binding OpenUrl}" CommandParameter="https://wiki.artemis-rgb.com/">
|
||||
<MenuItem Header="Artemis Wiki" Command="{CompiledBinding OpenUri}" CommandParameter="https://wiki.artemis-rgb.com/">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="BookEdit" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="Editor" Command="{Binding OpenUrl}" CommandParameter="https://wiki.artemis-rgb.com/en/guides/user/profiles">
|
||||
<MenuItem Header="Editor" Command="{CompiledBinding OpenUri}" CommandParameter="https://wiki.artemis-rgb.com/en/guides/user/profiles">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Edit" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Layers" Command="{Binding OpenUrl}" CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/layers">
|
||||
<MenuItem Header="Layers" Command="{CompiledBinding OpenUri}" CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/layers">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Layers" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Display Conditions" Command="{Binding OpenUrl}" CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/conditions">
|
||||
<MenuItem Header="Display Conditions" Command="{CompiledBinding OpenUri}" CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/conditions">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="NotEqual" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Timeline" Command="{Binding OpenUrl}" CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/timeline">
|
||||
<MenuItem Header="Timeline" Command="{CompiledBinding OpenUri}" CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/timeline">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Stopwatch" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Data Bindings" Command="{Binding OpenUrl}" CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/data-bindings">
|
||||
<MenuItem Header="Data Bindings" Command="{CompiledBinding OpenUri}" CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/data-bindings">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="VectorLink" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Scripting" Command="{Binding OpenUrl}" CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/scripting">
|
||||
<MenuItem Header="Scripting" Command="{CompiledBinding OpenUri}" CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/scripting">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="CodeJson" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="Report a Bug" Command="{Binding OpenUrl}" CommandParameter="https://github.com/Artemis-RGB/Artemis/issues">
|
||||
<MenuItem Header="Report a Bug" Command="{CompiledBinding OpenUri}" CommandParameter="https://github.com/Artemis-RGB/Artemis/issues">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Github" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Get Help on Discord" Command="{Binding OpenUrl}" CommandParameter="https://discord.gg/S3MVaC9">
|
||||
<MenuItem Header="Get Help on Discord" Command="{CompiledBinding OpenUri}" CommandParameter="https://discord.gg/S3MVaC9">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Discord" />
|
||||
</MenuItem.Icon>
|
||||
|
||||
@ -2,9 +2,9 @@ using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.MenuBar
|
||||
{
|
||||
public partial class MenuBarView : ReactiveUserControl<MenuBarViewModel>
|
||||
namespace Artemis.UI.Screens.ProfileEditor.MenuBar;
|
||||
|
||||
public class MenuBarView : ReactiveUserControl<MenuBarViewModel>
|
||||
{
|
||||
public MenuBarView()
|
||||
{
|
||||
@ -18,7 +18,5 @@ namespace Artemis.UI.Screens.ProfileEditor.MenuBar
|
||||
|
||||
private void MenuItem_OnSubmenuOpened(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,31 +1,50 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Screens.Sidebar;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
||||
using Newtonsoft.Json;
|
||||
using ReactiveUI;
|
||||
using Serilog;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.MenuBar;
|
||||
|
||||
public class MenuBarViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IWindowService _windowService;
|
||||
private ProfileEditorHistory? _history;
|
||||
private ObservableAsPropertyHelper<ProfileConfiguration?>? _profileConfiguration;
|
||||
private ObservableAsPropertyHelper<bool>? _suspendedEditing;
|
||||
private ObservableAsPropertyHelper<bool>? _isSuspended;
|
||||
private ObservableAsPropertyHelper<ProfileConfiguration?>? _profileConfiguration;
|
||||
private ObservableAsPropertyHelper<RenderProfileElement?>? _profileElement;
|
||||
|
||||
public MenuBarViewModel(IProfileEditorService profileEditorService, IProfileService profileService, ISettingsService settingsService)
|
||||
public MenuBarViewModel(ILogger logger, IProfileEditorService profileEditorService, IProfileService profileService, ISettingsService settingsService, IWindowService windowService)
|
||||
{
|
||||
_logger = logger;
|
||||
_profileEditorService = profileEditorService;
|
||||
_profileService = profileService;
|
||||
_settingsService = settingsService;
|
||||
_windowService = windowService;
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
profileEditorService.History.Subscribe(history => History = history).DisposeWith(d);
|
||||
_profileConfiguration = profileEditorService.ProfileConfiguration.ToProperty(this, vm => vm.ProfileConfiguration).DisposeWith(d);
|
||||
_profileElement = profileEditorService.ProfileElement.ToProperty(this, vm => vm.ProfileElement).DisposeWith(d);
|
||||
_suspendedEditing = profileEditorService.SuspendedEditing.ToProperty(this, vm => vm.SuspendedEditing).DisposeWith(d);
|
||||
_isSuspended = profileEditorService.ProfileConfiguration
|
||||
.Select(p => p?.WhenAnyValue(c => c.IsSuspended) ?? Observable.Never<bool>())
|
||||
.Switch()
|
||||
@ -33,17 +52,35 @@ public class MenuBarViewModel : ActivatableViewModelBase
|
||||
.DisposeWith(d);
|
||||
});
|
||||
|
||||
AddFolder = ReactiveCommand.Create(ExecuteAddFolder);
|
||||
AddLayer = ReactiveCommand.Create(ExecuteAddLayer);
|
||||
ViewProperties = ReactiveCommand.CreateFromTask(ExecuteViewProperties, this.WhenAnyValue(vm => vm.ProfileConfiguration).Select(c => c != null));
|
||||
ToggleSuspended = ReactiveCommand.Create(ExecuteToggleSuspended, this.WhenAnyValue(vm => vm.ProfileConfiguration).Select(c => c != null));
|
||||
DeleteProfile = ReactiveCommand.CreateFromTask(ExecuteDeleteProfile, this.WhenAnyValue(vm => vm.ProfileConfiguration).Select(c => c != null));
|
||||
ExportProfile = ReactiveCommand.CreateFromTask(ExecuteExportProfile, this.WhenAnyValue(vm => vm.ProfileConfiguration).Select(c => c != null));
|
||||
DuplicateProfile = ReactiveCommand.Create(ExecuteDuplicateProfile, this.WhenAnyValue(vm => vm.ProfileConfiguration).Select(c => c != null));
|
||||
ToggleSuspendedEditing = ReactiveCommand.Create(ExecuteToggleSuspendedEditing);
|
||||
ToggleBooleanSetting = ReactiveCommand.Create<PluginSetting<bool>>(ExecuteToggleBooleanSetting);
|
||||
OpenUri = ReactiveCommand.CreateFromTask<string>(ExecuteOpenUri);
|
||||
}
|
||||
|
||||
private void ExecuteToggleBooleanSetting(PluginSetting<bool> setting)
|
||||
{
|
||||
setting.Value = !setting.Value;
|
||||
setting.Save();
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> AddFolder { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddLayer { get; }
|
||||
public ReactiveCommand<Unit, Unit> ToggleSuspended { get; }
|
||||
public ReactiveCommand<Unit, Unit> ViewProperties { get; }
|
||||
public ReactiveCommand<Unit, Unit> DeleteProfile { get; }
|
||||
public ReactiveCommand<Unit, Unit> ExportProfile { get; }
|
||||
public ReactiveCommand<Unit, Unit> DuplicateProfile { get; }
|
||||
public ReactiveCommand<PluginSetting<bool>, Unit> ToggleBooleanSetting { get; }
|
||||
public ReactiveCommand<string, Unit> OpenUri { get; }
|
||||
public ReactiveCommand<Unit, Unit> ToggleSuspendedEditing { get; }
|
||||
|
||||
public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value;
|
||||
public RenderProfileElement? ProfileElement => _profileElement?.Value;
|
||||
public bool IsSuspended => _isSuspended?.Value ?? false;
|
||||
public bool SuspendedEditing => _suspendedEditing?.Value ?? false;
|
||||
|
||||
public PluginSetting<bool> AutoSuspend => _settingsService.GetSetting("ProfileEditor.AutoSuspend", true);
|
||||
public PluginSetting<bool> FocusSelectedLayer => _settingsService.GetSetting("ProfileEditor.FocusSelectedLayer", false);
|
||||
public PluginSetting<bool> ShowDataModelValues => _settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
|
||||
public PluginSetting<bool> ShowFullPaths => _settingsService.GetSetting("ProfileEditor.ShowFullPaths", false);
|
||||
@ -56,16 +93,113 @@ public class MenuBarViewModel : ActivatableViewModelBase
|
||||
set => RaiseAndSetIfChanged(ref _history, value);
|
||||
}
|
||||
|
||||
public bool IsSuspended
|
||||
private void ExecuteAddFolder()
|
||||
{
|
||||
get => _isSuspended?.Value ?? false;
|
||||
set
|
||||
if (ProfileConfiguration?.Profile == null)
|
||||
return;
|
||||
|
||||
RenderProfileElement target = ProfileElement ?? ProfileConfiguration.Profile.GetRootFolder();
|
||||
_profileEditorService.CreateAndAddFolder(target);
|
||||
}
|
||||
|
||||
private void ExecuteAddLayer()
|
||||
{
|
||||
if (ProfileConfiguration?.Profile == null)
|
||||
return;
|
||||
|
||||
RenderProfileElement target = ProfileElement ?? ProfileConfiguration.Profile.GetRootFolder();
|
||||
_profileEditorService.CreateAndAddLayer(target);
|
||||
}
|
||||
|
||||
private async Task ExecuteViewProperties()
|
||||
{
|
||||
if (ProfileConfiguration == null)
|
||||
return;
|
||||
|
||||
ProfileConfiguration.IsSuspended = value;
|
||||
await _windowService.ShowDialogAsync<ProfileConfigurationEditViewModel, ProfileConfiguration?>(
|
||||
("profileCategory", ProfileConfiguration.Category),
|
||||
("profileConfiguration", ProfileConfiguration)
|
||||
);
|
||||
}
|
||||
|
||||
private void ExecuteToggleSuspended()
|
||||
{
|
||||
if (ProfileConfiguration == null)
|
||||
return;
|
||||
|
||||
ProfileConfiguration.IsSuspended = !ProfileConfiguration.IsSuspended;
|
||||
_profileService.SaveProfileCategory(ProfileConfiguration.Category);
|
||||
}
|
||||
|
||||
private async Task ExecuteDeleteProfile()
|
||||
{
|
||||
if (ProfileConfiguration == null)
|
||||
return;
|
||||
if (!await _windowService.ShowConfirmContentDialog("Delete profile", "Are you sure you want to permanently delete this profile?"))
|
||||
return;
|
||||
|
||||
if (ProfileConfiguration.IsBeingEdited)
|
||||
_profileEditorService.ChangeCurrentProfileConfiguration(null);
|
||||
_profileService.RemoveProfileConfiguration(ProfileConfiguration);
|
||||
}
|
||||
|
||||
private async Task ExecuteExportProfile()
|
||||
{
|
||||
if (ProfileConfiguration == null)
|
||||
return;
|
||||
|
||||
// Might not cover everything but then the dialog will complain and that's good enough
|
||||
string fileName = Path.GetInvalidFileNameChars().Aggregate(ProfileConfiguration.Name, (current, c) => current.Replace(c, '-'));
|
||||
string? result = await _windowService.CreateSaveFileDialog()
|
||||
.HavingFilter(f => f.WithExtension("json").WithName("Artemis profile"))
|
||||
.WithInitialFileName(fileName)
|
||||
.ShowAsync();
|
||||
|
||||
if (result == null)
|
||||
return;
|
||||
|
||||
ProfileConfigurationExportModel export = _profileService.ExportProfile(ProfileConfiguration);
|
||||
string json = JsonConvert.SerializeObject(export, IProfileService.ExportSettings);
|
||||
try
|
||||
{
|
||||
await File.WriteAllTextAsync(result, json);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_windowService.ShowExceptionDialog("Failed to export profile", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteDuplicateProfile()
|
||||
{
|
||||
if (ProfileConfiguration == null)
|
||||
return;
|
||||
|
||||
ProfileConfigurationExportModel export = _profileService.ExportProfile(ProfileConfiguration);
|
||||
_profileService.ImportProfile(ProfileConfiguration.Category, export, true, false, "copy");
|
||||
}
|
||||
|
||||
private void ExecuteToggleSuspendedEditing()
|
||||
{
|
||||
_profileEditorService.ChangeSuspendedEditing(!SuspendedEditing);
|
||||
}
|
||||
|
||||
private void ExecuteToggleBooleanSetting(PluginSetting<bool> setting)
|
||||
{
|
||||
setting.Value = !setting.Value;
|
||||
setting.Save();
|
||||
}
|
||||
|
||||
private async Task ExecuteOpenUri(string uri)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(uri) {UseShellExecute = true, Verb = "open"});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(e, "Failed to open URL");
|
||||
await _windowService.ShowConfirmContentDialog("Failed to open URL", "We couldn't open the URL for you, check the logs for more details", "Confirm", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Playback
|
||||
{
|
||||
public partial class PlaybackView : ReactiveUserControl<PlaybackViewModel>
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Playback;
|
||||
|
||||
public class PlaybackView : ReactiveUserControl<PlaybackViewModel>
|
||||
{
|
||||
public PlaybackView()
|
||||
{
|
||||
@ -15,4 +15,3 @@ namespace Artemis.UI.Screens.ProfileEditor.Playback
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,14 +14,14 @@ public class PlaybackViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private RenderProfileElement? _profileElement;
|
||||
private ObservableAsPropertyHelper<TimeSpan>? _currentTime;
|
||||
private ObservableAsPropertyHelper<string?>? _formattedCurrentTime;
|
||||
private ObservableAsPropertyHelper<bool>? _playing;
|
||||
private bool _repeating;
|
||||
private bool _repeatTimeline;
|
||||
private bool _repeatSegment;
|
||||
private DateTime _lastUpdate;
|
||||
private ObservableAsPropertyHelper<bool>? _playing;
|
||||
private RenderProfileElement? _profileElement;
|
||||
private bool _repeating;
|
||||
private bool _repeatSegment;
|
||||
private bool _repeatTimeline;
|
||||
|
||||
public PlaybackViewModel(IProfileEditorService profileEditorService, ISettingsService settingsService)
|
||||
{
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.UI.Extensions;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
@ -14,21 +13,14 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree;
|
||||
|
||||
public class FolderTreeItemViewModel : TreeItemViewModel
|
||||
{
|
||||
public FolderTreeItemViewModel(TreeItemViewModel? parent,
|
||||
Folder folder,
|
||||
IWindowService windowService,
|
||||
IProfileEditorService profileEditorService,
|
||||
ILayerBrushService layerBrushService,
|
||||
IProfileEditorVmFactory profileEditorVmFactory,
|
||||
IRgbService rgbService)
|
||||
: base(parent, folder, windowService, profileEditorService, rgbService, layerBrushService, profileEditorVmFactory)
|
||||
public FolderTreeItemViewModel(TreeItemViewModel? parent, Folder folder, IWindowService windowService, IProfileEditorService profileEditorService, IProfileEditorVmFactory profileEditorVmFactory)
|
||||
: base(parent, folder, windowService, profileEditorService, profileEditorVmFactory)
|
||||
{
|
||||
Folder = folder;
|
||||
}
|
||||
|
||||
public Folder Folder { get; }
|
||||
|
||||
|
||||
#region Overrides of TreeItemViewModel
|
||||
|
||||
protected override async Task ExecuteDuplicate()
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.UI.Extensions;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
@ -14,14 +13,8 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree;
|
||||
|
||||
public class LayerTreeItemViewModel : TreeItemViewModel
|
||||
{
|
||||
public LayerTreeItemViewModel(TreeItemViewModel? parent,
|
||||
Layer layer,
|
||||
IWindowService windowService,
|
||||
IProfileEditorService profileEditorService,
|
||||
IRgbService rgbService,
|
||||
ILayerBrushService layerBrushService,
|
||||
IProfileEditorVmFactory profileEditorVmFactory)
|
||||
: base(parent, layer, windowService, profileEditorService, rgbService, layerBrushService, profileEditorVmFactory)
|
||||
public LayerTreeItemViewModel(TreeItemViewModel? parent, Layer layer, IWindowService windowService, IProfileEditorService profileEditorService, IProfileEditorVmFactory profileEditorVmFactory)
|
||||
: base(parent, layer, windowService, profileEditorService, profileEditorVmFactory)
|
||||
{
|
||||
Layer = layer;
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
@ -18,12 +17,8 @@ public class ProfileTreeViewModel : TreeItemViewModel
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private TreeItemViewModel? _selectedChild;
|
||||
|
||||
public ProfileTreeViewModel(IWindowService windowService,
|
||||
IProfileEditorService profileEditorService,
|
||||
ILayerBrushService layerBrushService,
|
||||
IProfileEditorVmFactory profileEditorVmFactory,
|
||||
IRgbService rgbService)
|
||||
: base(null, null, windowService, profileEditorService, rgbService, layerBrushService, profileEditorVmFactory)
|
||||
public ProfileTreeViewModel(IWindowService windowService, IProfileEditorService profileEditorService, IProfileEditorVmFactory profileEditorVmFactory)
|
||||
: base(null, null, windowService, profileEditorService, profileEditorVmFactory)
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
this.WhenActivated(d =>
|
||||
|
||||
@ -7,7 +7,6 @@ using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Extensions;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Shared;
|
||||
@ -21,9 +20,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree;
|
||||
|
||||
public abstract class TreeItemViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly ILayerBrushService _layerBrushService;
|
||||
private readonly IProfileEditorVmFactory _profileEditorVmFactory;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly IWindowService _windowService;
|
||||
protected readonly IProfileEditorService ProfileEditorService;
|
||||
private bool _canPaste;
|
||||
@ -34,16 +31,13 @@ public abstract class TreeItemViewModel : ActivatableViewModelBase
|
||||
private string? _renameValue;
|
||||
private bool _renaming;
|
||||
|
||||
protected TreeItemViewModel(TreeItemViewModel? parent, ProfileElement? profileElement,
|
||||
protected TreeItemViewModel(TreeItemViewModel? parent,
|
||||
ProfileElement? profileElement,
|
||||
IWindowService windowService,
|
||||
IProfileEditorService profileEditorService,
|
||||
IRgbService rgbService,
|
||||
ILayerBrushService layerBrushService,
|
||||
IProfileEditorVmFactory profileEditorVmFactory)
|
||||
{
|
||||
ProfileEditorService = profileEditorService;
|
||||
_rgbService = rgbService;
|
||||
_layerBrushService = layerBrushService;
|
||||
_windowService = windowService;
|
||||
_profileEditorVmFactory = profileEditorVmFactory;
|
||||
|
||||
@ -126,7 +120,8 @@ public abstract class TreeItemViewModel : ActivatableViewModelBase
|
||||
foreach (IBreakableModel current in broken)
|
||||
{
|
||||
_windowService.ShowExceptionDialog($"{current.BrokenDisplayName} - {current.BrokenState}", current.BrokenStateException!);
|
||||
if (broken.Last() != current)
|
||||
if (broken.Last() == current)
|
||||
continue;
|
||||
if (!await _windowService.ShowConfirmContentDialog("Broken state", "Do you want to view the next exception?"))
|
||||
return;
|
||||
}
|
||||
@ -243,30 +238,14 @@ public abstract class TreeItemViewModel : ActivatableViewModelBase
|
||||
|
||||
private void ExecuteAddFolder()
|
||||
{
|
||||
if (ProfileElement is Layer targetLayer)
|
||||
ProfileEditorService.ExecuteCommand(new AddProfileElement(new Folder(targetLayer.Parent, targetLayer.Parent.GetNewFolderName()), targetLayer.Parent, targetLayer.Order));
|
||||
else if (ProfileElement != null)
|
||||
ProfileEditorService.ExecuteCommand(new AddProfileElement(new Folder(ProfileElement, ProfileElement.GetNewFolderName()), ProfileElement, 0));
|
||||
if (ProfileElement != null)
|
||||
ProfileEditorService.CreateAndAddFolder(ProfileElement);
|
||||
}
|
||||
|
||||
private void ExecuteAddLayer()
|
||||
{
|
||||
if (ProfileElement is Layer targetLayer)
|
||||
{
|
||||
Layer layer = new(targetLayer.Parent, targetLayer.GetNewLayerName());
|
||||
_layerBrushService.ApplyDefaultBrush(layer);
|
||||
|
||||
layer.AddLeds(_rgbService.EnabledDevices.SelectMany(d => d.Leds));
|
||||
ProfileEditorService.ExecuteCommand(new AddProfileElement(layer, targetLayer.Parent, targetLayer.Order));
|
||||
}
|
||||
else if (ProfileElement != null)
|
||||
{
|
||||
Layer layer = new(ProfileElement, ProfileElement.GetNewLayerName());
|
||||
_layerBrushService.ApplyDefaultBrush(layer);
|
||||
|
||||
layer.AddLeds(_rgbService.EnabledDevices.SelectMany(d => d.Leds));
|
||||
ProfileEditorService.ExecuteCommand(new AddProfileElement(layer, ProfileElement, 0));
|
||||
}
|
||||
if (ProfileElement != null)
|
||||
ProfileEditorService.CreateAndAddLayer(ProfileElement);
|
||||
}
|
||||
|
||||
private async void UpdateCanPaste(bool isFlyoutOpen)
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
HorizontalAlignment="Right"
|
||||
Margin="10"
|
||||
Command="{Binding OpenEditor}">
|
||||
<avalonia:MaterialIcon Kind="OpenInNew"></avalonia:MaterialIcon>
|
||||
<avalonia:MaterialIcon Kind="OpenInNew" />
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.DataBinding
|
||||
{
|
||||
public partial class DataBindingView : ReactiveUserControl<DataBindingViewModel>
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.DataBinding;
|
||||
|
||||
public class DataBindingView : ReactiveUserControl<DataBindingViewModel>
|
||||
{
|
||||
public DataBindingView()
|
||||
{
|
||||
@ -15,4 +15,3 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.DataBinding
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
x:DataType="dialogs:AddEffectViewModel"
|
||||
Width="500">
|
||||
<Grid RowDefinitions="Auto,*">
|
||||
<TextBox Name="SearchBox" Text="{CompiledBinding SearchText}" Margin="0 0 0 15" Watermark="Search"></TextBox>
|
||||
<TextBox Name="SearchBox" Text="{CompiledBinding SearchText}" Margin="0 0 0 15" Watermark="Search" />
|
||||
<ListBox Name="EffectDescriptorsList"
|
||||
Grid.Row="1"
|
||||
Items="{CompiledBinding LayerEffectDescriptors}"
|
||||
@ -55,7 +55,7 @@
|
||||
<StackPanel VerticalAlignment="Center"
|
||||
Spacing="20"
|
||||
IsVisible="{CompiledBinding !LayerEffectDescriptors.Count}">
|
||||
<avalonia:MaterialIcon Kind="CloseCircle" Width="32" Height="32"></avalonia:MaterialIcon>
|
||||
<avalonia:MaterialIcon Kind="CloseCircle" Width="32" Height="32" />
|
||||
<TextBlock Classes="h5" TextAlignment="Center">None of the effects match your search</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
@ -14,8 +14,8 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Dialogs;
|
||||
|
||||
public class AddEffectViewModel : ContentDialogViewModelBase
|
||||
{
|
||||
private readonly RenderProfileElement _renderProfileElement;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly RenderProfileElement _renderProfileElement;
|
||||
private string? _searchText;
|
||||
|
||||
public AddEffectViewModel(RenderProfileElement renderProfileElement, IProfileEditorService profileEditorService, ILayerEffectService layerEffectService)
|
||||
@ -39,7 +39,7 @@ public class AddEffectViewModel : ContentDialogViewModelBase
|
||||
public string? SearchText
|
||||
{
|
||||
get => _searchText;
|
||||
set => this.RaiseAndSetIfChanged(ref _searchText, value);
|
||||
set => RaiseAndSetIfChanged(ref _searchText, value);
|
||||
}
|
||||
|
||||
public void AddLayerEffect(LayerEffectDescriptor descriptor)
|
||||
@ -59,4 +59,3 @@ public class AddEffectViewModel : ContentDialogViewModelBase
|
||||
data.Description.Contains(search, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
xmlns:controls="clr-namespace:Artemis.UI.Controls"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.ProfileEditor.Properties"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="350"
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.Properties.PropertiesView"
|
||||
x:DataType="local:PropertiesViewModel">
|
||||
@ -13,7 +12,7 @@
|
||||
<StyleInclude Source="/Screens/ProfileEditor/Panels/Properties/Timeline/Segments/Segment.axaml" />
|
||||
</UserControl.Styles>
|
||||
<UserControl.Resources>
|
||||
<converters:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter"></converters:DoubleToGridLengthConverter>
|
||||
<converters:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid Name="ContainerGrid">
|
||||
<Grid.ColumnDefinitions>
|
||||
@ -89,8 +88,7 @@
|
||||
StartPoint="0,0"
|
||||
EndPoint="{CompiledBinding #ContainerGrid.Bounds.BottomLeft}"
|
||||
StrokeThickness="2"
|
||||
Stroke="{DynamicResource SystemAccentColorLight1}">
|
||||
</Line>
|
||||
Stroke="{DynamicResource SystemAccentColorLight1}" />
|
||||
|
||||
<Line Name="StartSegmentLine"
|
||||
Canvas.Left="{CompiledBinding TimelineViewModel.StartSegmentViewModel.EndX}"
|
||||
@ -100,8 +98,7 @@
|
||||
StrokeThickness="2"
|
||||
Stroke="{DynamicResource SystemAccentColorLight1}"
|
||||
StrokeDashArray="6,2"
|
||||
Opacity="0.5">
|
||||
</Line>
|
||||
Opacity="0.5" />
|
||||
<Line Name="MainSegmentLine"
|
||||
Canvas.Left="{CompiledBinding TimelineViewModel.MainSegmentViewModel.EndX}"
|
||||
IsVisible="{CompiledBinding !TimelineViewModel.MainSegmentViewModel.ShowAddMain}"
|
||||
@ -110,8 +107,7 @@
|
||||
StrokeThickness="2"
|
||||
Stroke="{DynamicResource SystemAccentColorLight1}"
|
||||
StrokeDashArray="6,2"
|
||||
Opacity="0.5">
|
||||
</Line>
|
||||
Opacity="0.5" />
|
||||
<Line Name="EndSegmentLine"
|
||||
Canvas.Left="{CompiledBinding TimelineViewModel.EndSegmentViewModel.EndX}"
|
||||
IsVisible="{CompiledBinding !TimelineViewModel.MainSegmentViewModel.ShowAddEnd}"
|
||||
@ -120,8 +116,7 @@
|
||||
StrokeThickness="2"
|
||||
Stroke="{DynamicResource SystemAccentColorLight1}"
|
||||
StrokeDashArray="6,2"
|
||||
Opacity="0.5">
|
||||
</Line>
|
||||
Opacity="0.5" />
|
||||
|
||||
<!-- Timeline segments -->
|
||||
<ContentControl Canvas.Left="{CompiledBinding TimelineViewModel.EndSegmentViewModel.StartX}"
|
||||
@ -142,8 +137,7 @@
|
||||
PointerReleased="TimelineCaret_OnPointerReleased"
|
||||
PointerMoved="TimelineCaret_OnPointerMoved"
|
||||
Points="-8,0 -8,8 0,20, 8,8 8,0"
|
||||
Fill="{DynamicResource SystemAccentColorLight1}">
|
||||
</Polygon>
|
||||
Fill="{DynamicResource SystemAccentColorLight1}" />
|
||||
</Canvas>
|
||||
|
||||
<ScrollViewer Grid.Row="1"
|
||||
|
||||
@ -15,10 +15,8 @@ using Artemis.UI.Screens.ProfileEditor.Playback;
|
||||
using Artemis.UI.Screens.ProfileEditor.Properties.DataBinding;
|
||||
using Artemis.UI.Screens.ProfileEditor.Properties.Dialogs;
|
||||
using Artemis.UI.Screens.ProfileEditor.Properties.Timeline;
|
||||
using Artemis.UI.Screens.Sidebar;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Builders;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using ReactiveUI;
|
||||
|
||||
@ -28,11 +26,11 @@ public class PropertiesViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly Dictionary<LayerPropertyGroup, PropertyGroupViewModel> _cachedPropertyViewModels;
|
||||
private readonly IDataBindingVmFactory _dataBindingVmFactory;
|
||||
private readonly IWindowService _windowService;
|
||||
private readonly ILayerEffectService _layerEffectService;
|
||||
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IWindowService _windowService;
|
||||
private DataBindingViewModel? _backgroundDataBindingViewModel;
|
||||
private DataBindingViewModel? _dataBindingViewModel;
|
||||
private ObservableAsPropertyHelper<ILayerProperty?>? _layerProperty;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes
|
||||
{
|
||||
public partial class TimelineEasingView : UserControl
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes;
|
||||
|
||||
public class TimelineEasingView : UserControl
|
||||
{
|
||||
public TimelineEasingView()
|
||||
{
|
||||
@ -15,4 +15,3 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,8 +44,8 @@
|
||||
</Template>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Command" Value="{Binding $parent[UserControl].DataContext.SelectEasingFunction}"></Setter>
|
||||
<Setter Property="CommandParameter" Value="{Binding EasingFunction}"></Setter>
|
||||
<Setter Property="Command" Value="{Binding $parent[UserControl].DataContext.SelectEasingFunction}" />
|
||||
<Setter Property="CommandParameter" Value="{Binding EasingFunction}" />
|
||||
</Style>
|
||||
</MenuItem.Styles>
|
||||
<MenuItem.Icon>
|
||||
|
||||
@ -8,9 +8,9 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes;
|
||||
|
||||
public class TimelineKeyframeView : ReactiveUserControl<ITimelineKeyframeViewModel>
|
||||
{
|
||||
private bool _moved;
|
||||
private TimelinePropertyView? _timelinePropertyView;
|
||||
private TimelineView? _timelineView;
|
||||
private bool _moved;
|
||||
|
||||
public TimelineKeyframeView()
|
||||
{
|
||||
@ -70,7 +70,9 @@ public class TimelineKeyframeView : ReactiveUserControl<ITimelineKeyframeViewMod
|
||||
|
||||
// Select the keyframe if the user didn't move
|
||||
if (!_moved)
|
||||
{
|
||||
ViewModel.Select(e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control));
|
||||
}
|
||||
else
|
||||
{
|
||||
TimeSpan time = ViewModel.GetTimeSpanAtPosition(e.GetPosition(_timelinePropertyView).X);
|
||||
|
||||
@ -15,10 +15,10 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes;
|
||||
public class TimelineKeyframeViewModel<T> : ActivatableViewModelBase, ITimelineKeyframeViewModel
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private ObservableAsPropertyHelper<bool>? _isSelected;
|
||||
private string _timestamp;
|
||||
|
||||
private double _x;
|
||||
private string _timestamp;
|
||||
private ObservableAsPropertyHelper<bool>? _isSelected;
|
||||
|
||||
public TimelineKeyframeViewModel(LayerPropertyKeyframe<T> layerPropertyKeyframe, IProfileEditorService profileEditorService)
|
||||
{
|
||||
@ -56,16 +56,16 @@ public class TimelineKeyframeViewModel<T> : ActivatableViewModelBase, ITimelineK
|
||||
set => RaiseAndSetIfChanged(ref _timestamp, value);
|
||||
}
|
||||
|
||||
public bool IsSelected => _isSelected?.Value ?? false;
|
||||
public TimeSpan Position => LayerPropertyKeyframe.Position;
|
||||
public ILayerPropertyKeyframe Keyframe => LayerPropertyKeyframe;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
X = _pixelsPerSecond * LayerPropertyKeyframe.Position.TotalSeconds;
|
||||
Timestamp = $"{Math.Floor(LayerPropertyKeyframe.Position.TotalSeconds):00}.{LayerPropertyKeyframe.Position.Milliseconds:000}";
|
||||
}
|
||||
|
||||
public bool IsSelected => _isSelected?.Value ?? false;
|
||||
public TimeSpan Position => LayerPropertyKeyframe.Position;
|
||||
public ILayerPropertyKeyframe Keyframe => LayerPropertyKeyframe;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Select(bool expand, bool toggle)
|
||||
{
|
||||
@ -165,4 +165,3 @@ public class TimelineKeyframeViewModel<T> : ActivatableViewModelBase, ITimelineK
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@ -4,9 +4,9 @@ using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments
|
||||
{
|
||||
public partial class EndSegmentView : ReactiveUserControl<EndSegmentViewModel>
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
|
||||
|
||||
public class EndSegmentView : ReactiveUserControl<EndSegmentViewModel>
|
||||
{
|
||||
private readonly Rectangle _keyframeDragAnchor;
|
||||
private double _dragOffset;
|
||||
@ -47,4 +47,3 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments
|
||||
ViewModel.FinishResize(e.GetCurrentPoint(this).Position.X + _dragOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
@ -13,14 +11,14 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
|
||||
public class EndSegmentViewModel : TimelineSegmentViewModel
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private RenderProfileElement? _profileElement;
|
||||
private int _pixelsPerSecond;
|
||||
private TimeSpan _time;
|
||||
private ObservableAsPropertyHelper<double>? _start;
|
||||
private readonly ObservableAsPropertyHelper<double> _width;
|
||||
private ObservableAsPropertyHelper<double>? _end;
|
||||
private ObservableAsPropertyHelper<string?>? _endTimestamp;
|
||||
private readonly ObservableAsPropertyHelper<double> _width;
|
||||
private TimeSpan _initialLength;
|
||||
private int _pixelsPerSecond;
|
||||
private RenderProfileElement? _profileElement;
|
||||
private ObservableAsPropertyHelper<double>? _start;
|
||||
private TimeSpan _time;
|
||||
|
||||
|
||||
public EndSegmentViewModel(IProfileEditorService profileEditorService) : base(profileEditorService)
|
||||
@ -59,6 +57,7 @@ public class EndSegmentViewModel : TimelineSegmentViewModel
|
||||
public override double StartX => _start?.Value ?? 0;
|
||||
public override TimeSpan End => _profileElement?.Timeline.EndSegmentEndPosition ?? TimeSpan.Zero;
|
||||
public override double EndX => _end?.Value ?? 0;
|
||||
|
||||
public override TimeSpan Length
|
||||
{
|
||||
get => _profileElement?.Timeline.EndSegmentLength ?? TimeSpan.Zero;
|
||||
|
||||
@ -4,9 +4,9 @@ using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments
|
||||
{
|
||||
public partial class MainSegmentView : ReactiveUserControl<MainSegmentViewModel>
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
|
||||
|
||||
public class MainSegmentView : ReactiveUserControl<MainSegmentViewModel>
|
||||
{
|
||||
private readonly Rectangle _keyframeDragAnchor;
|
||||
private double _dragOffset;
|
||||
@ -59,4 +59,3 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,11 +6,10 @@
|
||||
</Border>
|
||||
</Design.PreviewWith>
|
||||
|
||||
<Style Selector="ContentControl.segment-content-control">
|
||||
</Style>
|
||||
<Style Selector="ContentControl.segment-content-control" />
|
||||
|
||||
<Style Selector="Border.segment-container">
|
||||
<Setter Property="Height" Value="18"></Setter>
|
||||
<Setter Property="Height" Value="18" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="Rectangle.resize-visual">
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
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:system="clr-namespace:System;assembly=System.Runtime"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:segments="clr-namespace:Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="18"
|
||||
|
||||
@ -4,9 +4,9 @@ using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments
|
||||
{
|
||||
public partial class StartSegmentView : ReactiveUserControl<StartSegmentViewModel>
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
|
||||
|
||||
public class StartSegmentView : ReactiveUserControl<StartSegmentViewModel>
|
||||
{
|
||||
private readonly Rectangle _keyframeDragAnchor;
|
||||
private double _dragOffset;
|
||||
@ -47,4 +47,3 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments
|
||||
ViewModel.FinishResize(e.GetCurrentPoint(this).Position.X + _dragOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
||||
using Avalonia.Controls.Mixins;
|
||||
using Castle.DynamicProxy.Generators;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
|
||||
@ -14,13 +11,13 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
|
||||
public class StartSegmentViewModel : TimelineSegmentViewModel
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private RenderProfileElement? _profileElement;
|
||||
private int _pixelsPerSecond;
|
||||
private TimeSpan _time;
|
||||
private readonly ObservableAsPropertyHelper<double> _width;
|
||||
private ObservableAsPropertyHelper<double>? _end;
|
||||
private ObservableAsPropertyHelper<string?>? _endTimestamp;
|
||||
private readonly ObservableAsPropertyHelper<double> _width;
|
||||
private TimeSpan _initialLength;
|
||||
private int _pixelsPerSecond;
|
||||
private RenderProfileElement? _profileElement;
|
||||
private TimeSpan _time;
|
||||
|
||||
public StartSegmentViewModel(IProfileEditorService profileEditorService) : base(profileEditorService)
|
||||
{
|
||||
@ -52,6 +49,7 @@ public class StartSegmentViewModel : TimelineSegmentViewModel
|
||||
public override double StartX => 0;
|
||||
public override TimeSpan End => _profileElement?.Timeline.StartSegmentEndPosition ?? TimeSpan.Zero;
|
||||
public override double EndX => _end?.Value ?? 0;
|
||||
|
||||
public override TimeSpan Length
|
||||
{
|
||||
get => _profileElement?.Timeline.StartSegmentLength ?? TimeSpan.Zero;
|
||||
|
||||
@ -15,14 +15,14 @@ public abstract class TimelineSegmentViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private static readonly TimeSpan NewSegmentLength = TimeSpan.FromSeconds(2);
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private RenderProfileElement? _profileElement;
|
||||
private TimeSpan _initialLength;
|
||||
private readonly Dictionary<ILayerPropertyKeyframe, TimeSpan> _originalKeyframePositions = new();
|
||||
private int _pixelsPerSecond;
|
||||
private Dictionary<ILayerPropertyKeyframe, TimeSpan> _originalKeyframePositions = new();
|
||||
private RenderProfileElement? _profileElement;
|
||||
private ObservableAsPropertyHelper<bool>? _showAddEnd;
|
||||
private ObservableAsPropertyHelper<bool>? _showAddMain;
|
||||
|
||||
private ObservableAsPropertyHelper<bool>? _showAddStart;
|
||||
private ObservableAsPropertyHelper<bool>? _showAddMain;
|
||||
private ObservableAsPropertyHelper<bool>? _showAddEnd;
|
||||
private TimeSpan _initialLength;
|
||||
|
||||
protected TimelineSegmentViewModel(IProfileEditorService profileEditorService)
|
||||
{
|
||||
@ -136,8 +136,10 @@ public abstract class TimelineSegmentViewModel : ActivatableViewModelBase
|
||||
|
||||
// Delete keyframes in the segment
|
||||
foreach (ILayerPropertyKeyframe layerPropertyKeyframe in keyframes)
|
||||
{
|
||||
if (layerPropertyKeyframe.Position > Start && layerPropertyKeyframe.Position <= End)
|
||||
_profileEditorService.ExecuteCommand(new DeleteKeyframe(layerPropertyKeyframe));
|
||||
}
|
||||
|
||||
// Move keyframes after the segment forwards
|
||||
ShiftKeyframes(keyframes.Where(s => s.Position > End), new TimeSpan(Length.Ticks * -1));
|
||||
|
||||
@ -9,8 +9,6 @@
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.Properties.Timeline.TimelineView"
|
||||
x:DataType="timeline:TimelineViewModel">
|
||||
<UserControl.Resources>
|
||||
<x:Double x:Key="RailsHeight">28</x:Double>
|
||||
<x:Double x:Key="RailsBorderHeight">29</x:Double>
|
||||
</UserControl.Resources>
|
||||
<Grid Background="Transparent" PointerReleased="InputElement_OnPointerReleased" Focusable="True" MinWidth="{Binding MinWidth}">
|
||||
<Grid.KeyBindings>
|
||||
@ -23,7 +21,7 @@
|
||||
</TreeDataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<shared:SelectionRectangle Name="SelectionRectangle" InputElement="{CompiledBinding $parent}" SelectionFinished="SelectionRectangle_OnSelectionFinished"></shared:SelectionRectangle>
|
||||
<shared:SelectionRectangle Name="SelectionRectangle" InputElement="{CompiledBinding $parent}" SelectionFinished="SelectionRectangle_OnSelectionFinished" />
|
||||
</Grid>
|
||||
|
||||
|
||||
|
||||
@ -3,12 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes;
|
||||
using Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
||||
using Avalonia.Controls.Mixins;
|
||||
using ReactiveUI;
|
||||
|
||||
@ -18,9 +16,9 @@ public class TimelineViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private ObservableAsPropertyHelper<double>? _caretPosition;
|
||||
private ObservableAsPropertyHelper<int>? _pixelsPerSecond;
|
||||
private List<ITimelineKeyframeViewModel>? _moveKeyframes;
|
||||
private ObservableAsPropertyHelper<double> _minWidth;
|
||||
private List<ITimelineKeyframeViewModel>? _moveKeyframes;
|
||||
private ObservableAsPropertyHelper<int>? _pixelsPerSecond;
|
||||
|
||||
public TimelineViewModel(ObservableCollection<PropertyGroupViewModel> propertyGroupViewModels,
|
||||
StartSegmentViewModel startSegmentViewModel,
|
||||
@ -142,7 +140,9 @@ public class TimelineViewModel : ActivatableViewModelBase
|
||||
public void DuplicateKeyframes(ITimelineKeyframeViewModel? source = null)
|
||||
{
|
||||
if (source is {IsSelected: false})
|
||||
{
|
||||
source.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
List<ITimelineKeyframeViewModel> keyframes = PropertyGroupViewModels.SelectMany(g => g.GetAllKeyframeViewModels(true)).Where(k => k.IsSelected).ToList();
|
||||
@ -155,7 +155,9 @@ public class TimelineViewModel : ActivatableViewModelBase
|
||||
public void CopyKeyframes(ITimelineKeyframeViewModel? source = null)
|
||||
{
|
||||
if (source is {IsSelected: false})
|
||||
{
|
||||
source.Copy();
|
||||
}
|
||||
else
|
||||
{
|
||||
List<ITimelineKeyframeViewModel> keyframes = PropertyGroupViewModels.SelectMany(g => g.GetAllKeyframeViewModels(true)).Where(k => k.IsSelected).ToList();
|
||||
@ -168,7 +170,9 @@ public class TimelineViewModel : ActivatableViewModelBase
|
||||
public void PasteKeyframes(ITimelineKeyframeViewModel? source = null)
|
||||
{
|
||||
if (source is {IsSelected: false})
|
||||
{
|
||||
source.Paste();
|
||||
}
|
||||
else
|
||||
{
|
||||
List<ITimelineKeyframeViewModel> keyframes = PropertyGroupViewModels.SelectMany(g => g.GetAllKeyframeViewModels(true)).Where(k => k.IsSelected).ToList();
|
||||
@ -181,7 +185,9 @@ public class TimelineViewModel : ActivatableViewModelBase
|
||||
public void DeleteKeyframes(ITimelineKeyframeViewModel? source = null)
|
||||
{
|
||||
if (source is {IsSelected: false})
|
||||
{
|
||||
source.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
List<ITimelineKeyframeViewModel> keyframes = PropertyGroupViewModels.SelectMany(g => g.GetAllKeyframeViewModels(true)).Where(k => k.IsSelected).ToList();
|
||||
|
||||
@ -7,12 +7,12 @@ using FluentAvalonia.UI.Controls;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Validation.Extensions;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree.ContentDialogs
|
||||
{
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree.ContentDialogs;
|
||||
|
||||
public class LayerEffectRenameViewModel : ContentDialogViewModelBase
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly BaseLayerEffect _layerEffect;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private string? _layerEffectName;
|
||||
|
||||
public LayerEffectRenameViewModel(IProfileEditorService profileEditorService, BaseLayerEffect layerEffect)
|
||||
@ -28,7 +28,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree.ContentDialogs
|
||||
public string? LayerEffectName
|
||||
{
|
||||
get => _layerEffectName;
|
||||
set => this.RaiseAndSetIfChanged(ref _layerEffectName, value);
|
||||
set => RaiseAndSetIfChanged(ref _layerEffectName, value);
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> Confirm { get; }
|
||||
@ -42,4 +42,3 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree.ContentDialogs
|
||||
ContentDialog?.Hide(ContentDialogResult.Primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
using System.Reactive;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree;
|
||||
|
||||
@ -63,6 +63,19 @@ public class TreeGroupViewModel : ActivatableViewModelBase
|
||||
public ReactiveCommand<Unit, Unit> RenameEffect { get; }
|
||||
public ReactiveCommand<Unit, Unit> DeleteEffect { get; }
|
||||
|
||||
public double GetDepth()
|
||||
{
|
||||
int depth = 0;
|
||||
LayerPropertyGroup? current = LayerPropertyGroup.Parent;
|
||||
while (current != null)
|
||||
{
|
||||
depth++;
|
||||
current = current.Parent;
|
||||
}
|
||||
|
||||
return depth;
|
||||
}
|
||||
|
||||
private async Task ExecuteOpenBrushSettings()
|
||||
{
|
||||
if (LayerBrush?.ConfigurationDialog is not LayerBrushConfigurationDialog configurationViewModel)
|
||||
@ -145,19 +158,6 @@ public class TreeGroupViewModel : ActivatableViewModelBase
|
||||
_profileEditorService.ExecuteCommand(new RemoveLayerEffect(LayerEffect));
|
||||
}
|
||||
|
||||
public double GetDepth()
|
||||
{
|
||||
int depth = 0;
|
||||
LayerPropertyGroup? current = LayerPropertyGroup.Parent;
|
||||
while (current != null)
|
||||
{
|
||||
depth++;
|
||||
current = current.Parent;
|
||||
}
|
||||
|
||||
return depth;
|
||||
}
|
||||
|
||||
private void CloseViewModels()
|
||||
{
|
||||
_effectConfigurationWindowViewModel?.Close(null);
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
xmlns:sharedConverters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
|
||||
xmlns:tree="clr-namespace:Artemis.UI.Screens.ProfileEditor.Properties.Tree"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.Properties.Tree.TreePropertyView"
|
||||
|
||||
@ -15,9 +15,9 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree;
|
||||
internal class TreePropertyViewModel<T> : ActivatableViewModelBase, ITreePropertyViewModel
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private TimeSpan _time;
|
||||
private ObservableAsPropertyHelper<bool>? _isCurrentlySelected;
|
||||
private ObservableAsPropertyHelper<bool>? _dataBindingEnabled;
|
||||
private ObservableAsPropertyHelper<bool>? _isCurrentlySelected;
|
||||
private TimeSpan _time;
|
||||
|
||||
public TreePropertyViewModel(LayerProperty<T> layerProperty, PropertyViewModel propertyViewModel, IProfileEditorService profileEditorService, IPropertyInputService propertyInputService)
|
||||
{
|
||||
@ -40,7 +40,6 @@ internal class TreePropertyViewModel<T> : ActivatableViewModelBase, ITreePropert
|
||||
}
|
||||
|
||||
public bool IsCurrentlySelected => _isCurrentlySelected?.Value ?? false;
|
||||
public bool DataBindingEnabled => _dataBindingEnabled?.Value ?? false;
|
||||
public LayerProperty<T> LayerProperty { get; }
|
||||
public PropertyViewModel PropertyViewModel { get; }
|
||||
public PropertyInputViewModel<T>? PropertyInputViewModel { get; }
|
||||
@ -65,6 +64,8 @@ internal class TreePropertyViewModel<T> : ActivatableViewModelBase, ITreePropert
|
||||
_profileEditorService.ExecuteCommand(new ResetLayerProperty<T>(LayerProperty));
|
||||
}
|
||||
|
||||
public bool DataBindingEnabled => _dataBindingEnabled?.Value ?? false;
|
||||
|
||||
public ILayerProperty BaseLayerProperty => LayerProperty;
|
||||
|
||||
public double GetDepth()
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.LayerBrushes;
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Windows;
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.LayerEffects;
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Windows;
|
||||
|
||||
|
||||
@ -8,13 +8,13 @@
|
||||
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="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1 0 0 0" />
|
||||
<Setter Property="Margin" Value="5 2 0 2" />
|
||||
<Setter Property="Transitions">
|
||||
<Setter.Value>
|
||||
<Transitions>
|
||||
<DoubleTransition Property="Opacity" Duration="0.2"></DoubleTransition>
|
||||
<DoubleTransition Property="Opacity" Duration="0.2" />
|
||||
</Transitions>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.StatusBar
|
||||
{
|
||||
public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
|
||||
namespace Artemis.UI.Screens.ProfileEditor.StatusBar;
|
||||
|
||||
public class StatusBarView : ReactiveUserControl<StatusBarViewModel>
|
||||
{
|
||||
public StatusBarView()
|
||||
{
|
||||
@ -15,4 +15,3 @@ namespace Artemis.UI.Screens.ProfileEditor.StatusBar
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
SelectionFinished="SelectionRectangle_OnSelectionFinished"
|
||||
ZoomRatio="{Binding $parent[ZoomBorder].ZoomX}">
|
||||
<shared:SelectionRectangle.Background>
|
||||
<SolidColorBrush Color="{DynamicResource SystemAccentColorLight1}" Opacity="0.2"></SolidColorBrush>
|
||||
<SolidColorBrush Color="{DynamicResource SystemAccentColorLight1}" Opacity="0.2" />
|
||||
</shared:SelectionRectangle.Background>
|
||||
</shared:SelectionRectangle>
|
||||
</Grid>
|
||||
|
||||
@ -15,9 +15,9 @@ namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Tools;
|
||||
|
||||
public class SelectionAddToolViewModel : ToolViewModel
|
||||
{
|
||||
private readonly ObservableAsPropertyHelper<bool>? _isEnabled;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly ObservableAsPropertyHelper<bool>? _isEnabled;
|
||||
private Layer? _layer;
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -49,15 +49,6 @@ public class SelectionAddToolViewModel : ToolViewModel
|
||||
/// <inheritdoc />
|
||||
public override string ToolTip => "Add LEDs to the current layer";
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
_isEnabled?.Dispose();
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public void AddLedsInRectangle(SKRect rect, bool expand, bool inverse)
|
||||
{
|
||||
if (_layer == null)
|
||||
@ -80,4 +71,13 @@ public class SelectionAddToolViewModel : ToolViewModel
|
||||
_profileEditorService.ExecuteCommand(new ChangeLayerLeds(_layer, leds.Distinct().ToList()));
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
_isEnabled?.Dispose();
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
@ -15,7 +15,7 @@
|
||||
SelectionFinished="SelectionRectangle_OnSelectionFinished"
|
||||
ZoomRatio="{Binding $parent[ZoomBorder].ZoomX}">
|
||||
<shared:SelectionRectangle.Background>
|
||||
<SolidColorBrush Color="{DynamicResource SystemAccentColorLight1}" Opacity="0.2"></SolidColorBrush>
|
||||
<SolidColorBrush Color="{DynamicResource SystemAccentColorLight1}" Opacity="0.2" />
|
||||
</shared:SelectionRectangle.Background>
|
||||
</shared:SelectionRectangle>
|
||||
</Grid>
|
||||
|
||||
@ -79,7 +79,7 @@
|
||||
Canvas.Top="{CompiledBinding ShapeBounds.Top}"
|
||||
RenderTransformOrigin="{CompiledBinding RelativeAnchor}">
|
||||
<Border.RenderTransform>
|
||||
<RotateTransform Angle="{CompiledBinding Rotation}"></RotateTransform>
|
||||
<RotateTransform Angle="{CompiledBinding Rotation}" />
|
||||
</Border.RenderTransform>
|
||||
<Grid Name="HandleGrid">
|
||||
<!-- Render these first so that they are always behind the actual shape -->
|
||||
|
||||
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Extensions;
|
||||
using Artemis.UI.Shared.Providers;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Mixins;
|
||||
@ -24,6 +23,7 @@ namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Tools;
|
||||
|
||||
public class TransformToolView : ReactiveUserControl<TransformToolViewModel>
|
||||
{
|
||||
private readonly Grid _handleGrid;
|
||||
private readonly List<Control> _handles = new();
|
||||
private readonly Panel _resizeBottomCenter;
|
||||
private readonly Panel _resizeBottomLeft;
|
||||
@ -36,7 +36,6 @@ public class TransformToolView : ReactiveUserControl<TransformToolViewModel>
|
||||
|
||||
private SKPoint _dragOffset;
|
||||
private ZoomBorder? _zoomBorder;
|
||||
private readonly Grid _handleGrid;
|
||||
|
||||
public TransformToolView()
|
||||
{
|
||||
|
||||
@ -185,8 +185,8 @@ public class TransformToolViewModel : ToolViewModel
|
||||
// Get a normalized point
|
||||
SKPoint scaled = Layer.GetNormalizedPoint(position, true);
|
||||
// Compensate for the anchor
|
||||
scaled.X += ((Layer.Transform.AnchorPoint.CurrentValue.X) * (Layer.Transform.Scale.CurrentValue.Width/100f));
|
||||
scaled.Y += ((Layer.Transform.AnchorPoint.CurrentValue.Y) * (Layer.Transform.Scale.CurrentValue.Height/100f));
|
||||
scaled.X += Layer.Transform.AnchorPoint.CurrentValue.X * (Layer.Transform.Scale.CurrentValue.Width / 100f);
|
||||
scaled.Y += Layer.Transform.AnchorPoint.CurrentValue.Y * (Layer.Transform.Scale.CurrentValue.Height / 100f);
|
||||
_movementPreview.Preview(scaled);
|
||||
}
|
||||
|
||||
|
||||
@ -85,14 +85,14 @@
|
||||
</paz:ZoomBorder>
|
||||
<Border CornerRadius="0 0 8 0" VerticalAlignment="Top" HorizontalAlignment="Left">
|
||||
<Border.Background>
|
||||
<SolidColorBrush Color="{DynamicResource CardStrokeColorDefaultSolid}" Opacity="0.65"></SolidColorBrush>
|
||||
<SolidColorBrush Color="{DynamicResource CardStrokeColorDefaultSolid}" Opacity="0.65" />
|
||||
</Border.Background>
|
||||
<StackPanel Orientation="Horizontal" Margin="8">
|
||||
<shared:ProfileConfigurationIcon ConfigurationIcon="{CompiledBinding ProfileConfiguration.Icon}"
|
||||
Foreground="{DynamicResource ToolTipForeground}"
|
||||
Width="18"
|
||||
Height="18"
|
||||
Margin="0 0 5 0"></shared:ProfileConfigurationIcon>
|
||||
Margin="0 0 5 0" />
|
||||
<TextBlock Text="{CompiledBinding ProfileConfiguration.Name}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
@ -5,8 +5,8 @@ using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.VisualEditor
|
||||
{
|
||||
namespace Artemis.UI.Screens.ProfileEditor.VisualEditor;
|
||||
|
||||
public class VisualEditorView : ReactiveUserControl<VisualEditorViewModel>
|
||||
{
|
||||
private readonly ZoomBorder _zoomBorder;
|
||||
@ -42,4 +42,3 @@ namespace Artemis.UI.Screens.ProfileEditor.VisualEditor
|
||||
UpdateZoomBorderBackground();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -13,8 +13,8 @@
|
||||
<Setter Property="Transitions">
|
||||
<Setter.Value>
|
||||
<Transitions>
|
||||
<DoubleTransition Property="StrokeThickness" Duration="0:0:0.2" Easing="CubicEaseOut"></DoubleTransition>
|
||||
<BrushTransition Property="Stroke" Duration="0:0:0.2" Easing="CubicEaseOut"></BrushTransition>
|
||||
<DoubleTransition Property="StrokeThickness" Duration="0:0:0.2" Easing="CubicEaseOut" />
|
||||
<BrushTransition Property="Stroke" Duration="0:0:0.2" Easing="CubicEaseOut" />
|
||||
</Transitions>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
@ -28,7 +28,7 @@
|
||||
<Setter Property="Transitions">
|
||||
<Setter.Value>
|
||||
<Transitions>
|
||||
<DoubleTransition Property="StrokeThickness" Duration="0:0:0.2" Easing="CubicEaseOut"></DoubleTransition>
|
||||
<DoubleTransition Property="StrokeThickness" Duration="0:0:0.2" Easing="CubicEaseOut" />
|
||||
</Transitions>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
@ -43,8 +43,7 @@
|
||||
Classes.layer-visualizer-unbound-selected="{CompiledBinding Selected}"
|
||||
Data="{CompiledBinding ShapeGeometry, Mode=OneWay}"
|
||||
StrokeThickness="4"
|
||||
StrokeJoin="Round">
|
||||
</Path>
|
||||
StrokeJoin="Round" />
|
||||
<Border Name="LayerVisualizerBounds"
|
||||
ClipToBounds="True"
|
||||
Width="{CompiledBinding LayerBounds.Width, Mode=OneWay}"
|
||||
@ -54,8 +53,7 @@
|
||||
Classes.layer-visualizer-selected="{CompiledBinding Selected}"
|
||||
Data="{CompiledBinding ShapeGeometry, Mode=OneWay}"
|
||||
StrokeThickness="4"
|
||||
StrokeJoin="Round">
|
||||
</Path>
|
||||
StrokeJoin="Round" />
|
||||
</Border>
|
||||
</Canvas>
|
||||
|
||||
|
||||
@ -12,11 +12,11 @@ using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers;
|
||||
|
||||
public partial class LayerShapeVisualizerView : ReactiveUserControl<LayerShapeVisualizerViewModel>
|
||||
public class LayerShapeVisualizerView : ReactiveUserControl<LayerShapeVisualizerViewModel>
|
||||
{
|
||||
private ZoomBorder? _zoomBorder;
|
||||
private readonly Path _layerVisualizerUnbound;
|
||||
private readonly Path _layerVisualizer;
|
||||
private readonly Path _layerVisualizerUnbound;
|
||||
private ZoomBorder? _zoomBorder;
|
||||
|
||||
public LayerShapeVisualizerView()
|
||||
{
|
||||
|
||||
@ -15,11 +15,11 @@ namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers;
|
||||
|
||||
public class LayerShapeVisualizerViewModel : ActivatableViewModelBase, IVisualizerViewModel
|
||||
{
|
||||
private ObservableAsPropertyHelper<bool>? _selected;
|
||||
private Rect _layerBounds;
|
||||
private ObservableAsPropertyHelper<bool>? _selected;
|
||||
private Geometry? _shapeGeometry;
|
||||
private double _x;
|
||||
private double _y;
|
||||
private Geometry? _shapeGeometry;
|
||||
|
||||
public LayerShapeVisualizerViewModel(Layer layer, IProfileEditorService profileEditorService)
|
||||
{
|
||||
@ -49,7 +49,6 @@ public class LayerShapeVisualizerViewModel : ActivatableViewModelBase, IVisualiz
|
||||
}
|
||||
|
||||
public Layer Layer { get; }
|
||||
public ProfileElement ProfileElement => Layer;
|
||||
public bool Selected => _selected?.Value ?? false;
|
||||
|
||||
public Rect LayerBounds
|
||||
@ -58,26 +57,12 @@ public class LayerShapeVisualizerViewModel : ActivatableViewModelBase, IVisualiz
|
||||
private set => RaiseAndSetIfChanged(ref _layerBounds, value);
|
||||
}
|
||||
|
||||
public double X
|
||||
{
|
||||
get => _x;
|
||||
set => RaiseAndSetIfChanged(ref _x, value);
|
||||
}
|
||||
|
||||
public double Y
|
||||
{
|
||||
get => _y;
|
||||
set => RaiseAndSetIfChanged(ref _y, value);
|
||||
}
|
||||
|
||||
public Geometry? ShapeGeometry
|
||||
{
|
||||
get => _shapeGeometry;
|
||||
set => RaiseAndSetIfChanged(ref _shapeGeometry, value);
|
||||
}
|
||||
|
||||
public int Order => 2;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateLayerBounds();
|
||||
@ -103,4 +88,20 @@ public class LayerShapeVisualizerViewModel : ActivatableViewModelBase, IVisualiz
|
||||
if (ShapeGeometry != null)
|
||||
ShapeGeometry.Transform = new MatrixTransform(Layer.GetTransformMatrix(false, true, true, true, LayerBounds.ToSKRect()).ToMatrix());
|
||||
}
|
||||
|
||||
public ProfileElement ProfileElement => Layer;
|
||||
|
||||
public double X
|
||||
{
|
||||
get => _x;
|
||||
set => RaiseAndSetIfChanged(ref _x, value);
|
||||
}
|
||||
|
||||
public double Y
|
||||
{
|
||||
get => _y;
|
||||
set => RaiseAndSetIfChanged(ref _y, value);
|
||||
}
|
||||
|
||||
public int Order => 2;
|
||||
}
|
||||
@ -14,7 +14,7 @@
|
||||
<Setter Property="Transitions">
|
||||
<Setter.Value>
|
||||
<Transitions>
|
||||
<DoubleTransition Property="Opacity" Duration="0:0:0.2" Easing="CubicEaseOut"></DoubleTransition>
|
||||
<DoubleTransition Property="Opacity" Duration="0:0:0.2" Easing="CubicEaseOut" />
|
||||
</Transitions>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
@ -31,7 +31,7 @@
|
||||
StrokeDashArray="6,2"
|
||||
StrokeJoin="Round">
|
||||
<Path.Data>
|
||||
<RectangleGeometry Rect="{CompiledBinding LayerBounds}"></RectangleGeometry>
|
||||
<RectangleGeometry Rect="{CompiledBinding LayerBounds}" />
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</UserControl>
|
||||
@ -7,14 +7,13 @@ using Avalonia.Controls.Shapes;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers
|
||||
namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers;
|
||||
|
||||
public class LayerVisualizerView : ReactiveUserControl<LayerVisualizerViewModel>
|
||||
{
|
||||
public partial class LayerVisualizerView : ReactiveUserControl<LayerVisualizerViewModel>
|
||||
{
|
||||
private ZoomBorder? _zoomBorder;
|
||||
private readonly Path _layerVisualizer;
|
||||
private ZoomBorder? _zoomBorder;
|
||||
|
||||
public LayerVisualizerView()
|
||||
{
|
||||
@ -22,6 +21,11 @@ namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers
|
||||
_layerVisualizer = this.Get<Path>("LayerVisualizer");
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
#region Overrides of TemplatedControl
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -49,10 +53,4 @@ namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7,14 +7,14 @@ using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.Mixins;
|
||||
using ReactiveUI;
|
||||
using SKRect = SkiaSharp.SKRect;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers;
|
||||
|
||||
public class LayerVisualizerViewModel : ActivatableViewModelBase, IVisualizerViewModel
|
||||
{
|
||||
private ObservableAsPropertyHelper<bool>? _selected;
|
||||
private Rect _layerBounds;
|
||||
private ObservableAsPropertyHelper<bool>? _selected;
|
||||
private double _x;
|
||||
private double _y;
|
||||
|
||||
@ -36,7 +36,6 @@ public class LayerVisualizerViewModel : ActivatableViewModelBase, IVisualizerVie
|
||||
}
|
||||
|
||||
public Layer Layer { get; }
|
||||
public ProfileElement ProfileElement => Layer;
|
||||
public bool Selected => _selected?.Value ?? false;
|
||||
|
||||
public Rect LayerBounds
|
||||
@ -45,6 +44,16 @@ public class LayerVisualizerViewModel : ActivatableViewModelBase, IVisualizerVie
|
||||
private set => RaiseAndSetIfChanged(ref _layerBounds, value);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
SKRect bounds = Layer.GetLayerBounds();
|
||||
LayerBounds = new Rect(0, 0, bounds.Width, bounds.Height);
|
||||
X = bounds.Left;
|
||||
Y = bounds.Top;
|
||||
}
|
||||
|
||||
public ProfileElement ProfileElement => Layer;
|
||||
|
||||
public double X
|
||||
{
|
||||
get => _x;
|
||||
@ -58,12 +67,4 @@ public class LayerVisualizerViewModel : ActivatableViewModelBase, IVisualizerVie
|
||||
}
|
||||
|
||||
public int Order => 1;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
SKRect bounds = Layer.GetLayerBounds();
|
||||
LayerBounds = new Rect(0, 0, bounds.Width, bounds.Height);
|
||||
X = bounds.Left;
|
||||
Y = bounds.Top;
|
||||
}
|
||||
}
|
||||
@ -6,13 +6,13 @@
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.ProfileEditorTitleBarView">
|
||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||
<ContentControl Grid.Row="0" Grid.Column="0" Content="{Binding MenuBarViewModel}"></ContentControl>
|
||||
<ContentControl Grid.Row="0" Grid.Column="0" Content="{Binding MenuBarViewModel}" />
|
||||
|
||||
<!-- This border enables dragging the window in between the menu and the buttons-->
|
||||
<Border Grid.Row="0" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="Transparent" IsHitTestVisible="False" />
|
||||
|
||||
<Button Grid.Column="2" Classes="title-bar-button" Command="{Binding ShowDebugger}" HorizontalAlignment="Right" VerticalAlignment="Top">
|
||||
<avalonia:MaterialIcon Kind="Bug"></avalonia:MaterialIcon>
|
||||
<avalonia:MaterialIcon Kind="Bug" />
|
||||
</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -1,11 +1,10 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor
|
||||
{
|
||||
public partial class ProfileEditorTitleBarView : UserControl
|
||||
namespace Artemis.UI.Screens.ProfileEditor;
|
||||
|
||||
public class ProfileEditorTitleBarView : UserControl
|
||||
{
|
||||
public ProfileEditorTitleBarView()
|
||||
{
|
||||
@ -21,4 +20,3 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,8 +2,8 @@
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor
|
||||
{
|
||||
namespace Artemis.UI.Screens.ProfileEditor;
|
||||
|
||||
public class ProfileEditorTitleBarViewModel : ViewModelBase
|
||||
{
|
||||
private readonly IDebugService _debugService;
|
||||
@ -21,4 +21,3 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
_debugService.ShowDebugger();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,6 @@
|
||||
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:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
xmlns:profileEditor="clr-namespace:Artemis.UI.Screens.ProfileEditor"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared.Services.ProfileEditor;assembly=Artemis.UI.Shared"
|
||||
@ -11,7 +10,7 @@
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.ProfileEditorView"
|
||||
x:DataType="profileEditor:ProfileEditorViewModel">
|
||||
<UserControl.Resources>
|
||||
<converters:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter"></converters:DoubleToGridLengthConverter>
|
||||
<converters:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter" />
|
||||
</UserControl.Resources>
|
||||
<UserControl.Styles>
|
||||
<Style Selector="Border.suspended-editing">
|
||||
@ -22,10 +21,10 @@
|
||||
</Style>
|
||||
</UserControl.Styles>
|
||||
<UserControl.KeyBindings>
|
||||
<KeyBinding Command="{CompiledBinding History.Undo}" Gesture="Ctrl+Z"></KeyBinding>
|
||||
<KeyBinding Command="{CompiledBinding History.Redo}" Gesture="Ctrl+Y"></KeyBinding>
|
||||
<KeyBinding Command="{CompiledBinding ToggleSuspend}" Gesture="F5"></KeyBinding>
|
||||
<KeyBinding Command="{CompiledBinding ToggleAutoSuspend}" Gesture="Shift+F5"></KeyBinding>
|
||||
<KeyBinding Command="{CompiledBinding History.Undo}" Gesture="Ctrl+Z" />
|
||||
<KeyBinding Command="{CompiledBinding History.Redo}" Gesture="Ctrl+Y" />
|
||||
<KeyBinding Command="{CompiledBinding ToggleSuspend}" Gesture="F5" />
|
||||
<KeyBinding Command="{CompiledBinding ToggleAutoSuspend}" Gesture="Shift+F5" />
|
||||
</UserControl.KeyBindings>
|
||||
<UserControl.Styles>
|
||||
<Style Selector="GridSplitter.editor-grid-splitter-vertical">
|
||||
@ -46,7 +45,7 @@
|
||||
<Setter Property="Height" Value="18" />
|
||||
</Style>
|
||||
<Style Selector="Window:windows Grid.editor-grid">
|
||||
<Setter Property="Margin" Value="0 0 4 4"></Setter>
|
||||
<Setter Property="Margin" Value="0 0 4 4" />
|
||||
</Style>
|
||||
</UserControl.Styles>
|
||||
<Grid Classes="editor-grid">
|
||||
@ -127,7 +126,7 @@
|
||||
|
||||
<Border Grid.Row="2" Classes="card card-condensed" Margin="4">
|
||||
<Panel>
|
||||
<ContentControl Content="{CompiledBinding DisplayConditionScriptViewModel}"></ContentControl>
|
||||
<ContentControl Content="{CompiledBinding DisplayConditionScriptViewModel}" />
|
||||
<Border Classes="suspended-editing" />
|
||||
</Panel>
|
||||
</Border>
|
||||
|
||||
@ -2,8 +2,8 @@ using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor
|
||||
{
|
||||
namespace Artemis.UI.Screens.ProfileEditor;
|
||||
|
||||
public class ProfileEditorView : ReactiveUserControl<ProfileEditorViewModel>
|
||||
{
|
||||
public ProfileEditorView()
|
||||
@ -18,7 +18,5 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
|
||||
private void MenuItem_OnSubmenuOpened(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,5 +97,6 @@ public class ProfileEditorViewModel : MainScreenViewModel
|
||||
|
||||
private void ExecuteToggleAutoSuspend()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
@ -151,18 +151,9 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
if (!await _windowService.ShowConfirmContentDialog("Delete profile", "Are you sure you want to permanently delete this profile?"))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
if (_profileConfiguration.IsBeingEdited)
|
||||
_profileEditorService.ChangeCurrentProfileConfiguration(null);
|
||||
_profileService.RemoveProfileConfiguration(_profileConfiguration);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
|
||||
Close(_profileConfiguration);
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Sidebar"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.Sidebar.SidebarCategoryView">
|
||||
x:Class="Artemis.UI.Screens.Sidebar.SidebarCategoryView"
|
||||
x:DataType="local:SidebarCategoryViewModel">
|
||||
<UserControl.Styles>
|
||||
<Style Selector=":is(Button).category-button">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
@ -26,11 +27,14 @@
|
||||
<Style Selector="Border.fadable.suspended">
|
||||
<Setter Property="Opacity" Value="1" />
|
||||
</Style>
|
||||
<Style Selector=".sidebar-listbox > ListBoxItem">
|
||||
<Setter Property="Padding" Value="6 0"/>
|
||||
</Style>
|
||||
</UserControl.Styles>
|
||||
<Grid x:Name="ContainerGrid" Margin="0 8 0 0" RowDefinitions="Auto,*">
|
||||
<Grid Grid.Row="0" Background="Transparent" ColumnDefinitions="Auto,Auto,*,Auto,Auto,Auto">
|
||||
<Grid Grid.Row="0" Background="Transparent" Margin="0 0 6 0" ColumnDefinitions="Auto,*,Auto,Auto,Auto,Auto">
|
||||
|
||||
<avalonia:MaterialIcon Classes.chevron-collapsed="{Binding ShowItems}"
|
||||
<avalonia:MaterialIcon Classes.chevron-collapsed="{CompiledBinding !IsCollapsed}"
|
||||
Kind="ChevronUp"
|
||||
Grid.Column="0"
|
||||
Margin="5 0"
|
||||
@ -44,13 +48,14 @@
|
||||
</avalonia:MaterialIcon>
|
||||
|
||||
<TextBlock Classes="fadable"
|
||||
Classes.suspended="{Binding IsSuspended}"
|
||||
Classes.suspended="{CompiledBinding IsSuspended}"
|
||||
Grid.Column="1"
|
||||
Padding="0 5"
|
||||
FontWeight="SemiBold"
|
||||
FontSize="13"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding ProfileCategory.Name, FallbackValue='Profile name'}"
|
||||
Text="{CompiledBinding ProfileCategory.Name, FallbackValue='Profile name'}"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
PointerPressed="Title_OnPointerPressed"
|
||||
Background="Transparent">
|
||||
<TextBlock.Transitions>
|
||||
@ -61,7 +66,7 @@
|
||||
</TextBlock>
|
||||
|
||||
<Border Classes="fadable"
|
||||
Classes.suspended="{Binding IsSuspended}"
|
||||
Classes.suspended="{CompiledBinding IsSuspended}"
|
||||
Grid.Column="1"
|
||||
BorderBrush="White"
|
||||
BorderThickness="0.5"
|
||||
@ -77,29 +82,34 @@
|
||||
Grid.Column="2"
|
||||
ToolTip.Tip="Edit category"
|
||||
HorizontalAlignment="Right"
|
||||
Command="{Binding EditCategory}">
|
||||
Command="{CompiledBinding EditCategory}"
|
||||
Margin="0 0 2 0">
|
||||
<avalonia:MaterialIcon Kind="Cog" />
|
||||
</Button>
|
||||
<ToggleButton Classes="category-button icon-button icon-button-small"
|
||||
<Button Classes="icon-button icon-button-small"
|
||||
Command="{CompiledBinding ToggleSuspended}"
|
||||
Grid.Column="3"
|
||||
ToolTip.Tip="Suspend category"
|
||||
Margin="5 0"
|
||||
IsChecked="{Binding IsSuspended}">
|
||||
<avalonia:MaterialIcon Kind="Pause" />
|
||||
</ToggleButton>
|
||||
ToolTip.Tip="Suspend/resume profile"
|
||||
Margin="0 0 2 0">
|
||||
<Panel>
|
||||
<avalonia:MaterialIcon Kind="EyeOff" IsVisible="{CompiledBinding IsSuspended}" />
|
||||
<avalonia:MaterialIcon Kind="Eye" IsVisible="{CompiledBinding !IsSuspended}" />
|
||||
</Panel>
|
||||
</Button>
|
||||
<Button Classes="category-button icon-button icon-button-small"
|
||||
Grid.Column="4"
|
||||
ToolTip.Tip="Add profile"
|
||||
HorizontalAlignment="Right"
|
||||
Command="{Binding AddProfile}">
|
||||
Command="{CompiledBinding AddProfile}"
|
||||
Margin="0 0 2 0">
|
||||
<avalonia:MaterialIcon Kind="Plus" />
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
<Border Grid.Row="1">
|
||||
<ListBox Classes="sidebar-listbox"
|
||||
Items="{Binding ProfileConfigurations}"
|
||||
SelectedItem="{Binding SelectedProfileConfiguration}"
|
||||
Items="{CompiledBinding ProfileConfigurations}"
|
||||
SelectedItem="{CompiledBinding SelectedProfileConfiguration}"
|
||||
MinHeight="10"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled">
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Avalonia.Input;
|
||||
using System;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
@ -18,8 +19,7 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
|
||||
private void Title_OnPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (ViewModel != null)
|
||||
ViewModel.ShowItems = !ViewModel.ShowItems;
|
||||
ViewModel?.ToggleCollapsed.Execute().Subscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Builders;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using DynamicData;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Sidebar
|
||||
@ -21,6 +25,8 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
private readonly ISidebarVmFactory _vmFactory;
|
||||
private readonly IWindowService _windowService;
|
||||
private SidebarProfileConfigurationViewModel? _selectedProfileConfiguration;
|
||||
private ObservableAsPropertyHelper<bool>? _isCollapsed;
|
||||
private ObservableAsPropertyHelper<bool>? _isSuspended;
|
||||
|
||||
public SidebarCategoryViewModel(SidebarViewModel sidebarViewModel, ProfileCategory profileCategory, IProfileService profileService, IWindowService windowService,
|
||||
IProfileEditorService profileEditorService, ISidebarVmFactory vmFactory)
|
||||
@ -31,24 +37,59 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
_vmFactory = vmFactory;
|
||||
|
||||
ProfileCategory = profileCategory;
|
||||
SourceCache<ProfileConfiguration, Guid> profileConfigurations = new(t => t.ProfileId);
|
||||
|
||||
if (ShowItems)
|
||||
CreateProfileViewModels();
|
||||
// Only show items when not collapsed
|
||||
IObservable<Func<ProfileConfiguration, bool>> profileConfigurationsFilter = this.WhenAnyValue(vm => vm.IsCollapsed).Select(b => new Func<object, bool>(_ => !b));
|
||||
profileConfigurations.Connect()
|
||||
.SortBy(c => c.Order)
|
||||
.Filter(profileConfigurationsFilter)
|
||||
.Transform(c => _vmFactory.SidebarProfileConfigurationViewModel(_sidebarViewModel, c))
|
||||
.Bind(out ReadOnlyObservableCollection<SidebarProfileConfigurationViewModel> profileConfigurationViewModels)
|
||||
.Subscribe();
|
||||
ProfileConfigurations = profileConfigurationViewModels;
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
ToggleCollapsed = ReactiveCommand.Create(ExecuteToggleCollapsed);
|
||||
ToggleSuspended = ReactiveCommand.Create(ExecuteToggleSuspended);
|
||||
AddProfile = ReactiveCommand.CreateFromTask(ExecuteAddProfile);
|
||||
EditCategory = ReactiveCommand.CreateFromTask(ExecuteEditCategory);
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
profileEditorService.ProfileConfiguration
|
||||
.Subscribe(p => SelectedProfileConfiguration = ProfileConfigurations.FirstOrDefault(c => ReferenceEquals(c.ProfileConfiguration, p)))
|
||||
.DisposeWith(disposables);
|
||||
this.WhenAnyValue(vm => vm.SelectedProfileConfiguration)
|
||||
.WhereNotNull()
|
||||
.Subscribe(s => profileEditorService.ChangeCurrentProfileConfiguration(s.ProfileConfiguration));
|
||||
// Update the list of profiles whenever the category fires events
|
||||
Observable.FromEventPattern<ProfileConfigurationEventArgs>(x => profileCategory.ProfileConfigurationAdded += x, x => profileCategory.ProfileConfigurationAdded -= x)
|
||||
.Subscribe(e => profileConfigurations.AddOrUpdate(e.EventArgs.ProfileConfiguration))
|
||||
.DisposeWith(d);
|
||||
Observable.FromEventPattern<ProfileConfigurationEventArgs>(x => profileCategory.ProfileConfigurationRemoved += x, x => profileCategory.ProfileConfigurationRemoved -= x)
|
||||
.Subscribe(e => profileConfigurations.Remove(e.EventArgs.ProfileConfiguration))
|
||||
.DisposeWith(d);
|
||||
|
||||
profileEditorService.ProfileConfiguration.Subscribe(p => SelectedProfileConfiguration = ProfileConfigurations.FirstOrDefault(c => ReferenceEquals(c.ProfileConfiguration, p)))
|
||||
.DisposeWith(d);
|
||||
|
||||
_isCollapsed = ProfileCategory.WhenAnyValue(vm => vm.IsCollapsed).ToProperty(this, vm => vm.IsCollapsed).DisposeWith(d);
|
||||
_isSuspended = ProfileCategory.WhenAnyValue(vm => vm.IsSuspended).ToProperty(this, vm => vm.IsSuspended).DisposeWith(d);
|
||||
|
||||
// Change the current profile configuration when a new one is selected
|
||||
this.WhenAnyValue(vm => vm.SelectedProfileConfiguration).WhereNotNull().Subscribe(s => profileEditorService.ChangeCurrentProfileConfiguration(s.ProfileConfiguration));
|
||||
});
|
||||
|
||||
profileConfigurations.Edit(updater =>
|
||||
{
|
||||
foreach (ProfileConfiguration profileConfiguration in profileCategory.ProfileConfigurations)
|
||||
updater.AddOrUpdate(profileConfiguration);
|
||||
});
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> ToggleCollapsed { get; }
|
||||
public ReactiveCommand<Unit, Unit> ToggleSuspended { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddProfile { get; }
|
||||
public ReactiveCommand<Unit, Unit> EditCategory { get; }
|
||||
public ProfileCategory ProfileCategory { get; }
|
||||
public ReadOnlyObservableCollection<SidebarProfileConfigurationViewModel> ProfileConfigurations { get; }
|
||||
|
||||
public ObservableCollection<SidebarProfileConfigurationViewModel> ProfileConfigurations { get; } = new();
|
||||
public bool IsCollapsed => _isCollapsed?.Value ?? false;
|
||||
public bool IsSuspended => _isSuspended?.Value ?? false;
|
||||
|
||||
public SidebarProfileConfigurationViewModel? SelectedProfileConfiguration
|
||||
{
|
||||
@ -56,34 +97,7 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
set => RaiseAndSetIfChanged(ref _selectedProfileConfiguration, value);
|
||||
}
|
||||
|
||||
public bool ShowItems
|
||||
{
|
||||
get => !ProfileCategory.IsCollapsed;
|
||||
set
|
||||
{
|
||||
ProfileCategory.IsCollapsed = !value;
|
||||
if (ProfileCategory.IsCollapsed)
|
||||
ProfileConfigurations.Clear();
|
||||
else
|
||||
CreateProfileViewModels();
|
||||
_profileService.SaveProfileCategory(ProfileCategory);
|
||||
|
||||
this.RaisePropertyChanged(nameof(ShowItems));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSuspended
|
||||
{
|
||||
get => ProfileCategory.IsSuspended;
|
||||
set
|
||||
{
|
||||
ProfileCategory.IsSuspended = value;
|
||||
this.RaisePropertyChanged(nameof(IsSuspended));
|
||||
_profileService.SaveProfileCategory(ProfileCategory);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task EditCategory()
|
||||
private async Task ExecuteEditCategory()
|
||||
{
|
||||
await _windowService.CreateContentDialog()
|
||||
.WithTitle("Edit category")
|
||||
@ -97,7 +111,7 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
_sidebarViewModel.UpdateProfileCategories();
|
||||
}
|
||||
|
||||
public async Task AddProfile()
|
||||
private async Task ExecuteAddProfile()
|
||||
{
|
||||
ProfileConfiguration? result = await _windowService.ShowDialogAsync<ProfileConfigurationEditViewModel, ProfileConfiguration?>(
|
||||
("profileCategory", ProfileCategory),
|
||||
@ -106,18 +120,20 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
if (result != null)
|
||||
{
|
||||
SidebarProfileConfigurationViewModel viewModel = _vmFactory.SidebarProfileConfigurationViewModel(_sidebarViewModel, result);
|
||||
ProfileConfigurations.Insert(0, viewModel);
|
||||
SelectedProfileConfiguration = viewModel;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateProfileViewModels()
|
||||
private void ExecuteToggleCollapsed()
|
||||
{
|
||||
ProfileConfigurations.Clear();
|
||||
foreach (ProfileConfiguration profileConfiguration in ProfileCategory.ProfileConfigurations.OrderBy(p => p.Order))
|
||||
ProfileConfigurations.Add(_vmFactory.SidebarProfileConfigurationViewModel(_sidebarViewModel, profileConfiguration));
|
||||
ProfileCategory.IsCollapsed = !ProfileCategory.IsCollapsed;
|
||||
_profileService.SaveProfileCategory(ProfileCategory);
|
||||
}
|
||||
|
||||
SelectedProfileConfiguration = ProfileConfigurations.FirstOrDefault(i => i.ProfileConfiguration.IsBeingEdited);
|
||||
private void ExecuteToggleSuspended()
|
||||
{
|
||||
ProfileCategory.IsSuspended = !ProfileCategory.IsSuspended;
|
||||
_profileService.SaveProfileCategory(ProfileCategory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -106,15 +106,18 @@
|
||||
Classes="icon-button icon-button-small"
|
||||
Grid.Column="2"
|
||||
ToolTip.Tip="View properties"
|
||||
HorizontalAlignment="Right">
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0 0 2 0">
|
||||
<avalonia:MaterialIcon Kind="Cog" />
|
||||
</Button>
|
||||
<ToggleButton Classes="icon-button icon-button-small"
|
||||
<Button Classes="icon-button icon-button-small"
|
||||
Command="{CompiledBinding ToggleSuspended}"
|
||||
Grid.Column="3"
|
||||
ToolTip.Tip="Suspend profile"
|
||||
Margin="2 0 0 0"
|
||||
IsChecked="{CompiledBinding IsSuspended}">
|
||||
<avalonia:MaterialIcon Kind="Pause" />
|
||||
</ToggleButton>
|
||||
ToolTip.Tip="Suspend/resume profile">
|
||||
<Panel>
|
||||
<avalonia:MaterialIcon Kind="EyeOff" IsVisible="{CompiledBinding IsSuspended}" />
|
||||
<avalonia:MaterialIcon Kind="Eye" IsVisible="{CompiledBinding !IsSuspended}" />
|
||||
</Panel>
|
||||
</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -26,31 +26,22 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
|
||||
ProfileConfiguration = profileConfiguration;
|
||||
EditProfile = ReactiveCommand.CreateFromTask(ExecuteEditProfile);
|
||||
ToggleSuspended = ReactiveCommand.Create(ExecuteToggleSuspended);
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
_isSuspended = ProfileConfiguration.WhenAnyValue(c => c.IsSuspended)
|
||||
.ToProperty(this, vm => vm.IsSuspended)
|
||||
.DisposeWith(d);
|
||||
_isSuspended = ProfileConfiguration.WhenAnyValue(c => c.IsSuspended).ToProperty(this, vm => vm.IsSuspended).DisposeWith(d);
|
||||
});
|
||||
_profileService.LoadProfileConfigurationIcon(ProfileConfiguration);
|
||||
}
|
||||
|
||||
|
||||
public ReactiveCommand<Unit, Unit> EditProfile { get; }
|
||||
public ReactiveCommand<Unit,Unit> ToggleSuspended { get; }
|
||||
|
||||
public bool IsProfileActive => ProfileConfiguration.Profile != null;
|
||||
public bool IsSuspended => _isSuspended?.Value ?? false;
|
||||
|
||||
public bool IsSuspended
|
||||
{
|
||||
get => _isSuspended?.Value ?? false;
|
||||
set
|
||||
{
|
||||
ProfileConfiguration.IsSuspended = value;
|
||||
_profileService.SaveProfileCategory(ProfileConfiguration.Category);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ExecuteEditProfile()
|
||||
private async Task ExecuteEditProfile()
|
||||
{
|
||||
ProfileConfiguration? edited = await _windowService.ShowDialogAsync<ProfileConfigurationEditViewModel, ProfileConfiguration?>(
|
||||
("profileCategory", ProfileConfiguration.Category),
|
||||
@ -60,5 +51,11 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
if (edited != null)
|
||||
_sidebarViewModel.UpdateProfileCategories();
|
||||
}
|
||||
|
||||
private void ExecuteToggleSuspended()
|
||||
{
|
||||
ProfileConfiguration.IsSuspended = !ProfileConfiguration.IsSuspended;
|
||||
_profileService.SaveProfileCategory(ProfileConfiguration.Category);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user