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? expression = Expression.Convert(parameter, Target.GetType());
|
||||||
Expression? nullCondition = null;
|
Expression? nullCondition = null;
|
||||||
|
|
||||||
|
MethodInfo equals = typeof(object).GetMethod("Equals", BindingFlags.Static | BindingFlags.Public)!;
|
||||||
foreach (DataModelPathSegment segment in _segments)
|
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;
|
nullCondition = nullCondition != null ? Expression.AndAlso(nullCondition, notNull) : notNull;
|
||||||
expression = segment.Initialize(parameter, expression, nullCondition);
|
expression = segment.Initialize(parameter, expression, nullCondition);
|
||||||
if (expression == null)
|
if (expression == null)
|
||||||
|
|||||||
@ -19,6 +19,10 @@
|
|||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid Grid.Row="0" Margin="0 0 0 5">
|
<Grid Grid.Row="0" Margin="0 0 0 5">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
@ -48,6 +52,17 @@
|
|||||||
IsEnabled="{Binding IsModuleFilterEnabled}"
|
IsEnabled="{Binding IsModuleFilterEnabled}"
|
||||||
SelectedItem="{Binding SelectedModule}"
|
SelectedItem="{Binding SelectedModule}"
|
||||||
ItemsSource="{Binding Modules}" />
|
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>
|
</Grid>
|
||||||
<TreeView Grid.Row="1" ItemsSource="{Binding MainDataModel.Children}" HorizontalContentAlignment="Stretch">
|
<TreeView Grid.Row="1" ItemsSource="{Binding MainDataModel.Children}" HorizontalContentAlignment="Stretch">
|
||||||
<TreeView.Resources>
|
<TreeView.Resources>
|
||||||
|
|||||||
@ -20,12 +20,13 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
|||||||
private DataModelPropertiesViewModel _mainDataModel;
|
private DataModelPropertiesViewModel _mainDataModel;
|
||||||
private string _propertySearch;
|
private string _propertySearch;
|
||||||
private Module _selectedModule;
|
private Module _selectedModule;
|
||||||
|
private bool _slowUpdates;
|
||||||
|
|
||||||
public DataModelDebugViewModel(IDataModelUIService dataModelUIService, IPluginManagementService pluginManagementService)
|
public DataModelDebugViewModel(IDataModelUIService dataModelUIService, IPluginManagementService pluginManagementService)
|
||||||
{
|
{
|
||||||
_dataModelUIService = dataModelUIService;
|
_dataModelUIService = dataModelUIService;
|
||||||
_pluginManagementService = pluginManagementService;
|
_pluginManagementService = pluginManagementService;
|
||||||
_updateTimer = new Timer(500);
|
_updateTimer = new Timer(25);
|
||||||
|
|
||||||
DisplayName = "Data model";
|
DisplayName = "Data model";
|
||||||
Modules = new BindableCollection<Module>();
|
Modules = new BindableCollection<Module>();
|
||||||
@ -43,6 +44,16 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
|||||||
set => SetAndNotify(ref _propertySearch, value);
|
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 BindableCollection<Module> Modules { get; }
|
||||||
|
|
||||||
public Module SelectedModule
|
public Module SelectedModule
|
||||||
|
|||||||
@ -16,7 +16,6 @@ using Artemis.UI.Shared.Services;
|
|||||||
using Flurl;
|
using Flurl;
|
||||||
using Flurl.Http;
|
using Flurl.Http;
|
||||||
using MaterialDesignThemes.Wpf;
|
using MaterialDesignThemes.Wpf;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using File = System.IO.File;
|
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 const string ApiUrl = "https://dev.azure.com/artemis-rgb/Artemis/_apis/";
|
||||||
private readonly PluginSetting<bool> _autoInstallUpdates;
|
private readonly PluginSetting<bool> _autoInstallUpdates;
|
||||||
private readonly PluginSetting<bool> _checkForUpdates;
|
private readonly PluginSetting<bool> _checkForUpdates;
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IDialogService _dialogService;
|
private readonly IDialogService _dialogService;
|
||||||
|
private readonly ILogger _logger;
|
||||||
private readonly IMessageService _messageService;
|
private readonly IMessageService _messageService;
|
||||||
private readonly IWindowService _windowService;
|
private readonly IWindowService _windowService;
|
||||||
|
|
||||||
@ -46,6 +45,32 @@ namespace Artemis.UI.Services
|
|||||||
_checkForUpdates.SettingChanged += CheckForUpdatesOnSettingChanged;
|
_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()
|
public async Task<bool> AutoUpdate()
|
||||||
{
|
{
|
||||||
if (!_checkForUpdates.Value)
|
if (!_checkForUpdates.Value)
|
||||||
@ -68,7 +93,9 @@ namespace Artemis.UI.Services
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_windowService.IsMainWindowOpen)
|
if (_windowService.IsMainWindowOpen)
|
||||||
|
{
|
||||||
await OfferUpdate(buildInfo);
|
await OfferUpdate(buildInfo);
|
||||||
|
}
|
||||||
else if (_autoInstallUpdates.Value)
|
else if (_autoInstallUpdates.Value)
|
||||||
{
|
{
|
||||||
// Lets go
|
// Lets go
|
||||||
@ -92,11 +119,6 @@ namespace Artemis.UI.Services
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OfferUpdate(DevOpsBuild buildInfo)
|
|
||||||
{
|
|
||||||
await _dialogService.ShowDialog<UpdateDialogViewModel>(new Dictionary<string, object> {{"buildInfo", buildInfo}});
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> IsUpdateAvailable()
|
public async Task<bool> IsUpdateAvailable()
|
||||||
{
|
{
|
||||||
DevOpsBuild buildInfo = await GetBuildInfo(1);
|
DevOpsBuild buildInfo = await GetBuildInfo(1);
|
||||||
@ -114,7 +136,9 @@ namespace Artemis.UI.Services
|
|||||||
|
|
||||||
// Always update installer if it is missing ^^
|
// Always update installer if it is missing ^^
|
||||||
if (!File.Exists(installerPath))
|
if (!File.Exists(installerPath))
|
||||||
|
{
|
||||||
await UpdateInstaller();
|
await UpdateInstaller();
|
||||||
|
}
|
||||||
// Compare the creation date of the installer with the build date and update if needed
|
// Compare the creation date of the installer with the build date and update if needed
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -182,27 +206,6 @@ namespace Artemis.UI.Services
|
|||||||
.GetJsonAsync<GitHubDifference>();
|
.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
|
#region Event handlers
|
||||||
|
|
||||||
private void CheckForUpdatesOnSettingChanged(object sender, EventArgs e)
|
private void CheckForUpdatesOnSettingChanged(object sender, EventArgs e)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user