mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Data model debugger - Fixed dictionaries causing the debugger to fail
Data model debugger - Added realtime updating (can be disabled)
This commit is contained in:
parent
3c29c3aeeb
commit
41b8038b74
@ -213,9 +213,25 @@ namespace Artemis.Core
|
||||
Expression? expression = Expression.Convert(parameter, Target.GetType());
|
||||
Expression? nullCondition = null;
|
||||
|
||||
MethodInfo equals = typeof(object).GetMethod("Equals", BindingFlags.Static | BindingFlags.Public)!;
|
||||
foreach (DataModelPathSegment segment in _segments)
|
||||
{
|
||||
BinaryExpression notNull = Expression.NotEqual(expression, Expression.Default(expression.Type));
|
||||
BinaryExpression notNull;
|
||||
try
|
||||
{
|
||||
notNull = Expression.NotEqual(expression, Expression.Default(expression.Type));
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
notNull = Expression.NotEqual(
|
||||
Expression.Call(
|
||||
null,
|
||||
equals,
|
||||
Expression.Convert(expression, typeof(object)),
|
||||
Expression.Convert(Expression.Default(expression.Type), typeof(object))),
|
||||
Expression.Constant(true));
|
||||
}
|
||||
|
||||
nullCondition = nullCondition != null ? Expression.AndAlso(nullCondition, notNull) : notNull;
|
||||
expression = segment.Initialize(parameter, expression, nullCondition);
|
||||
if (expression == null)
|
||||
|
||||
@ -19,6 +19,10 @@
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0" Margin="0 0 0 5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
@ -48,6 +52,17 @@
|
||||
IsEnabled="{Binding IsModuleFilterEnabled}"
|
||||
SelectedItem="{Binding SelectedModule}"
|
||||
ItemsSource="{Binding Modules}" />
|
||||
|
||||
<StackPanel Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Orientation="Horizontal"
|
||||
Margin="0 10 0 0"
|
||||
ToolTip="Check to update values every half second instead of realtime">
|
||||
<TextBlock VerticalAlignment="Center">Slow updates</TextBlock>
|
||||
<ToggleButton VerticalAlignment="Center" Margin="5 0" Style="{StaticResource MaterialDesignSwitchToggleButton}" IsChecked="{Binding SlowUpdates}" />
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
<TreeView Grid.Row="1" ItemsSource="{Binding MainDataModel.Children}" HorizontalContentAlignment="Stretch">
|
||||
<TreeView.Resources>
|
||||
|
||||
@ -20,12 +20,13 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
||||
private DataModelPropertiesViewModel _mainDataModel;
|
||||
private string _propertySearch;
|
||||
private Module _selectedModule;
|
||||
private bool _slowUpdates;
|
||||
|
||||
public DataModelDebugViewModel(IDataModelUIService dataModelUIService, IPluginManagementService pluginManagementService)
|
||||
{
|
||||
_dataModelUIService = dataModelUIService;
|
||||
_pluginManagementService = pluginManagementService;
|
||||
_updateTimer = new Timer(500);
|
||||
_updateTimer = new Timer(25);
|
||||
|
||||
DisplayName = "Data model";
|
||||
Modules = new BindableCollection<Module>();
|
||||
@ -43,6 +44,16 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
||||
set => SetAndNotify(ref _propertySearch, value);
|
||||
}
|
||||
|
||||
public bool SlowUpdates
|
||||
{
|
||||
get => _slowUpdates;
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _slowUpdates, value);
|
||||
_updateTimer.Interval = _slowUpdates ? 500 : 25;
|
||||
}
|
||||
}
|
||||
|
||||
public BindableCollection<Module> Modules { get; }
|
||||
|
||||
public Module SelectedModule
|
||||
|
||||
@ -16,7 +16,6 @@ using Artemis.UI.Shared.Services;
|
||||
using Flurl;
|
||||
using Flurl.Http;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Serilog;
|
||||
using File = System.IO.File;
|
||||
|
||||
@ -27,8 +26,8 @@ namespace Artemis.UI.Services
|
||||
private const string ApiUrl = "https://dev.azure.com/artemis-rgb/Artemis/_apis/";
|
||||
private readonly PluginSetting<bool> _autoInstallUpdates;
|
||||
private readonly PluginSetting<bool> _checkForUpdates;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMessageService _messageService;
|
||||
private readonly IWindowService _windowService;
|
||||
|
||||
@ -46,6 +45,32 @@ namespace Artemis.UI.Services
|
||||
_checkForUpdates.SettingChanged += CheckForUpdatesOnSettingChanged;
|
||||
}
|
||||
|
||||
private async Task OfferUpdate(DevOpsBuild buildInfo)
|
||||
{
|
||||
await _dialogService.ShowDialog<UpdateDialogViewModel>(new Dictionary<string, object> {{"buildInfo", buildInfo}});
|
||||
}
|
||||
|
||||
private async Task UpdateInstaller()
|
||||
{
|
||||
string downloadUrl = "https://builds.artemis-rgb.com/binaries/Artemis.Installer.exe";
|
||||
string installerDirectory = Path.Combine(Constants.ApplicationFolder, "Installer");
|
||||
string installerPath = Path.Combine(installerDirectory, "Artemis.Installer.exe");
|
||||
|
||||
_logger.Information("UpdateInstaller: Downloading installer from {downloadUrl}", downloadUrl);
|
||||
using HttpClient client = new();
|
||||
HttpResponseMessage httpResponseMessage = await client.GetAsync(downloadUrl);
|
||||
if (!httpResponseMessage.IsSuccessStatusCode)
|
||||
throw new ArtemisUIException($"Failed to download installer, status code {httpResponseMessage.StatusCode}");
|
||||
|
||||
_logger.Information("UpdateInstaller: Writing installer file to {installerPath}", installerPath);
|
||||
if (File.Exists(installerPath))
|
||||
File.Delete(installerPath);
|
||||
|
||||
Core.Utilities.CreateAccessibleDirectory(installerDirectory);
|
||||
await using FileStream fs = new(installerPath, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
await httpResponseMessage.Content.CopyToAsync(fs);
|
||||
}
|
||||
|
||||
public async Task<bool> AutoUpdate()
|
||||
{
|
||||
if (!_checkForUpdates.Value)
|
||||
@ -68,7 +93,9 @@ namespace Artemis.UI.Services
|
||||
return false;
|
||||
|
||||
if (_windowService.IsMainWindowOpen)
|
||||
{
|
||||
await OfferUpdate(buildInfo);
|
||||
}
|
||||
else if (_autoInstallUpdates.Value)
|
||||
{
|
||||
// Lets go
|
||||
@ -92,11 +119,6 @@ namespace Artemis.UI.Services
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task OfferUpdate(DevOpsBuild buildInfo)
|
||||
{
|
||||
await _dialogService.ShowDialog<UpdateDialogViewModel>(new Dictionary<string, object> {{"buildInfo", buildInfo}});
|
||||
}
|
||||
|
||||
public async Task<bool> IsUpdateAvailable()
|
||||
{
|
||||
DevOpsBuild buildInfo = await GetBuildInfo(1);
|
||||
@ -114,7 +136,9 @@ namespace Artemis.UI.Services
|
||||
|
||||
// Always update installer if it is missing ^^
|
||||
if (!File.Exists(installerPath))
|
||||
{
|
||||
await UpdateInstaller();
|
||||
}
|
||||
// Compare the creation date of the installer with the build date and update if needed
|
||||
else
|
||||
{
|
||||
@ -182,27 +206,6 @@ namespace Artemis.UI.Services
|
||||
.GetJsonAsync<GitHubDifference>();
|
||||
}
|
||||
|
||||
private async Task UpdateInstaller()
|
||||
{
|
||||
string downloadUrl = "https://builds.artemis-rgb.com/binaries/Artemis.Installer.exe";
|
||||
string installerDirectory = Path.Combine(Constants.ApplicationFolder, "Installer");
|
||||
string installerPath = Path.Combine(installerDirectory, "Artemis.Installer.exe");
|
||||
|
||||
_logger.Information("UpdateInstaller: Downloading installer from {downloadUrl}", downloadUrl);
|
||||
using HttpClient client = new();
|
||||
HttpResponseMessage httpResponseMessage = await client.GetAsync(downloadUrl);
|
||||
if (!httpResponseMessage.IsSuccessStatusCode)
|
||||
throw new ArtemisUIException($"Failed to download installer, status code {httpResponseMessage.StatusCode}");
|
||||
|
||||
_logger.Information("UpdateInstaller: Writing installer file to {installerPath}", installerPath);
|
||||
if (File.Exists(installerPath))
|
||||
File.Delete(installerPath);
|
||||
else if (!Directory.Exists(installerDirectory))
|
||||
Directory.CreateDirectory(installerDirectory);
|
||||
await using FileStream fs = new(installerPath, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
await httpResponseMessage.Content.CopyToAsync(fs);
|
||||
}
|
||||
|
||||
#region Event handlers
|
||||
|
||||
private void CheckForUpdatesOnSettingChanged(object sender, EventArgs e)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user