mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Profile settigns - Added activation condition visual scripting
This commit is contained in:
parent
bcd03becc7
commit
d563d17270
4
src/.idea/.idea.Artemis/.idea/avalonia.xml
generated
4
src/.idea/.idea.Artemis/.idea/avalonia.xml
generated
@ -27,6 +27,7 @@
|
||||
<entry key="Artemis.UI/Screens/Device/Tabs/InputMappingsTabView.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/DisplayCondition/ConditionTypes/StaticConditionView.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/Dialogs/AdaptionHints/CategoryAdaptionHintView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/Dialogs/AdaptionHints/DeviceAdaptionHintView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
@ -54,7 +55,7 @@
|
||||
<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/Dialogs/ProfileConfigurationEditView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/Sidebar/Dialogs/ProfileConfigurationEditView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
|
||||
<entry key="Artemis.UI/Screens/Sidebar/SidebarCategoryView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.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" />
|
||||
@ -65,6 +66,7 @@
|
||||
<entry key="Artemis.UI/Screens/VisualScripting/NodeScriptView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
|
||||
<entry key="Artemis.UI/Screens/VisualScripting/NodeView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/Workshop/WorkshopView.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" />
|
||||
</map>
|
||||
|
||||
@ -134,7 +134,7 @@ namespace Artemis.Core
|
||||
/// Gets the data model condition that must evaluate to <see langword="true" /> for this profile to be activated
|
||||
/// alongside any activation requirements of the <see cref="Module" />, if set
|
||||
/// </summary>
|
||||
public NodeScript<bool> ActivationCondition { get; set; }
|
||||
public NodeScript<bool> ActivationCondition { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the module this profile uses
|
||||
@ -241,11 +241,7 @@ namespace Artemis.Core
|
||||
|
||||
Icon.Load();
|
||||
|
||||
ActivationCondition.Dispose();
|
||||
ActivationCondition = Entity.ActivationCondition != null
|
||||
? new NodeScript<bool>("Activate profile", "Whether or not the profile should be active", Entity.ActivationCondition, this)
|
||||
: new NodeScript<bool>("Activate profile", "Whether or not the profile should be active", this);
|
||||
|
||||
ActivationCondition.LoadFromEntity(Entity.ActivationCondition);
|
||||
EnableHotkey = Entity.EnableHotkey != null ? new Hotkey(Entity.EnableHotkey) : null;
|
||||
DisableHotkey = Entity.DisableHotkey != null ? new Hotkey(Entity.DisableHotkey) : null;
|
||||
}
|
||||
@ -265,8 +261,8 @@ namespace Artemis.Core
|
||||
|
||||
Icon.Save();
|
||||
|
||||
ActivationCondition?.Save();
|
||||
Entity.ActivationCondition = ActivationCondition?.Entity;
|
||||
ActivationCondition.Save();
|
||||
Entity.ActivationCondition = ActivationCondition.Entity;
|
||||
|
||||
EnableHotkey?.Save();
|
||||
Entity.EnableHotkey = EnableHotkey?.Entity;
|
||||
|
||||
@ -276,13 +276,8 @@ namespace Artemis.Core
|
||||
{
|
||||
Entity.Name = Name;
|
||||
Entity.Description = Description;
|
||||
|
||||
Entity.Nodes.Clear();
|
||||
|
||||
// No need to save the exit node if that's all there is
|
||||
if (Nodes.Count() == 1)
|
||||
return;
|
||||
|
||||
foreach (INode node in Nodes)
|
||||
{
|
||||
NodeEntity nodeEntity = new()
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
</Style>
|
||||
|
||||
<Style Selector="Border.card">
|
||||
<Setter Property="Padding" Value="25" />
|
||||
<Setter Property="Padding" Value="16" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlFillColorDefaultBrush}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource CardStrokeColorDefaultBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
@ -44,7 +44,7 @@
|
||||
</Style>
|
||||
|
||||
<Style Selector="Border.card-condensed">
|
||||
<Setter Property="Padding" Value="10" />
|
||||
<Setter Property="Padding" Value="8" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlFillColorDefaultBrush}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource CardStrokeColorDefaultBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
<controls1:CoreWindow xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:core="clr-namespace:Artemis.Core;assembly=Artemis.Core"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:svg="clr-namespace:Avalonia.Svg.Skia;assembly=Avalonia.Svg.Skia"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Sidebar"
|
||||
xmlns:controls1="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="850"
|
||||
x:Class="Artemis.UI.Screens.Sidebar.ProfileConfigurationEditView"
|
||||
Title="{Binding DisplayName}"
|
||||
Icon="/Assets/Images/Logo/application.ico"
|
||||
Width="800"
|
||||
MinWidth="420"
|
||||
Height="850">
|
||||
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:core="clr-namespace:Artemis.Core;assembly=Artemis.Core"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Sidebar"
|
||||
xmlns:controls1="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="850"
|
||||
x:Class="Artemis.UI.Screens.Sidebar.ProfileConfigurationEditView"
|
||||
x:DataType="local:ProfileConfigurationEditViewModel"
|
||||
Title="{CompiledBinding DisplayName}"
|
||||
Icon="/Assets/Images/Logo/application.ico"
|
||||
Width="800"
|
||||
MinWidth="420"
|
||||
Height="975">
|
||||
<Window.Resources>
|
||||
<converters:EnumToBooleanConverter x:Key="EnumBoolConverter" />
|
||||
</Window.Resources>
|
||||
@ -37,16 +37,16 @@
|
||||
</StackPanel.Styles>
|
||||
|
||||
<Grid>
|
||||
<TextBlock Classes="h4" IsVisible="{Binding IsNew}">Add a new profile</TextBlock>
|
||||
<TextBlock Classes="h4" IsVisible="{Binding !IsNew}" Text="{Binding ProfileConfiguration.Name}" />
|
||||
<TextBlock Classes="h4" IsVisible="{CompiledBinding IsNew}">Add a new profile</TextBlock>
|
||||
<TextBlock Classes="h4" IsVisible="{CompiledBinding !IsNew}" Text="{CompiledBinding ProfileConfiguration.Name}" />
|
||||
</Grid>
|
||||
|
||||
<Border Classes="card" Margin="0 0 0 15">
|
||||
<StackPanel>
|
||||
<TextBlock Classes="label">Profile name</TextBlock>
|
||||
<TextBox Watermark="Name" Text="{Binding ProfileName}" />
|
||||
<TextBox Watermark="Name" Text="{CompiledBinding ProfileName}" />
|
||||
<TextBlock Classes="label">Module</TextBlock>
|
||||
<ComboBox SelectedItem="{Binding SelectedModule}" IsEnabled="{Binding Modules.Count}" Items="{Binding Modules}" HorizontalAlignment="Stretch">
|
||||
<ComboBox SelectedItem="{CompiledBinding SelectedModule}" IsEnabled="{CompiledBinding Modules.Count}" Items="{CompiledBinding Modules}" HorizontalAlignment="Stretch">
|
||||
<ComboBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel />
|
||||
@ -55,65 +55,64 @@
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type local:ProfileModuleViewModel}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<shared:ArtemisIcon Icon="{Binding Icon}" Width="16" Height="16" Margin="0 0 5 0" />
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
<shared:ArtemisIcon Icon="{CompiledBinding Icon}" Width="16" Height="16" Margin="0 0 5 0" />
|
||||
<TextBlock Text="{CompiledBinding Name}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<Grid>
|
||||
<TextBlock Classes="subtitle" IsVisible="{Binding Modules.Count}">Optional and binds the profile to the selected module, making module data available</TextBlock>
|
||||
<TextBlock Classes="subtitle" IsVisible="{Binding !Modules.Count}">No available modules were found</TextBlock>
|
||||
<TextBlock Classes="subtitle" IsVisible="{CompiledBinding Modules.Count}">Optional and binds the profile to the selected module, making module data available</TextBlock>
|
||||
<TextBlock Classes="subtitle" IsVisible="{CompiledBinding !Modules.Count}">No available modules were found</TextBlock>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Classes="label">Icon type</TextBlock>
|
||||
<TextBlock Classes="label">Icon</TextBlock>
|
||||
<WrapPanel Orientation="Horizontal">
|
||||
<RadioButton Content="Material Icon"
|
||||
IsChecked="{Binding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.MaterialIcon}}" />
|
||||
IsChecked="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.MaterialIcon}}" />
|
||||
<RadioButton Content="Bitmap image"
|
||||
IsChecked="{Binding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.BitmapImage}}" />
|
||||
IsChecked="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.BitmapImage}}" />
|
||||
<RadioButton Content="SVG image"
|
||||
IsChecked="{Binding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.SvgImage}}" />
|
||||
IsChecked="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.SvgImage}}" />
|
||||
</WrapPanel>
|
||||
|
||||
<TextBlock Classes="label">Icon</TextBlock>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
IsVisible="{Binding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.BitmapImage}}">
|
||||
IsVisible="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.BitmapImage}}">
|
||||
<Border Background="{DynamicResource CheckerboardBrush}" CornerRadius="{DynamicResource CardCornerRadius}" Width="78" Height="78">
|
||||
<Image Source="{Binding SelectedBitmapSource}" Margin="10" />
|
||||
<Image Source="{CompiledBinding SelectedBitmapSource}" Margin="10" />
|
||||
</Border>
|
||||
<Button Command="{Binding BrowseBitmapFile}"
|
||||
<Button Command="{CompiledBinding BrowseBitmapFile}"
|
||||
VerticalAlignment="Bottom"
|
||||
Margin="10 0"
|
||||
IsVisible="{Binding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.BitmapImage}}">
|
||||
IsVisible="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.BitmapImage}}">
|
||||
Browse bitmap file
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
IsVisible="{Binding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.SvgImage}}">
|
||||
IsVisible="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.SvgImage}}">
|
||||
<Border Background="{DynamicResource CheckerboardBrush}" CornerRadius="{DynamicResource CardCornerRadius}" Width="78" Height="78">
|
||||
<Image Margin="10" Source="{Binding SelectedSvgSource}" />
|
||||
<Image Margin="10" Source="{CompiledBinding SelectedSvgSource}" />
|
||||
</Border>
|
||||
<Button Command="{Binding BrowseSvgFile}"
|
||||
<Button Command="{CompiledBinding BrowseSvgFile}"
|
||||
VerticalAlignment="Bottom"
|
||||
Margin="10 0"
|
||||
IsVisible="{Binding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.SvgImage}}">
|
||||
IsVisible="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.SvgImage}}">
|
||||
Browse SVG file
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
IsVisible="{Binding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.MaterialIcon}}">
|
||||
IsVisible="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.MaterialIcon}}">
|
||||
<Border Background="{DynamicResource CheckerboardBrush}" CornerRadius="{DynamicResource CardCornerRadius}" Width="78" Height="78">
|
||||
<avalonia:MaterialIcon Kind="{Binding SelectedMaterialIcon.Icon}" Width="45" Height="45" />
|
||||
<avalonia:MaterialIcon Kind="{CompiledBinding SelectedMaterialIcon.Icon}" Width="45" Height="45" />
|
||||
</Border>
|
||||
<ComboBox Items="{Binding MaterialIcons}"
|
||||
SelectedItem="{Binding SelectedMaterialIcon}"
|
||||
<ComboBox Items="{CompiledBinding MaterialIcons}"
|
||||
SelectedItem="{CompiledBinding SelectedMaterialIcon}"
|
||||
VirtualizationMode="Simple"
|
||||
VerticalAlignment="Bottom"
|
||||
IsTextSearchEnabled="True"
|
||||
Margin="10 0"
|
||||
Width="250"
|
||||
IsVisible="{Binding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.MaterialIcon}}">
|
||||
IsVisible="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.MaterialIcon}}">
|
||||
<ComboBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel />
|
||||
@ -122,8 +121,8 @@
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate DataType="local:ProfileIconViewModel">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<avalonia:MaterialIcon Kind="{Binding Icon}" Margin="0 0 5 0" />
|
||||
<TextBlock Text="{Binding DisplayName}" />
|
||||
<avalonia:MaterialIcon Kind="{CompiledBinding Icon}" Margin="0 0 5 0" />
|
||||
<TextBlock Text="{CompiledBinding DisplayName}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
@ -135,33 +134,33 @@
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Classes="h5 section-header">Keybindings</TextBlock>
|
||||
<TextBlock Classes="subtitle section-subtitle">You may set up hotkeys to activate/deactivate the profile</TextBlock>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Border Classes="card" Margin="0 5 0 15">
|
||||
<StackPanel>
|
||||
<TextBlock>Hotkey mode</TextBlock>
|
||||
<WrapPanel Orientation="Horizontal">
|
||||
<RadioButton Content="None"
|
||||
IsChecked="{Binding HotkeyMode, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationHotkeyMode.None}}" />
|
||||
<RadioButton Content="Toggle"
|
||||
IsChecked="{Binding HotkeyMode, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationHotkeyMode.Toggle}}" />
|
||||
<RadioButton Content="Separate enable/disable"
|
||||
IsChecked="{Binding HotkeyMode, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationHotkeyMode.EnableDisable}}" />
|
||||
</WrapPanel>
|
||||
<StackPanel>
|
||||
<TextBlock>Hotkey mode</TextBlock>
|
||||
<WrapPanel Orientation="Horizontal">
|
||||
<RadioButton Content="None"
|
||||
IsChecked="{CompiledBinding HotkeyMode, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationHotkeyMode.None}}" />
|
||||
<RadioButton Content="Toggle"
|
||||
IsChecked="{CompiledBinding HotkeyMode, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationHotkeyMode.Toggle}}" />
|
||||
<RadioButton Content="Separate enable/disable"
|
||||
IsChecked="{CompiledBinding HotkeyMode, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationHotkeyMode.EnableDisable}}" />
|
||||
</WrapPanel>
|
||||
|
||||
<shared:HotkeyBox Watermark="Toggle hotkey"
|
||||
Hotkey="{Binding EnableHotkey}"
|
||||
IsVisible="{Binding HotkeyMode, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationHotkeyMode.Toggle}}"
|
||||
HorizontalAlignment="Left"
|
||||
Width="200"
|
||||
Margin="0 5 0 0"/>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
IsVisible="{Binding HotkeyMode, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationHotkeyMode.EnableDisable}}"
|
||||
<shared:HotkeyBox Watermark="Toggle hotkey"
|
||||
Hotkey="{CompiledBinding EnableHotkey}"
|
||||
IsVisible="{CompiledBinding HotkeyMode, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationHotkeyMode.Toggle}}"
|
||||
HorizontalAlignment="Left"
|
||||
Width="200"
|
||||
Margin="0 5 0 0" />
|
||||
<StackPanel Orientation="Horizontal"
|
||||
IsVisible="{CompiledBinding HotkeyMode, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationHotkeyMode.EnableDisable}}"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0 5 0 0">
|
||||
<shared:HotkeyBox Watermark="Enable hotkey" Hotkey="{Binding EnableHotkey}" Margin="0 0 4 0" Width="200"/>
|
||||
<shared:HotkeyBox Watermark="Disable hotkey" Hotkey="{Binding DisableHotkey}" Margin="4 0 0 0" Width="200"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<shared:HotkeyBox Watermark="Enable hotkey" Hotkey="{CompiledBinding EnableHotkey}" Margin="0 0 4 0" Width="200" />
|
||||
<shared:HotkeyBox Watermark="Disable hotkey" Hotkey="{CompiledBinding DisableHotkey}" Margin="4 0 0 0" Width="200" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
@ -169,16 +168,30 @@
|
||||
<TextBlock Classes="subtitle section-subtitle">Set up certain conditions under which the profile should be active</TextBlock>
|
||||
</StackPanel>
|
||||
<Border Classes="card" Margin="0 5 0 15">
|
||||
<TextBlock TextWrapping="Wrap">Here you'll find the node editor layer at some point, use your imagination for now.</TextBlock>
|
||||
<Grid>
|
||||
<Border CornerRadius="5" ClipToBounds="True">
|
||||
<ContentControl Content="{CompiledBinding VisualEditorViewModel}" Height="150" />
|
||||
</Border>
|
||||
<Border Background="Black" Opacity="0.5" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" CornerRadius="5"/>
|
||||
|
||||
<Button DockPanel.Dock="Bottom"
|
||||
ToolTip.Tip="Open editor"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Command="{CompiledBinding OpenConditionEditor}">
|
||||
Edit condition script
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
<Grid Grid.Row="1" ColumnDefinitions="Auto,Auto,Auto" HorizontalAlignment="Right">
|
||||
<Button Grid.Column="0" Classes="accent" Command="{Binding Confirm}">Confirm</Button>
|
||||
<Button Grid.Column="1" Margin="5" Command="{Binding Import}" IsVisible="{Binding IsNew}">Import</Button>
|
||||
<Button Grid.Column="1" Margin="5" Command="{Binding Delete}" IsVisible="{Binding !IsNew}">Delete</Button>
|
||||
<Button Grid.Column="2" Command="{Binding Cancel}">Cancel</Button>
|
||||
<Button Grid.Column="0" Classes="accent" Command="{CompiledBinding Confirm}">Confirm</Button>
|
||||
<Button Grid.Column="1" Margin="5" Command="{CompiledBinding Import}" IsVisible="{CompiledBinding IsNew}">Import</Button>
|
||||
<Button Grid.Column="1" Margin="5" Command="{CompiledBinding Delete}" IsVisible="{CompiledBinding !IsNew}">Delete</Button>
|
||||
<Button Grid.Column="2" Command="{CompiledBinding Cancel}">Cancel</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
@ -2,10 +2,13 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Modules;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.VisualScripting;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
@ -43,7 +46,8 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
IWindowService windowService,
|
||||
IProfileService profileService,
|
||||
IProfileEditorService profileEditorService,
|
||||
IPluginManagementService pluginManagementService)
|
||||
IPluginManagementService pluginManagementService,
|
||||
INodeVmFactory nodeVmFactory)
|
||||
{
|
||||
_profileCategory = profileCategory;
|
||||
_windowService = windowService;
|
||||
@ -63,8 +67,17 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
Modules = new ObservableCollection<ProfileModuleViewModel>(
|
||||
pluginManagementService.GetFeaturesOfType<Module>().Where(m => !m.IsAlwaysAvailable).Select(m => new ProfileModuleViewModel(m))
|
||||
);
|
||||
|
||||
VisualEditorViewModel = nodeVmFactory.NodeScriptViewModel(_profileConfiguration.ActivationCondition, true);
|
||||
Dispatcher.UIThread.Post(LoadIcon, DispatcherPriority.Background);
|
||||
|
||||
BrowseBitmapFile = ReactiveCommand.CreateFromTask(ExecuteBrowseBitmapFile);
|
||||
BrowseSvgFile = ReactiveCommand.CreateFromTask(ExecuteBrowseSvgFile);
|
||||
OpenConditionEditor = ReactiveCommand.CreateFromTask(ExecuteOpenConditionEditor);
|
||||
Confirm = ReactiveCommand.CreateFromTask(ExecuteConfirm);
|
||||
Import = ReactiveCommand.CreateFromTask(ExecuteImport);
|
||||
Delete = ReactiveCommand.CreateFromTask(ExecuteDelete);
|
||||
Cancel = ReactiveCommand.Create(ExecuteCancel);
|
||||
|
||||
}
|
||||
|
||||
public bool IsNew { get; }
|
||||
@ -107,7 +120,17 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
set => RaiseAndSetIfChanged(ref _selectedModule, value);
|
||||
}
|
||||
|
||||
public async Task Import()
|
||||
public NodeScriptViewModel VisualEditorViewModel { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> OpenConditionEditor { get; }
|
||||
public ReactiveCommand<Unit, Unit> BrowseBitmapFile { get; }
|
||||
public ReactiveCommand<Unit, Unit> BrowseSvgFile { get; }
|
||||
public ReactiveCommand<Unit, Unit> Confirm { get; }
|
||||
public ReactiveCommand<Unit, Unit> Import { get; }
|
||||
public ReactiveCommand<Unit, Unit> Delete { get; }
|
||||
public new ReactiveCommand<Unit, Unit> Cancel { get; }
|
||||
|
||||
private async Task ExecuteImport()
|
||||
{
|
||||
if (!IsNew)
|
||||
return;
|
||||
@ -144,7 +167,7 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
Close(_profileConfiguration);
|
||||
}
|
||||
|
||||
public async Task Delete()
|
||||
private async Task ExecuteDelete()
|
||||
{
|
||||
if (IsNew)
|
||||
return;
|
||||
@ -157,7 +180,7 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
Close(_profileConfiguration);
|
||||
}
|
||||
|
||||
public async Task Confirm()
|
||||
private async Task ExecuteConfirm()
|
||||
{
|
||||
ProfileConfiguration.Name = ProfileName;
|
||||
ProfileConfiguration.Module = SelectedModule?.Module;
|
||||
@ -172,7 +195,7 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
Close(ProfileConfiguration);
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
private void ExecuteCancel()
|
||||
{
|
||||
if (IsNew)
|
||||
_profileService.RemoveProfileConfiguration(_profileConfiguration);
|
||||
@ -255,7 +278,7 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
}
|
||||
}
|
||||
|
||||
public async Task BrowseBitmapFile()
|
||||
private async Task ExecuteBrowseBitmapFile()
|
||||
{
|
||||
string[]? result = await _windowService.CreateOpenFileDialog()
|
||||
.HavingFilter(f => f.WithExtension("png").WithExtension("jpg").WithExtension("bmp").WithName("Bitmap image"))
|
||||
@ -268,7 +291,7 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
_selectedIconPath = result[0];
|
||||
}
|
||||
|
||||
public async Task BrowseSvgFile()
|
||||
private async Task ExecuteBrowseSvgFile()
|
||||
{
|
||||
string[]? result = await _windowService.CreateOpenFileDialog()
|
||||
.HavingFilter(f => f.WithExtension("svg").WithName("SVG image"))
|
||||
@ -283,6 +306,11 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
SelectedSvgSource = new SvgImage {Source = newSource};
|
||||
_selectedIconPath = result[0];
|
||||
}
|
||||
|
||||
private async Task ExecuteOpenConditionEditor()
|
||||
{
|
||||
await _windowService.ShowDialogAsync<NodeScriptWindowViewModel, bool>(("nodeScript", ProfileConfiguration.ActivationCondition));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -14,13 +14,6 @@
|
||||
<Border Classes="router-container">
|
||||
<ScrollViewer>
|
||||
<StackPanel Margin="12" Spacing="5">
|
||||
<Border Classes="card">
|
||||
<StackPanel Spacing="5">
|
||||
<TextBlock Classes="h4">Nodes tests</TextBlock>
|
||||
<!-- <dataModelPicker:DataModelPickerButton Placement="BottomEdgeAlignedLeft"/> -->
|
||||
<ContentControl Content="{CompiledBinding VisualEditorViewModel}" HorizontalAlignment="Stretch" Height="800"></ContentControl>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Classes="card">
|
||||
<StackPanel Spacing="5">
|
||||
<TextBlock Classes="h4">Notification tests</TextBlock>
|
||||
|
||||
@ -1,96 +1,63 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.VisualScripting;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Builders;
|
||||
using Artemis.VisualScripting.Nodes;
|
||||
using Artemis.VisualScripting.Nodes.Operators;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop
|
||||
namespace Artemis.UI.Screens.Workshop;
|
||||
|
||||
public class WorkshopViewModel : MainScreenViewModel
|
||||
{
|
||||
public class WorkshopViewModel : MainScreenViewModel
|
||||
private readonly ObservableAsPropertyHelper<Cursor> _cursor;
|
||||
private readonly INotificationService _notificationService;
|
||||
|
||||
private ColorGradient _colorGradient = new()
|
||||
{
|
||||
private static NodeScript<bool>? _testScript = null;
|
||||
new ColorGradientStop(new SKColor(0xFFFF6D00), 0f),
|
||||
new ColorGradientStop(new SKColor(0xFFFE6806), 0.2f),
|
||||
new ColorGradientStop(new SKColor(0xFFEF1788), 0.4f),
|
||||
new ColorGradientStop(new SKColor(0xFFEF1788), 0.6f),
|
||||
new ColorGradientStop(new SKColor(0xFF00FCCC), 0.8f),
|
||||
new ColorGradientStop(new SKColor(0xFF00FCCC), 1f)
|
||||
};
|
||||
|
||||
private readonly INotificationService _notificationService;
|
||||
private StandardCursorType _selectedCursor;
|
||||
private readonly ObservableAsPropertyHelper<Cursor> _cursor;
|
||||
private StandardCursorType _selectedCursor;
|
||||
|
||||
private ColorGradient _colorGradient = new()
|
||||
{
|
||||
new ColorGradientStop(new SKColor(0xFFFF6D00), 0f),
|
||||
new ColorGradientStop(new SKColor(0xFFFE6806), 0.2f),
|
||||
new ColorGradientStop(new SKColor(0xFFEF1788), 0.4f),
|
||||
new ColorGradientStop(new SKColor(0xFFEF1788), 0.6f),
|
||||
new ColorGradientStop(new SKColor(0xFF00FCCC), 0.8f),
|
||||
new ColorGradientStop(new SKColor(0xFF00FCCC), 1f),
|
||||
};
|
||||
public WorkshopViewModel(IScreen hostScreen, INotificationService notificationService) : base(hostScreen, "workshop")
|
||||
{
|
||||
_notificationService = notificationService;
|
||||
_cursor = this.WhenAnyValue(vm => vm.SelectedCursor).Select(c => new Cursor(c)).ToProperty(this, vm => vm.Cursor);
|
||||
|
||||
public WorkshopViewModel(IScreen hostScreen, INotificationService notificationService, INodeVmFactory nodeVmFactory) : base(hostScreen, "workshop")
|
||||
{
|
||||
_notificationService = notificationService;
|
||||
_cursor = this.WhenAnyValue(vm => vm.SelectedCursor).Select(c => new Cursor(c)).ToProperty(this, vm => vm.Cursor);
|
||||
DisplayName = "Workshop";
|
||||
ShowNotification = ReactiveCommand.Create<NotificationSeverity>(ExecuteShowNotification);
|
||||
}
|
||||
|
||||
DisplayName = "Workshop";
|
||||
ShowNotification = ReactiveCommand.Create<NotificationSeverity>(ExecuteShowNotification);
|
||||
public ReactiveCommand<NotificationSeverity, Unit> ShowNotification { get; set; }
|
||||
|
||||
if (_testScript == null)
|
||||
{
|
||||
_testScript = new NodeScript<bool>("Test script", "A test script");
|
||||
INode exitNode = _testScript.Nodes.Last();
|
||||
exitNode.X = 300;
|
||||
exitNode.Y = 150;
|
||||
public StandardCursorType SelectedCursor
|
||||
{
|
||||
get => _selectedCursor;
|
||||
set => RaiseAndSetIfChanged(ref _selectedCursor, value);
|
||||
}
|
||||
|
||||
OrNode orNode = new() {X = 100, Y = 100};
|
||||
_testScript.AddNode(orNode);
|
||||
orNode.Result.ConnectTo(exitNode.Pins.First());
|
||||
}
|
||||
public Cursor Cursor => _cursor.Value;
|
||||
|
||||
VisualEditorViewModel = nodeVmFactory.NodeScriptViewModel(_testScript, false);
|
||||
public ColorGradient ColorGradient
|
||||
{
|
||||
get => _colorGradient;
|
||||
set => RaiseAndSetIfChanged(ref _colorGradient, value);
|
||||
}
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
DispatcherTimer updateTimer = new(TimeSpan.FromMilliseconds(20), DispatcherPriority.Normal, (_, _) => _testScript?.Run());
|
||||
updateTimer.Start();
|
||||
Disposable.Create(() => updateTimer.Stop()).DisposeWith(d);
|
||||
});
|
||||
}
|
||||
public void CreateRandomGradient()
|
||||
{
|
||||
ColorGradient = ColorGradient.GetRandom(6);
|
||||
}
|
||||
|
||||
public NodeScriptViewModel VisualEditorViewModel { get; }
|
||||
|
||||
public ReactiveCommand<NotificationSeverity, Unit> ShowNotification { get; set; }
|
||||
|
||||
public StandardCursorType SelectedCursor
|
||||
{
|
||||
get => _selectedCursor;
|
||||
set => RaiseAndSetIfChanged(ref _selectedCursor, value);
|
||||
}
|
||||
|
||||
public Cursor Cursor => _cursor.Value;
|
||||
|
||||
public ColorGradient ColorGradient
|
||||
{
|
||||
get => _colorGradient;
|
||||
set => RaiseAndSetIfChanged(ref _colorGradient, value);
|
||||
}
|
||||
|
||||
public void CreateRandomGradient()
|
||||
{
|
||||
ColorGradient = ColorGradient.GetRandom(6);
|
||||
}
|
||||
|
||||
private void ExecuteShowNotification(NotificationSeverity severity)
|
||||
{
|
||||
_notificationService.CreateNotification().WithTitle("Test title").WithMessage("Test message").WithSeverity(severity).Show();
|
||||
}
|
||||
private void ExecuteShowNotification(NotificationSeverity severity)
|
||||
{
|
||||
_notificationService.CreateNotification().WithTitle("Test title").WithMessage("Test message").WithSeverity(severity).Show();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user