mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Merge branch 'development' into VisualScripting
This commit is contained in:
commit
dc9661353c
@ -11,10 +11,6 @@ namespace Artemis.Core.ScriptingProviders
|
|||||||
protected ProfileScript(Profile profile, ScriptConfiguration configuration) : base(configuration)
|
protected ProfileScript(Profile profile, ScriptConfiguration configuration) : base(configuration)
|
||||||
{
|
{
|
||||||
Profile = profile;
|
Profile = profile;
|
||||||
lock (Profile.Scripts)
|
|
||||||
{
|
|
||||||
Profile.Scripts.Add(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -20,8 +20,6 @@ namespace Artemis.Core.ScriptingProviders
|
|||||||
throw new ArtemisCoreException("The provided script configuration already has an active script");
|
throw new ArtemisCoreException("The provided script configuration already has an active script");
|
||||||
|
|
||||||
ScriptConfiguration = configuration;
|
ScriptConfiguration = configuration;
|
||||||
ScriptConfiguration.Script = this;
|
|
||||||
|
|
||||||
ScriptConfiguration.PropertyChanged += ScriptConfigurationOnPropertyChanged;
|
ScriptConfiguration.PropertyChanged += ScriptConfigurationOnPropertyChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -305,10 +305,17 @@ namespace Artemis.Core.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsKeyDown(KeyboardKey key)
|
||||||
|
{
|
||||||
|
return _pressedKeys.Any(p => p.Value.Contains(key));
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Mouse
|
#region Mouse
|
||||||
|
|
||||||
|
private readonly HashSet<MouseButton> _pressedButtons = new();
|
||||||
|
|
||||||
private void InputProviderOnMouseButtonDataReceived(object? sender, InputProviderMouseButtonEventArgs e)
|
private void InputProviderOnMouseButtonDataReceived(object? sender, InputProviderMouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
bool foundLedId = InputKeyUtilities.MouseButtonLedIdMap.TryGetValue(e.Button, out LedId ledId);
|
bool foundLedId = InputKeyUtilities.MouseButtonLedIdMap.TryGetValue(e.Button, out LedId ledId);
|
||||||
@ -320,9 +327,17 @@ namespace Artemis.Core.Services
|
|||||||
ArtemisMouseButtonUpDownEventArgs eventArgs = new(e.Device, led, e.Button, e.IsDown);
|
ArtemisMouseButtonUpDownEventArgs eventArgs = new(e.Device, led, e.Button, e.IsDown);
|
||||||
OnMouseButtonUpDown(eventArgs);
|
OnMouseButtonUpDown(eventArgs);
|
||||||
if (e.IsDown)
|
if (e.IsDown)
|
||||||
|
{
|
||||||
|
if (!_pressedButtons.Contains(e.Button))
|
||||||
|
_pressedButtons.Add(e.Button);
|
||||||
OnMouseButtonDown(eventArgs);
|
OnMouseButtonDown(eventArgs);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (_pressedButtons.Contains(e.Button))
|
||||||
|
_pressedButtons.Remove(e.Button);
|
||||||
OnMouseButtonUp(eventArgs);
|
OnMouseButtonUp(eventArgs);
|
||||||
|
}
|
||||||
|
|
||||||
// _logger.Verbose("Mouse button data: LED ID: {ledId}, button: {button}, is down: {isDown}, device: {device} ", ledId, e.Button, e.IsDown, e.Device);
|
// _logger.Verbose("Mouse button data: LED ID: {ledId}, button: {button}, is down: {isDown}, device: {device} ", ledId, e.Button, e.IsDown, e.Device);
|
||||||
}
|
}
|
||||||
@ -339,6 +354,11 @@ namespace Artemis.Core.Services
|
|||||||
// _logger.Verbose("Mouse move data: XY: {X},{Y} - delta XY: {deltaX},{deltaY} - device: {device} ", e.CursorX, e.CursorY, e.DeltaX, e.DeltaY, e.Device);
|
// _logger.Verbose("Mouse move data: XY: {X},{Y} - delta XY: {deltaX},{deltaY} - device: {device} ", e.CursorX, e.CursorY, e.DeltaX, e.DeltaY, e.Device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsButtonDown(MouseButton button)
|
||||||
|
{
|
||||||
|
return _pressedButtons.Contains(button);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Events
|
#region Events
|
||||||
|
|||||||
@ -40,7 +40,19 @@ namespace Artemis.Core.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void ReleaseAll();
|
void ReleaseAll();
|
||||||
|
|
||||||
#region Events
|
/// <summary>
|
||||||
|
/// Determines whether the provided key is pressed by any device
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">The key to check</param>
|
||||||
|
/// <returns><see langword="true" /> if the key is pressed; otherwise <see langword="false" /></returns>
|
||||||
|
bool IsKeyDown(KeyboardKey key);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether the button key is pressed by any device
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="button">The button to check</param>
|
||||||
|
/// <returns><see langword="true" /> if the button is pressed; otherwise <see langword="false" /></returns>
|
||||||
|
bool IsButtonDown(MouseButton button);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs whenever a key on a keyboard was pressed or released
|
/// Occurs whenever a key on a keyboard was pressed or released
|
||||||
@ -92,8 +104,6 @@ namespace Artemis.Core.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler DeviceIdentified;
|
public event EventHandler DeviceIdentified;
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Identification
|
#region Identification
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -199,6 +199,12 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
public void LoadPlugins(List<string> startupArguments, bool isElevated)
|
public void LoadPlugins(List<string> startupArguments, bool isElevated)
|
||||||
{
|
{
|
||||||
|
if (startupArguments.Contains("--no-plugins"))
|
||||||
|
{
|
||||||
|
_logger.Warning("Artemis launched with --no-plugins, skipping the loading of plugins");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool ignorePluginLock = startupArguments.Contains("--ignore-plugin-lock");
|
bool ignorePluginLock = startupArguments.Contains("--ignore-plugin-lock");
|
||||||
bool stayElevated = startupArguments.Contains("--force-elevation");
|
bool stayElevated = startupArguments.Contains("--force-elevation");
|
||||||
bool droppedAdmin = startupArguments.Contains("--dropped-admin");
|
bool droppedAdmin = startupArguments.Contains("--dropped-admin");
|
||||||
|
|||||||
@ -6,17 +6,20 @@ using System.Reflection;
|
|||||||
using Artemis.Core.ScriptingProviders;
|
using Artemis.Core.ScriptingProviders;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using Ninject.Parameters;
|
using Ninject.Parameters;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace Artemis.Core.Services
|
namespace Artemis.Core.Services
|
||||||
{
|
{
|
||||||
internal class ScriptingService : IScriptingService
|
internal class ScriptingService : IScriptingService
|
||||||
{
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
private readonly IPluginManagementService _pluginManagementService;
|
private readonly IPluginManagementService _pluginManagementService;
|
||||||
private readonly IProfileService _profileService;
|
private readonly IProfileService _profileService;
|
||||||
private List<ScriptingProvider> _scriptingProviders;
|
private List<ScriptingProvider> _scriptingProviders;
|
||||||
|
|
||||||
public ScriptingService(IPluginManagementService pluginManagementService, IProfileService profileService)
|
public ScriptingService(ILogger logger, IPluginManagementService pluginManagementService, IProfileService profileService)
|
||||||
{
|
{
|
||||||
|
_logger = logger;
|
||||||
_pluginManagementService = pluginManagementService;
|
_pluginManagementService = pluginManagementService;
|
||||||
_profileService = profileService;
|
_profileService = profileService;
|
||||||
|
|
||||||
@ -81,43 +84,71 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
public GlobalScript? CreateScriptInstance(ScriptConfiguration scriptConfiguration)
|
public GlobalScript? CreateScriptInstance(ScriptConfiguration scriptConfiguration)
|
||||||
{
|
{
|
||||||
if (scriptConfiguration.Script != null)
|
GlobalScript? script = null;
|
||||||
throw new ArtemisCoreException("The provided script configuration already has an active script");
|
try
|
||||||
|
{
|
||||||
|
if (scriptConfiguration.Script != null)
|
||||||
|
throw new ArtemisCoreException("The provided script configuration already has an active script");
|
||||||
|
|
||||||
ScriptingProvider? provider = _scriptingProviders.FirstOrDefault(p => p.Id == scriptConfiguration.ScriptingProviderId);
|
ScriptingProvider? provider = _scriptingProviders.FirstOrDefault(p => p.Id == scriptConfiguration.ScriptingProviderId);
|
||||||
if (provider == null)
|
if (provider == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
script = (GlobalScript) provider.Plugin.Kernel!.Get(
|
||||||
|
provider.GlobalScriptType,
|
||||||
|
CreateScriptConstructorArgument(provider.GlobalScriptType, scriptConfiguration)
|
||||||
|
);
|
||||||
|
|
||||||
|
script.ScriptingProvider = provider;
|
||||||
|
script.ScriptingService = this;
|
||||||
|
provider.InternalScripts.Add(script);
|
||||||
|
InternalGlobalScripts.Add(script);
|
||||||
|
|
||||||
|
scriptConfiguration.Script = script;
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.Warning(e, "Failed to initialize global script");
|
||||||
|
script?.Dispose();
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
GlobalScript script = (GlobalScript) provider.Plugin.Kernel!.Get(
|
|
||||||
provider.GlobalScriptType,
|
|
||||||
CreateScriptConstructorArgument(provider.GlobalScriptType, scriptConfiguration)
|
|
||||||
);
|
|
||||||
|
|
||||||
script.ScriptingProvider = provider;
|
|
||||||
script.ScriptingService = this;
|
|
||||||
provider.InternalScripts.Add(script);
|
|
||||||
InternalGlobalScripts.Add(script);
|
|
||||||
return script;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfileScript? CreateScriptInstance(Profile profile, ScriptConfiguration scriptConfiguration)
|
public ProfileScript? CreateScriptInstance(Profile profile, ScriptConfiguration scriptConfiguration)
|
||||||
{
|
{
|
||||||
if (scriptConfiguration.Script != null)
|
ProfileScript? script = null;
|
||||||
throw new ArtemisCoreException("The provided script configuration already has an active script");
|
try
|
||||||
|
{
|
||||||
|
if (scriptConfiguration.Script != null)
|
||||||
|
throw new ArtemisCoreException("The provided script configuration already has an active script");
|
||||||
|
|
||||||
ScriptingProvider? provider = _scriptingProviders.FirstOrDefault(p => p.Id == scriptConfiguration.ScriptingProviderId);
|
ScriptingProvider? provider = _scriptingProviders.FirstOrDefault(p => p.Id == scriptConfiguration.ScriptingProviderId);
|
||||||
if (provider == null)
|
if (provider == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
script = (ProfileScript) provider.Plugin.Kernel!.Get(
|
||||||
|
provider.ProfileScriptType,
|
||||||
|
CreateScriptConstructorArgument(provider.ProfileScriptType, profile),
|
||||||
|
CreateScriptConstructorArgument(provider.ProfileScriptType, scriptConfiguration)
|
||||||
|
);
|
||||||
|
|
||||||
|
script.ScriptingProvider = provider;
|
||||||
|
provider.InternalScripts.Add(script);
|
||||||
|
lock (profile)
|
||||||
|
{
|
||||||
|
scriptConfiguration.Script = script;
|
||||||
|
profile.Scripts.Add(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.Warning(e, "Failed to initialize profile script");
|
||||||
|
script?.Dispose();
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
ProfileScript script = (ProfileScript) provider.Plugin.Kernel!.Get(
|
|
||||||
provider.ProfileScriptType,
|
|
||||||
CreateScriptConstructorArgument(provider.ProfileScriptType, profile),
|
|
||||||
CreateScriptConstructorArgument(provider.ProfileScriptType, scriptConfiguration)
|
|
||||||
);
|
|
||||||
|
|
||||||
script.ScriptingProvider = provider;
|
|
||||||
provider.InternalScripts.Add(script);
|
|
||||||
return script;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@ -21,6 +21,7 @@ namespace Artemis.UI.Providers
|
|||||||
private readonly IInputService _inputService;
|
private readonly IInputService _inputService;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private DateTime _lastMouseUpdate;
|
private DateTime _lastMouseUpdate;
|
||||||
|
private int _lastProcessId;
|
||||||
private SpongeWindow _sponge;
|
private SpongeWindow _sponge;
|
||||||
private System.Timers.Timer _taskManagerTimer;
|
private System.Timers.Timer _taskManagerTimer;
|
||||||
|
|
||||||
@ -88,9 +89,15 @@ namespace Artemis.UI.Providers
|
|||||||
|
|
||||||
private void TaskManagerTimerOnElapsed(object sender, ElapsedEventArgs e)
|
private void TaskManagerTimerOnElapsed(object sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
|
int processId = WindowUtilities.GetActiveProcessId();
|
||||||
|
if (processId == _lastProcessId)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_lastProcessId = processId;
|
||||||
|
|
||||||
// If task manager has focus then we can't track keys properly, release everything to avoid them getting stuck
|
// If task manager has focus then we can't track keys properly, release everything to avoid them getting stuck
|
||||||
// Same goes for Idle which is what you get when you press Ctrl+Alt+Del
|
// Same goes for Idle which is what you get when you press Ctrl+Alt+Del
|
||||||
Process active = Process.GetProcessById(WindowUtilities.GetActiveProcessId());
|
Process active = Process.GetProcessById(processId);
|
||||||
if (active?.ProcessName == "Taskmgr" || active?.ProcessName == "Idle")
|
if (active?.ProcessName == "Taskmgr" || active?.ProcessName == "Idle")
|
||||||
_inputService.ReleaseAll();
|
_inputService.ReleaseAll();
|
||||||
}
|
}
|
||||||
@ -164,7 +171,7 @@ namespace Artemis.UI.Providers
|
|||||||
|
|
||||||
private int _mouseDeltaX;
|
private int _mouseDeltaX;
|
||||||
private int _mouseDeltaY;
|
private int _mouseDeltaY;
|
||||||
|
|
||||||
private void HandleMouseData(RawInputData data, RawInputMouseData mouseData)
|
private void HandleMouseData(RawInputData data, RawInputMouseData mouseData)
|
||||||
{
|
{
|
||||||
// Only submit mouse movement 25 times per second but increment the delta
|
// Only submit mouse movement 25 times per second but increment the delta
|
||||||
|
|||||||
@ -62,7 +62,7 @@
|
|||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Bottom"
|
||||||
Margin="0 0 0 32">
|
Margin="0 0 0 32">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<materialDesign:Card Width="840" Margin="8 16" Height="Auto">
|
<materialDesign:Card Width="852" Margin="8" Height="Auto">
|
||||||
<Grid VerticalAlignment="Stretch">
|
<Grid VerticalAlignment="Stretch">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
@ -86,23 +86,15 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Border Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="0" BorderThickness="0 1 0 0" BorderBrush="{DynamicResource MaterialDesignDivider}" Padding="8">
|
<Border Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="0" BorderThickness="0 1 0 0" BorderBrush="{DynamicResource MaterialDesignDivider}" Padding="8">
|
||||||
<DockPanel>
|
<Button Style="{DynamicResource MaterialDesignFlatButton}"
|
||||||
<Button Style="{DynamicResource MaterialDesignFlatButton}"
|
HorizontalAlignment="Right"
|
||||||
DockPanel.Dock="Right"
|
Command="{s:Action OpenUrl}"
|
||||||
Command="{s:Action OpenUrl}"
|
CommandParameter="https://wiki.artemis-rgb.com/en/guides/user/plugins">
|
||||||
CommandParameter="https://wiki.artemis-rgb.com/en/guides/user/plugins">
|
<StackPanel Orientation="Horizontal">
|
||||||
<StackPanel Orientation="Horizontal">
|
<materialDesign:PackIcon Kind="OpenInBrowser" />
|
||||||
<materialDesign:PackIcon Kind="OpenInBrowser" />
|
<TextBlock Margin="8 0 0 0" VerticalAlignment="Center">Get more plugins</TextBlock>
|
||||||
<TextBlock Margin="8 0 0 0" VerticalAlignment="Center">Get more plugins</TextBlock>
|
</StackPanel>
|
||||||
</StackPanel>
|
</Button>
|
||||||
</Button>
|
|
||||||
<TextBlock Foreground="{DynamicResource MaterialDesignBodyLight}"
|
|
||||||
TextWrapping="Wrap"
|
|
||||||
Margin="16"
|
|
||||||
VerticalAlignment="Center">
|
|
||||||
Want more plugins? You can find them on our wiki.
|
|
||||||
</TextBlock>
|
|
||||||
</DockPanel>
|
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
</materialDesign:Card>
|
</materialDesign:Card>
|
||||||
|
|||||||
@ -3,7 +3,6 @@ using System.Globalization;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Artemis.UI.Shared.Services;
|
using Artemis.UI.Shared.Services;
|
||||||
using Castle.Core.Internal;
|
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
|
|
||||||
@ -70,7 +69,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Dialogs
|
|||||||
if (parts.Length == 1)
|
if (parts.Length == 1)
|
||||||
return TimeSpan.FromSeconds(double.Parse(parts[0]));
|
return TimeSpan.FromSeconds(double.Parse(parts[0]));
|
||||||
// Only milliseconds provided with a leading .
|
// Only milliseconds provided with a leading .
|
||||||
if (parts[0].IsNullOrEmpty())
|
if (string.IsNullOrEmpty(parts[0]))
|
||||||
{
|
{
|
||||||
// Add trailing zeros so 2.5 becomes 2.500, can't seem to make double.Parse do that
|
// Add trailing zeros so 2.5 becomes 2.500, can't seem to make double.Parse do that
|
||||||
while (parts[0].Length < 3) parts[0] += "0";
|
while (parts[0].Length < 3) parts[0] += "0";
|
||||||
|
|||||||
@ -61,6 +61,19 @@
|
|||||||
VerticalContentAlignment="Stretch"
|
VerticalContentAlignment="Stretch"
|
||||||
HorizontalContentAlignment="Stretch"
|
HorizontalContentAlignment="Stretch"
|
||||||
IsTabStop="False" />
|
IsTabStop="False" />
|
||||||
|
|
||||||
|
<Border Grid.Row="1" Visibility="{Binding SidebarViewModel.ActivatingProfile, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay, Delay=2000}">
|
||||||
|
<Border.Background>
|
||||||
|
<SolidColorBrush Color="{Binding Path=Color, Source={StaticResource MaterialDesignToolBarBackground}}" Opacity="0.5"></SolidColorBrush>
|
||||||
|
</Border.Background>
|
||||||
|
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||||
|
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}" Value="0" IsIndeterminate="True" Width="50" Height="50" Margin="20"/>
|
||||||
|
<TextBlock TextAlignment="Center" Style="{StaticResource MaterialDesignHeadline5TextBlock}">
|
||||||
|
Activating profile...
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
|
||||||
<materialDesign:Snackbar Grid.Row="0"
|
<materialDesign:Snackbar Grid.Row="0"
|
||||||
Grid.RowSpan="2"
|
Grid.RowSpan="2"
|
||||||
x:Name="MainSnackbar"
|
x:Name="MainSnackbar"
|
||||||
|
|||||||
@ -96,7 +96,7 @@
|
|||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Style="{StaticResource MaterialDesignBody1TextBlock}"
|
Style="{StaticResource MaterialDesignBody1TextBlock}"
|
||||||
Padding="0">
|
Padding="0">
|
||||||
Robert 'Spoinky' Beekman
|
Robert Beekman
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<TextBlock Grid.Column="1"
|
<TextBlock Grid.Column="1"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
@ -111,7 +111,7 @@
|
|||||||
Style="{StaticResource MaterialDesignIconForegroundButton}"
|
Style="{StaticResource MaterialDesignIconForegroundButton}"
|
||||||
ToolTip="View GitHub profile"
|
ToolTip="View GitHub profile"
|
||||||
Command="{s:Action OpenUrl}"
|
Command="{s:Action OpenUrl}"
|
||||||
CommandParameter="https://github.com/SpoinkyNL/">
|
CommandParameter="https://github.com/RobertWasTaken/">
|
||||||
<materialDesign:PackIcon Kind="Github" Width="20" Height="20" />
|
<materialDesign:PackIcon Kind="Github" Width="20" Height="20" />
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="ArtemisSidebar.xaml" />
|
<ResourceDictionary Source="ArtemisSidebar.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<materialDesign:DialogHost IsTabStop="False" Focusable="False" Identifier="SidebarDialog" DialogTheme="Inherit" DialogMargin="14">
|
<materialDesign:DialogHost IsTabStop="False" Focusable="False" Identifier="SidebarDialog" DialogTheme="Inherit" DialogMargin="14">
|
||||||
@ -74,7 +75,8 @@
|
|||||||
Margin="0 2"
|
Margin="0 2"
|
||||||
ItemContainerStyle="{StaticResource SidebarListBoxItem}"
|
ItemContainerStyle="{StaticResource SidebarListBoxItem}"
|
||||||
ItemsSource="{Binding SidebarScreens}"
|
ItemsSource="{Binding SidebarScreens}"
|
||||||
SelectedItem="{Binding SelectedSidebarScreen}">
|
SelectedItem="{Binding SelectedSidebarScreen}"
|
||||||
|
IsEnabled="{Binding ActivatingProfile, Converter={StaticResource InverseBooleanConverter}}">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" />
|
<ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" />
|
||||||
@ -105,7 +107,11 @@
|
|||||||
dd:DragDrop.DropHandler="{Binding}">
|
dd:DragDrop.DropHandler="{Binding}">
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" />
|
<ContentControl s:View.Model="{Binding}"
|
||||||
|
VerticalContentAlignment="Stretch"
|
||||||
|
HorizontalContentAlignment="Stretch"
|
||||||
|
IsTabStop="False"
|
||||||
|
IsEnabled="{Binding DataContext.ActivatingProfile, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource InverseBooleanConverter}}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
|
|||||||
@ -35,6 +35,7 @@ namespace Artemis.UI.Screens.Sidebar
|
|||||||
private MainScreenViewModel _selectedScreen;
|
private MainScreenViewModel _selectedScreen;
|
||||||
private readonly SidebarScreenViewModel<ProfileEditorViewModel> _profileEditor;
|
private readonly SidebarScreenViewModel<ProfileEditorViewModel> _profileEditor;
|
||||||
private readonly DefaultDropHandler _defaultDropHandler;
|
private readonly DefaultDropHandler _defaultDropHandler;
|
||||||
|
private bool _activatingProfile;
|
||||||
|
|
||||||
public SidebarViewModel(IKernel kernel,
|
public SidebarViewModel(IKernel kernel,
|
||||||
IEventAggregator eventAggregator,
|
IEventAggregator eventAggregator,
|
||||||
@ -96,6 +97,12 @@ namespace Artemis.UI.Screens.Sidebar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ActivatingProfile
|
||||||
|
{
|
||||||
|
get => _activatingProfile;
|
||||||
|
set => SetAndNotify(ref _activatingProfile, value);
|
||||||
|
}
|
||||||
|
|
||||||
private void ActivateScreenViewModel(SidebarScreenViewModel screenViewModel)
|
private void ActivateScreenViewModel(SidebarScreenViewModel screenViewModel)
|
||||||
{
|
{
|
||||||
SelectedScreen = screenViewModel.CreateInstance(_kernel);
|
SelectedScreen = screenViewModel.CreateInstance(_kernel);
|
||||||
@ -155,18 +162,34 @@ namespace Artemis.UI.Screens.Sidebar
|
|||||||
|
|
||||||
if (_profileEditorService.SuspendEditing)
|
if (_profileEditorService.SuspendEditing)
|
||||||
_profileEditorService.SuspendEditing = false;
|
_profileEditorService.SuspendEditing = false;
|
||||||
_profileEditorService.ChangeSelectedProfileConfiguration(profileConfiguration);
|
|
||||||
if (profileConfiguration != null)
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
// Little workaround to clear the selected item in the menu, ugly but oh well
|
try
|
||||||
if (_selectedSidebarScreen != _profileEditor)
|
|
||||||
{
|
{
|
||||||
_selectedSidebarScreen = null;
|
ActivatingProfile = true;
|
||||||
NotifyOfPropertyChange(nameof(SelectedSidebarScreen));
|
_profileEditorService.ChangeSelectedProfileConfiguration(profileConfiguration);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
ActivatingProfile = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectedSidebarScreen = _profileEditor;
|
if (profileConfiguration == null)
|
||||||
}
|
return;
|
||||||
|
|
||||||
|
Execute.PostToUIThread(() =>
|
||||||
|
{
|
||||||
|
// Little workaround to clear the selected item in the menu, ugly but oh well
|
||||||
|
if (_selectedSidebarScreen != _profileEditor)
|
||||||
|
{
|
||||||
|
_selectedSidebarScreen = null;
|
||||||
|
NotifyOfPropertyChange(nameof(SelectedSidebarScreen));
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedSidebarScreen = _profileEditor;
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Overrides of Screen
|
#region Overrides of Screen
|
||||||
@ -212,7 +235,7 @@ namespace Artemis.UI.Screens.Sidebar
|
|||||||
Items[index].ProfileCategory.Order = index;
|
Items[index].ProfileCategory.Order = index;
|
||||||
|
|
||||||
// Bit dumb but gets the job done
|
// Bit dumb but gets the job done
|
||||||
foreach (SidebarCategoryViewModel viewModel in Items)
|
foreach (SidebarCategoryViewModel viewModel in Items)
|
||||||
_profileService.SaveProfileCategory(viewModel.ProfileCategory);
|
_profileService.SaveProfileCategory(viewModel.ProfileCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Artemis.UI.Utilities
|
namespace Artemis.UI.Utilities
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user