mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Windows - Fix crash when clicking on update notification
Meta - Code cleanup
This commit is contained in:
parent
cdd814d920
commit
3994b49f08
@ -91,11 +91,6 @@ public static class Constants
|
||||
/// </summary>
|
||||
public static readonly Plugin CorePlugin = new(CorePluginInfo, new DirectoryInfo(ApplicationFolder), null);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the startup arguments provided to the application
|
||||
/// </summary>
|
||||
public static ReadOnlyCollection<string> StartupArguments { get; set; } = null!;
|
||||
|
||||
internal static readonly CorePluginFeature CorePluginFeature = new() {Plugin = CorePlugin, Profiler = CorePlugin.GetProfiler("Feature - Core")};
|
||||
internal static readonly EffectPlaceholderPlugin EffectPlaceholderPlugin = new() {Plugin = CorePlugin, Profiler = CorePlugin.GetProfiler("Feature - Effect Placeholder")};
|
||||
|
||||
@ -153,6 +148,11 @@ public static class Constants
|
||||
typeof(decimal)
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the startup arguments provided to the application
|
||||
/// </summary>
|
||||
public static ReadOnlyCollection<string> StartupArguments { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the graphics context to be used for rendering by SkiaSharp. Can be set via
|
||||
/// <see cref="IRgbService.UpdateGraphicsContext" />.
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Provides data for layer property events.
|
||||
/// </summary>
|
||||
@ -17,4 +17,3 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public ILayerPropertyKeyframe Keyframe { get; }
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Core.Services;
|
||||
|
||||
|
||||
20
src/Artemis.Core/Services/ProcessMonitor/ProcessComparer.cs
Normal file
20
src/Artemis.Core/Services/ProcessMonitor/ProcessComparer.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Artemis.Core.Services;
|
||||
|
||||
internal class ProcessComparer : IEqualityComparer<Process>
|
||||
{
|
||||
public bool Equals(Process? x, Process? y)
|
||||
{
|
||||
if (x == null && y == null) return true;
|
||||
if (x == null || y == null) return false;
|
||||
return x.Id == y.Id && x.ProcessName == y.ProcessName && x.SessionId == y.SessionId;
|
||||
}
|
||||
|
||||
public int GetHashCode(Process? obj)
|
||||
{
|
||||
if (obj == null) return 0;
|
||||
return obj.Id;
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,6 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
using Artemis.Core.Modules;
|
||||
using Serilog;
|
||||
|
||||
namespace Artemis.Core.Services;
|
||||
|
||||
@ -43,19 +42,3 @@ internal class ProcessMonitorService : IProcessMonitorService
|
||||
return _lastScannedProcesses;
|
||||
}
|
||||
}
|
||||
|
||||
internal class ProcessComparer : IEqualityComparer<Process>
|
||||
{
|
||||
public bool Equals(Process? x, Process? y)
|
||||
{
|
||||
if (x == null && y == null) return true;
|
||||
if (x == null || y == null) return false;
|
||||
return x.Id == y.Id && x.ProcessName == y.ProcessName && x.SessionId == y.SessionId;
|
||||
}
|
||||
|
||||
public int GetHashCode(Process? obj)
|
||||
{
|
||||
if (obj == null) return 0;
|
||||
return obj.Id;
|
||||
}
|
||||
}
|
||||
@ -38,6 +38,24 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
StartWebServer();
|
||||
}
|
||||
|
||||
public event EventHandler? WebServerStopped;
|
||||
public event EventHandler? WebServerStarted;
|
||||
|
||||
protected virtual void OnWebServerStopped()
|
||||
{
|
||||
WebServerStopped?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnWebServerStarting()
|
||||
{
|
||||
WebServerStarting?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnWebServerStarted()
|
||||
{
|
||||
WebServerStarted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void WebServerEnabledSettingOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
StartWebServer();
|
||||
@ -76,6 +94,7 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
|
||||
public WebServer? Server { get; private set; }
|
||||
public PluginsModule PluginsModule { get; }
|
||||
public event EventHandler? WebServerStarting;
|
||||
|
||||
|
||||
#region Web server managament
|
||||
@ -302,27 +321,4 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
protected virtual void OnWebServerStopped()
|
||||
{
|
||||
WebServerStopped?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnWebServerStarting()
|
||||
{
|
||||
WebServerStarting?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnWebServerStarted()
|
||||
{
|
||||
WebServerStarted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event EventHandler? WebServerStopped;
|
||||
public event EventHandler? WebServerStarting;
|
||||
public event EventHandler? WebServerStarted;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -160,10 +160,25 @@ public readonly struct Numeric : IComparable<Numeric>, IConvertible
|
||||
return (byte) Math.Clamp(p._value, 0, 255);
|
||||
}
|
||||
|
||||
public static implicit operator Numeric(double d) => new(d);
|
||||
public static implicit operator Numeric(float f) => new(f);
|
||||
public static implicit operator Numeric(int i) => new(i);
|
||||
public static implicit operator Numeric(byte b) => new(b);
|
||||
public static implicit operator Numeric(double d)
|
||||
{
|
||||
return new(d);
|
||||
}
|
||||
|
||||
public static implicit operator Numeric(float f)
|
||||
{
|
||||
return new(f);
|
||||
}
|
||||
|
||||
public static implicit operator Numeric(int i)
|
||||
{
|
||||
return new(i);
|
||||
}
|
||||
|
||||
public static implicit operator Numeric(byte b)
|
||||
{
|
||||
return new(b);
|
||||
}
|
||||
|
||||
public static implicit operator long(Numeric p)
|
||||
{
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Core;
|
||||
@ -111,10 +109,14 @@ public sealed class InputPin : Pin
|
||||
Value = Type.GetDefault()!;
|
||||
}
|
||||
else if (ConnectedTo.Count > 0)
|
||||
{
|
||||
Value = ConnectedTo[0].PinValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
Value = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -85,7 +85,10 @@ public interface IPin
|
||||
/// Determines whether this pin is compatible with the given type
|
||||
/// </summary>
|
||||
/// <param name="type">The type to check for compatibility</param>
|
||||
/// <param name="forgivingEnumMatching">A boolean indicating whether or not enums should be exactly equal or just both be enums</param>
|
||||
/// <param name="forgivingEnumMatching">
|
||||
/// A boolean indicating whether or not enums should be exactly equal or just both be
|
||||
/// enums
|
||||
/// </param>
|
||||
/// <returns><see langword="true" /> if the type is compatible, otherwise <see langword="false" />.</returns>
|
||||
public bool IsTypeCompatible(Type type, bool forgivingEnumMatching = true);
|
||||
}
|
||||
@ -26,6 +26,17 @@ internal class DataBindingExitNode<TLayerProperty> : Node, IExitNode
|
||||
property.SetValue(pendingValue);
|
||||
}
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
foreach ((IDataBindingProperty? property, InputPin? inputPin) in _propertyPins)
|
||||
{
|
||||
if (inputPin.ConnectedTo.Any())
|
||||
_propertyValues[property] = inputPin.Value!;
|
||||
else
|
||||
_propertyValues.Remove(property);
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearInputPins()
|
||||
{
|
||||
while (Pins.Any())
|
||||
@ -59,15 +70,4 @@ internal class DataBindingExitNode<TLayerProperty> : Node, IExitNode
|
||||
}
|
||||
|
||||
public override bool IsExitNode => true;
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
foreach ((IDataBindingProperty? property, InputPin? inputPin) in _propertyPins)
|
||||
{
|
||||
if (inputPin.ConnectedTo.Any())
|
||||
_propertyValues[property] = inputPin.Value!;
|
||||
else
|
||||
_propertyValues.Remove(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,19 @@ namespace Artemis.Core;
|
||||
/// </summary>
|
||||
public abstract class NodeScript : CorePropertyChanged, INodeScript
|
||||
{
|
||||
private void NodeTypeStoreOnNodeTypeAdded(object? sender, NodeTypeStoreEvent e)
|
||||
{
|
||||
if (Entity.Nodes.Any(n => e.TypeRegistration.MatchesEntity(n)))
|
||||
Load();
|
||||
}
|
||||
|
||||
private void NodeTypeStoreOnNodeTypeRemoved(object? sender, NodeTypeStoreEvent e)
|
||||
{
|
||||
List<INode> nodes = Nodes.Where(n => n.GetType() == e.TypeRegistration.NodeData.Type).ToList();
|
||||
foreach (INode node in nodes)
|
||||
RemoveNode(node);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<SingleValueEventArgs<INode>>? NodeAdded;
|
||||
|
||||
@ -374,19 +387,6 @@ public abstract class NodeScript : CorePropertyChanged, INodeScript
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void NodeTypeStoreOnNodeTypeAdded(object? sender, NodeTypeStoreEvent e)
|
||||
{
|
||||
if (Entity.Nodes.Any(n => e.TypeRegistration.MatchesEntity(n)))
|
||||
Load();
|
||||
}
|
||||
|
||||
private void NodeTypeStoreOnNodeTypeRemoved(object? sender, NodeTypeStoreEvent e)
|
||||
{
|
||||
List<INode> nodes = Nodes.Where(n => n.GetType() == e.TypeRegistration.NodeData.Type).ToList();
|
||||
foreach (INode node in nodes)
|
||||
RemoveNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Core;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Events;
|
||||
|
||||
namespace Artemis.Core;
|
||||
|
||||
@ -33,14 +33,12 @@ public class LinuxInputProvider : InputProvider
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
for (int i = _readers.Count - 1; i >= 0; i--)
|
||||
{
|
||||
_readers[i].InputEvent -= OnInputEvent;
|
||||
_readers[i].Dispose();
|
||||
_readers.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ using Avalonia.Controls;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Xaml.Interactivity;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
|
||||
namespace Artemis.UI.Shared.Behaviors;
|
||||
|
||||
|
||||
@ -19,12 +19,12 @@ public interface IMainWindowService : IArtemisSharedUIService
|
||||
void ConfigureMainWindowProvider(IMainWindowProvider mainWindowProvider);
|
||||
|
||||
/// <summary>
|
||||
/// Opens the main window if it is not already open
|
||||
/// Opens the main window if it is not already open, must be called on the UI thread
|
||||
/// </summary>
|
||||
void OpenMainWindow();
|
||||
|
||||
/// <summary>
|
||||
/// Closes the main window if it is not already closed
|
||||
/// Closes the main window if it is not already closed, must be called on the UI thread
|
||||
/// </summary>
|
||||
void CloseMainWindow();
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
@ -9,9 +8,9 @@ namespace Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
/// </summary>
|
||||
public class ConnectPins : INodeEditorCommand
|
||||
{
|
||||
private readonly IPin _output;
|
||||
private readonly IPin _input;
|
||||
private readonly IPin? _originalConnection;
|
||||
private readonly IPin _output;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="ConnectPins" /> class.
|
||||
|
||||
@ -24,11 +24,6 @@ public class App : Application
|
||||
private StandardKernel? _kernel;
|
||||
private bool _shutDown;
|
||||
|
||||
// ReSharper disable NotAccessedField.Local
|
||||
private ApplicationStateManager? _applicationStateManager;
|
||||
private Mutex? _artemisMutex;
|
||||
// ReSharper restore NotAccessedField.Local
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
// If Artemis is already running, bring it to foreground and stop this process
|
||||
@ -110,4 +105,10 @@ public class App : Application
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ReSharper disable NotAccessedField.Local
|
||||
private ApplicationStateManager? _applicationStateManager;
|
||||
|
||||
private Mutex? _artemisMutex;
|
||||
// ReSharper restore NotAccessedField.Local
|
||||
}
|
||||
@ -17,10 +17,10 @@ public class WindowsInputProvider : InputProvider
|
||||
|
||||
private readonly IInputService _inputService;
|
||||
private readonly ILogger _logger;
|
||||
private readonly SpongeWindow _sponge;
|
||||
private readonly Timer _taskManagerTimer;
|
||||
private DateTime _lastMouseUpdate;
|
||||
private int _lastProcessId;
|
||||
private readonly SpongeWindow _sponge;
|
||||
|
||||
public WindowsInputProvider(ILogger logger, IInputService inputService)
|
||||
{
|
||||
|
||||
@ -24,8 +24,8 @@ namespace Artemis.UI.Windows.Providers;
|
||||
|
||||
public class UpdateProvider : IUpdateProvider, IDisposable
|
||||
{
|
||||
private const string ApiUrl = "https://dev.azure.com/artemis-rgb/Artemis/_apis/";
|
||||
private const string InstallerUrl = "https://builds.artemis-rgb.com/binaries/Artemis.Installer.exe";
|
||||
private const string API_URL = "https://dev.azure.com/artemis-rgb/Artemis/_apis/";
|
||||
private const string INSTALLER_URL = "https://builds.artemis-rgb.com/binaries/Artemis.Installer.exe";
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMainWindowService _mainWindowService;
|
||||
@ -42,7 +42,7 @@ public class UpdateProvider : IUpdateProvider, IDisposable
|
||||
|
||||
public async Task<DevOpsBuild?> GetBuildInfo(int buildDefinition, string? buildNumber = null)
|
||||
{
|
||||
Url request = ApiUrl.AppendPathSegments("build", "builds")
|
||||
Url request = API_URL.AppendPathSegments("build", "builds")
|
||||
.SetQueryParam("definitions", buildDefinition)
|
||||
.SetQueryParam("resultFilter", "succeeded")
|
||||
.SetQueryParam("$top", 1)
|
||||
@ -143,9 +143,9 @@ public class UpdateProvider : IUpdateProvider, IDisposable
|
||||
string installerDirectory = Path.Combine(Constants.DataFolder, "installer");
|
||||
string installerPath = Path.Combine(installerDirectory, "Artemis.Installer.exe");
|
||||
|
||||
_logger.Information("UpdateInstaller: Downloading installer from {DownloadUrl}", InstallerUrl);
|
||||
_logger.Information("UpdateInstaller: Downloading installer from {DownloadUrl}", INSTALLER_URL);
|
||||
using HttpClient client = new();
|
||||
HttpResponseMessage httpResponseMessage = await client.GetAsync(InstallerUrl);
|
||||
HttpResponseMessage httpResponseMessage = await client.GetAsync(INSTALLER_URL);
|
||||
if (!httpResponseMessage.IsSuccessStatusCode)
|
||||
throw new ArtemisUIException($"Failed to download installer, status code {httpResponseMessage.StatusCode}");
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Ninject;
|
||||
|
||||
@ -2,6 +2,7 @@ using System;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Shared.Services.MainWindow;
|
||||
using Avalonia.Threading;
|
||||
using EmbedIO;
|
||||
using EmbedIO.Routing;
|
||||
using EmbedIO.WebApi;
|
||||
@ -22,7 +23,7 @@ public class RemoteController : WebApiController
|
||||
[Route(HttpVerbs.Post, "/remote/bring-to-foreground")]
|
||||
public void PostBringToForeground()
|
||||
{
|
||||
_mainWindowService.OpenMainWindow();
|
||||
Dispatcher.UIThread.Post(() => _mainWindowService.OpenMainWindow());
|
||||
}
|
||||
|
||||
[Route(HttpVerbs.Post, "/remote/restart")]
|
||||
|
||||
@ -37,6 +37,16 @@ public class DevicePropertiesViewModel : DialogViewModelBase<object>
|
||||
ClearSelectedLeds = ReactiveCommand.Create(ExecuteClearSelectedLeds);
|
||||
}
|
||||
|
||||
public ArtemisDevice Device
|
||||
{
|
||||
get => _device;
|
||||
set => RaiseAndSetIfChanged(ref _device, value);
|
||||
}
|
||||
|
||||
public ObservableCollection<ArtemisLed> SelectedLeds { get; }
|
||||
public ObservableCollection<ActivatableViewModelBase> Tabs { get; }
|
||||
public ReactiveCommand<Unit, Unit> ClearSelectedLeds { get; }
|
||||
|
||||
private void RgbServiceOnDeviceAdded(object? sender, DeviceEventArgs e)
|
||||
{
|
||||
if (e.Device.Identifier != Device.Identifier || Device == e.Device)
|
||||
@ -52,16 +62,6 @@ public class DevicePropertiesViewModel : DialogViewModelBase<object>
|
||||
SelectedLeds.Clear();
|
||||
}
|
||||
|
||||
public ArtemisDevice Device
|
||||
{
|
||||
get => _device;
|
||||
set => RaiseAndSetIfChanged(ref _device, value);
|
||||
}
|
||||
|
||||
public ObservableCollection<ArtemisLed> SelectedLeds { get; }
|
||||
public ObservableCollection<ActivatableViewModelBase> Tabs { get; }
|
||||
public ReactiveCommand<Unit, Unit> ClearSelectedLeds { get; }
|
||||
|
||||
private void AddTabs()
|
||||
{
|
||||
Tabs.Add(_deviceVmFactory.DevicePropertiesTabViewModel(Device));
|
||||
|
||||
@ -15,10 +15,10 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree;
|
||||
|
||||
public class ProfileTreeView : ReactiveUserControl<ProfileTreeViewModel>
|
||||
{
|
||||
private readonly TreeView _treeView;
|
||||
private Image? _dragAdorner;
|
||||
private Point _dragStartPosition;
|
||||
private Point _elementDragOffset;
|
||||
private readonly TreeView _treeView;
|
||||
|
||||
public ProfileTreeView()
|
||||
{
|
||||
|
||||
@ -293,6 +293,7 @@ public abstract class TreeItemViewModel : ActivatableViewModelBase
|
||||
CanPaste = false;
|
||||
return;
|
||||
}
|
||||
|
||||
CanPaste = formats.Contains(ProfileElementExtensions.ClipboardDataFormat);
|
||||
}
|
||||
|
||||
|
||||
@ -22,10 +22,10 @@ public class DataBindingViewModel : ActivatableViewModelBase
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly IWindowService _windowService;
|
||||
private ObservableAsPropertyHelper<bool>? _dataBindingEnabled;
|
||||
private bool _editorOpen;
|
||||
private ObservableAsPropertyHelper<ILayerProperty?>? _layerProperty;
|
||||
private ObservableAsPropertyHelper<NodeScriptViewModel?>? _nodeScriptViewModel;
|
||||
private bool _playing;
|
||||
private bool _editorOpen;
|
||||
|
||||
public DataBindingViewModel(IProfileEditorService profileEditorService, INodeVmFactory nodeVmFactory, IWindowService windowService, ISettingsService settingsService)
|
||||
{
|
||||
|
||||
@ -22,9 +22,9 @@ namespace Artemis.UI.Screens.ProfileEditor;
|
||||
|
||||
public class ProfileEditorViewModel : MainScreenViewModel
|
||||
{
|
||||
private readonly IMainWindowService _mainWindowService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IMainWindowService _mainWindowService;
|
||||
private readonly SourceList<IToolViewModel> _tools;
|
||||
private DisplayConditionScriptViewModel? _displayConditionScriptViewModel;
|
||||
private ObservableAsPropertyHelper<ProfileEditorHistory?>? _history;
|
||||
|
||||
@ -161,8 +161,6 @@ public class RootViewModel : ActivatableViewModelBase, IScreen, IMainWindowProvi
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OpenMainWindow()
|
||||
{
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
if (_lifeTime.MainWindow == null)
|
||||
{
|
||||
@ -175,7 +173,6 @@ public class RootViewModel : ActivatableViewModelBase, IScreen, IMainWindowProvi
|
||||
_lifeTime.MainWindow.WindowState = WindowState.Normal;
|
||||
_lifeTime.MainWindow.Activate();
|
||||
OnMainWindowOpened();
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -21,8 +21,8 @@ public class SurfaceEditorViewModel : MainScreenViewModel
|
||||
private readonly IDeviceService _deviceService;
|
||||
private readonly IDeviceVmFactory _deviceVmFactory;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly ISurfaceVmFactory _surfaceVmFactory;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly ISurfaceVmFactory _surfaceVmFactory;
|
||||
private readonly IWindowService _windowService;
|
||||
private bool _colorDevices;
|
||||
private bool _colorFirstLedOnly;
|
||||
@ -72,27 +72,6 @@ public class SurfaceEditorViewModel : MainScreenViewModel
|
||||
});
|
||||
}
|
||||
|
||||
private void RgbServiceOnDeviceAdded(object? sender, DeviceEventArgs e)
|
||||
{
|
||||
if (!e.Device.IsEnabled)
|
||||
return;
|
||||
|
||||
SurfaceDeviceViewModels.Add(_surfaceVmFactory.SurfaceDeviceViewModel(e.Device, this));
|
||||
ListDeviceViewModels.Add(_surfaceVmFactory.ListDeviceViewModel(e.Device, this));
|
||||
SurfaceDeviceViewModels.Sort(l => l.Device.ZIndex * -1);
|
||||
ListDeviceViewModels.Sort(l => l.Device.ZIndex * -1);
|
||||
}
|
||||
|
||||
private void RgbServiceOnDeviceRemoved(object? sender, DeviceEventArgs e)
|
||||
{
|
||||
SurfaceDeviceViewModel? surfaceVm = SurfaceDeviceViewModels.FirstOrDefault(vm => vm.Device == e.Device);
|
||||
ListDeviceViewModel? listVm = ListDeviceViewModels.FirstOrDefault(vm => vm.Device == e.Device);
|
||||
if (surfaceVm != null)
|
||||
SurfaceDeviceViewModels.Remove(surfaceVm);
|
||||
if (listVm != null)
|
||||
ListDeviceViewModels.Remove(listVm);
|
||||
}
|
||||
|
||||
public bool ColorDevices
|
||||
{
|
||||
get => _colorDevices;
|
||||
@ -180,6 +159,27 @@ public class SurfaceEditorViewModel : MainScreenViewModel
|
||||
surfaceDeviceViewModel.UpdateMouseDrag(mousePosition, round, ignoreOverlap);
|
||||
}
|
||||
|
||||
private void RgbServiceOnDeviceAdded(object? sender, DeviceEventArgs e)
|
||||
{
|
||||
if (!e.Device.IsEnabled)
|
||||
return;
|
||||
|
||||
SurfaceDeviceViewModels.Add(_surfaceVmFactory.SurfaceDeviceViewModel(e.Device, this));
|
||||
ListDeviceViewModels.Add(_surfaceVmFactory.ListDeviceViewModel(e.Device, this));
|
||||
SurfaceDeviceViewModels.Sort(l => l.Device.ZIndex * -1);
|
||||
ListDeviceViewModels.Sort(l => l.Device.ZIndex * -1);
|
||||
}
|
||||
|
||||
private void RgbServiceOnDeviceRemoved(object? sender, DeviceEventArgs e)
|
||||
{
|
||||
SurfaceDeviceViewModel? surfaceVm = SurfaceDeviceViewModels.FirstOrDefault(vm => vm.Device == e.Device);
|
||||
ListDeviceViewModel? listVm = ListDeviceViewModels.FirstOrDefault(vm => vm.Device == e.Device);
|
||||
if (surfaceVm != null)
|
||||
SurfaceDeviceViewModels.Remove(surfaceVm);
|
||||
if (listVm != null)
|
||||
ListDeviceViewModels.Remove(listVm);
|
||||
}
|
||||
|
||||
private async Task ExecuteAutoArrange()
|
||||
{
|
||||
bool confirmed = await _windowService.ShowConfirmContentDialog("Auto-arrange layout", "Are you sure you want to auto-arrange your layout? Your current settings will be overwritten.");
|
||||
|
||||
@ -12,7 +12,6 @@ using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.NodeEditor;
|
||||
using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using Avalonia;
|
||||
using Avalonia.Threading;
|
||||
using DynamicData;
|
||||
@ -25,8 +24,8 @@ public class NodeScriptWindowViewModel : DialogViewModelBase<bool>
|
||||
{
|
||||
private readonly INodeEditorService _nodeEditorService;
|
||||
private readonly INodeService _nodeService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IWindowService _windowService;
|
||||
|
||||
public NodeScriptWindowViewModel(NodeScript nodeScript,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user