mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 13:28:33 +00:00
Merge branch 'development' into feature/workshop
This commit is contained in:
commit
606a34c7be
@ -2,9 +2,16 @@
|
||||
|
||||
namespace Artemis.Core;
|
||||
|
||||
internal static class SKPaintExtensions
|
||||
/// <summary>
|
||||
/// A static class providing <see cref="SKPaint" /> extensions
|
||||
/// </summary>
|
||||
public static class SKPaintExtensions
|
||||
{
|
||||
internal static void DisposeSelfAndProperties(this SKPaint paint)
|
||||
/// <summary>
|
||||
/// Disposes the paint and its disposable properties such as shaders and filters.
|
||||
/// </summary>
|
||||
/// <param name="paint">The pain to dispose.</param>
|
||||
public static void DisposeSelfAndProperties(this SKPaint paint)
|
||||
{
|
||||
paint.ImageFilter?.Dispose();
|
||||
paint.ColorFilter?.Dispose();
|
||||
|
||||
@ -16,6 +16,7 @@ using Artemis.WebClient.Workshop.DryIoc;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Logging;
|
||||
using Avalonia.Styling;
|
||||
using DryIoc;
|
||||
using ReactiveUI;
|
||||
@ -32,9 +33,9 @@ public static class ArtemisBootstrapper
|
||||
{
|
||||
if (_application != null || _container != null)
|
||||
throw new ArtemisUIException("UI already bootstrapped");
|
||||
|
||||
|
||||
Utilities.PrepareFirstLaunch();
|
||||
|
||||
|
||||
application.RequestedThemeVariant = ThemeVariant.Dark;
|
||||
_application = application;
|
||||
_container = new Container(rules => rules
|
||||
@ -51,6 +52,8 @@ public static class ArtemisBootstrapper
|
||||
configureServices?.Invoke(_container);
|
||||
|
||||
_container.UseDryIocDependencyResolver();
|
||||
|
||||
Logger.Sink = _container.Resolve<SerilogAvaloniaSink>();
|
||||
return _container;
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,8 @@
|
||||
Margin="10 2"
|
||||
ItemsSource="{CompiledBinding SidebarScreen.Screens}"
|
||||
SelectedItem="{CompiledBinding SelectedScreen}"
|
||||
ItemContainerTheme="{StaticResource MenuTreeViewItem}">
|
||||
ItemContainerTheme="{StaticResource MenuTreeViewItem}"
|
||||
PointerReleased="InputElement_OnPointerReleased">
|
||||
<TreeView.Styles>
|
||||
<Style Selector="TreeViewItem">
|
||||
<Setter Property="IsExpanded" Value="{CompiledBinding IsExpanded, Mode=TwoWay, DataType=sidebar:SidebarScreenViewModel}" />
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Sidebar;
|
||||
@ -10,4 +13,9 @@ public partial class SidebarView : ReactiveUserControl<SidebarViewModel>
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InputElement_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
|
||||
{
|
||||
if (e.Source is IDataContextProvider dataContextProvider && dataContextProvider.DataContext is SidebarScreenViewModel sidebarScreenViewModel)
|
||||
ViewModel?.NavigateToScreen(sidebarScreenViewModel);
|
||||
}
|
||||
}
|
||||
@ -52,7 +52,6 @@ public class SidebarViewModel : ActivatableViewModelBase
|
||||
});
|
||||
|
||||
AddCategory = ReactiveCommand.CreateFromTask(ExecuteAddCategory);
|
||||
this.WhenAnyValue(vm => vm.SelectedScreen).WhereNotNull().Subscribe(NavigateToScreen);
|
||||
this.WhenAnyValue(vm => vm.SelectedScreen).WhereNotNull().Subscribe(s => SidebarScreen.ExpandIfRequired(s));
|
||||
|
||||
SourceList<ProfileCategory> profileCategories = new();
|
||||
@ -119,7 +118,7 @@ public class SidebarViewModel : ActivatableViewModelBase
|
||||
.ShowAsync();
|
||||
}
|
||||
|
||||
private void NavigateToScreen(SidebarScreenViewModel sidebarScreenViewModel)
|
||||
public void NavigateToScreen(SidebarScreenViewModel sidebarScreenViewModel)
|
||||
{
|
||||
if (_updating)
|
||||
return;
|
||||
|
||||
56
src/Artemis.UI/SerilogAvaloniaSink.cs
Normal file
56
src/Artemis.UI/SerilogAvaloniaSink.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Avalonia.Logging;
|
||||
using Serilog;
|
||||
using AvaloniaLogLevel = Avalonia.Logging.LogEventLevel;
|
||||
using SerilogLogLevel = Serilog.Events.LogEventLevel;
|
||||
|
||||
namespace Artemis.UI;
|
||||
|
||||
[SuppressMessage("ReSharper", "TemplateIsNotCompileTimeConstantProblem")]
|
||||
public class SerilogAvaloniaSink : ILogSink
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public SerilogAvaloniaSink(ILogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsEnabled(AvaloniaLogLevel level, string area)
|
||||
{
|
||||
SerilogLogLevel logLevel = GetSerilogLogLevel(level, area);
|
||||
|
||||
// Except with binding errors, ignore anything that is information or lower
|
||||
return (area == "Binding" || logLevel > SerilogLogLevel.Information) && _logger.IsEnabled(logLevel);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Log(AvaloniaLogLevel level, string area, object? source, string messageTemplate)
|
||||
{
|
||||
SerilogLogLevel logLevel = GetSerilogLogLevel(level, area);
|
||||
|
||||
ILogger logger = source != null ? _logger.ForContext(source.GetType()) : _logger;
|
||||
logger.Write(logLevel, messageTemplate);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Log(AvaloniaLogLevel level, string area, object? source, string messageTemplate, params object?[] propertyValues)
|
||||
{
|
||||
SerilogLogLevel logLevel = GetSerilogLogLevel(level, area);
|
||||
|
||||
ILogger logger = source != null ? _logger.ForContext(source.GetType()) : _logger;
|
||||
logger.Write(logLevel, messageTemplate, propertyValues);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static SerilogLogLevel GetSerilogLogLevel(AvaloniaLogLevel level, string area)
|
||||
{
|
||||
// Avalonia considers binding errors warnings, we'll treat them Verbose as to not spam people's logs
|
||||
// And yes we should fix them instead but we can't always: https://github.com/AvaloniaUI/Avalonia/issues/5762
|
||||
if (area == "Binding")
|
||||
return SerilogLogLevel.Verbose;
|
||||
return (SerilogLogLevel) level;
|
||||
}
|
||||
}
|
||||
@ -243,6 +243,7 @@
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAlwaysTreatStructAsNotReorderableMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=activatable/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Avalonia/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Hotkey/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=luma/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=pixmap/@EntryIndexedValue">True</s:Boolean>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user