diff --git a/StabilityMatrix.Avalonia/Controls/VendorLabs/Cache/InMemoryStorage.cs b/StabilityMatrix.Avalonia/Controls/VendorLabs/Cache/InMemoryStorage.cs index a4fddd6c8..8b2a6363c 100644 --- a/StabilityMatrix.Avalonia/Controls/VendorLabs/Cache/InMemoryStorage.cs +++ b/StabilityMatrix.Avalonia/Controls/VendorLabs/Cache/InMemoryStorage.cs @@ -2,14 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; using System.Runtime.CompilerServices; -using KGySoft.CoreLibraries; -using StabilityMatrix.Core.Helper.Cache; namespace StabilityMatrix.Avalonia.Controls.VendorLabs.Cache; @@ -23,7 +16,7 @@ public class InMemoryStorage private readonly LinkedList> _lruList = []; private int _maxItemCount; - private object _settingMaxItemCountLocker = new(); + private readonly Lock _settingMaxItemCountLocker = new(); /// /// Gets or sets the maximum count of Items that can be stored in this InMemoryStorage instance. diff --git a/StabilityMatrix.Avalonia/Helpers/EnumHelpers.cs b/StabilityMatrix.Avalonia/Helpers/EnumHelpers.cs index 9d037ed45..2ac48bdfe 100644 --- a/StabilityMatrix.Avalonia/Helpers/EnumHelpers.cs +++ b/StabilityMatrix.Avalonia/Helpers/EnumHelpers.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using StabilityMatrix.Core.Extensions; +using StabilityMatrix.Core.Extensions; using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models.Api; @@ -9,23 +6,20 @@ namespace StabilityMatrix.Avalonia.Helpers; public static class EnumHelpers { - public static IEnumerable AllCivitPeriods { get; } = - Enum.GetValues(typeof(CivitPeriod)).Cast(); + public static IEnumerable AllCivitPeriods { get; } = Enum.GetValues(); - public static IEnumerable AllSortModes { get; } = - Enum.GetValues(typeof(CivitSortMode)).Cast(); + public static IEnumerable AllSortModes { get; } = Enum.GetValues(); public static IEnumerable AllCivitModelTypes { get; } = - Enum.GetValues(typeof(CivitModelType)) - .Cast() + Enum.GetValues() .Where(t => t == CivitModelType.All || t.ConvertTo() > 0) .OrderBy(t => t.ToString()); public static IEnumerable MetadataEditorCivitModelTypes { get; } = - Enum.GetValues(typeof(CivitModelType)).Cast().OrderBy(t => t.ToString()); + Enum.GetValues().OrderBy(t => t.ToString()); public static IEnumerable AllCivitBaseModelTypes { get; } = - Enum.GetValues(typeof(CivitBaseModelType)).Cast(); + Enum.GetValues(); public static IEnumerable MetadataEditorCivitBaseModelTypes { get; } = AllCivitBaseModelTypes.Where(x => x != CivitBaseModelType.All); diff --git a/StabilityMatrix.Avalonia/Helpers/IOCommands.cs b/StabilityMatrix.Avalonia/Helpers/IOCommands.cs index 6877ec14c..0477c7a3a 100644 --- a/StabilityMatrix.Avalonia/Helpers/IOCommands.cs +++ b/StabilityMatrix.Avalonia/Helpers/IOCommands.cs @@ -1,5 +1,4 @@ -using System; -using CommunityToolkit.Mvvm.Input; +using CommunityToolkit.Mvvm.Input; using StabilityMatrix.Core.Processes; namespace StabilityMatrix.Avalonia.Helpers; diff --git a/StabilityMatrix.Avalonia/Helpers/ImageProcessor.cs b/StabilityMatrix.Avalonia/Helpers/ImageProcessor.cs index a090c6a27..75725834a 100644 --- a/StabilityMatrix.Avalonia/Helpers/ImageProcessor.cs +++ b/StabilityMatrix.Avalonia/Helpers/ImageProcessor.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using SkiaSharp; +using SkiaSharp; using StabilityMatrix.Core.Extensions; namespace StabilityMatrix.Avalonia.Helpers; @@ -45,9 +42,7 @@ public static SKImage CreateImageGrid(IReadOnlyList images, int spacing // Draw images using var canvas = new SKCanvas(output); - foreach ( - var (row, column) in Enumerable.Range(0, rows).Product(Enumerable.Range(0, columns)) - ) + foreach (var (row, column) in Enumerable.Range(0, rows).Product(Enumerable.Range(0, columns))) { // Stop if we have drawn all images var index = row * columns + column; diff --git a/StabilityMatrix.Avalonia/Helpers/ImageSearcher.cs b/StabilityMatrix.Avalonia/Helpers/ImageSearcher.cs index b5d280fec..b4e60f1d5 100644 --- a/StabilityMatrix.Avalonia/Helpers/ImageSearcher.cs +++ b/StabilityMatrix.Avalonia/Helpers/ImageSearcher.cs @@ -1,5 +1,4 @@ -using System; -using FuzzySharp; +using FuzzySharp; using FuzzySharp.PreProcess; using StabilityMatrix.Core.Models.Database; @@ -27,8 +26,7 @@ public Func GetPredicate(string? searchQuery) if ( SearchOptions.HasFlag(ImageSearchOptions.FileName) - && Fuzz.WeightedRatio(searchQuery, file.FileName, PreprocessMode.Full) - > MinimumFuzzScore + && Fuzz.WeightedRatio(searchQuery, file.FileName, PreprocessMode.Full) > MinimumFuzzScore ) { return true; @@ -53,22 +51,18 @@ public Func GetPredicate(string? searchQuery) ) ?? false ) || SearchOptions.HasFlag(ImageSearchOptions.Seed) - && parameters.Seed - .ToString() + && parameters + .Seed.ToString() .StartsWith(searchQuery, StringComparison.OrdinalIgnoreCase) || SearchOptions.HasFlag(ImageSearchOptions.Sampler) && ( - parameters.Sampler?.StartsWith( - searchQuery, - StringComparison.OrdinalIgnoreCase - ) ?? false + parameters.Sampler?.StartsWith(searchQuery, StringComparison.OrdinalIgnoreCase) + ?? false ) || SearchOptions.HasFlag(ImageSearchOptions.ModelName) && ( - parameters.ModelName?.StartsWith( - searchQuery, - StringComparison.OrdinalIgnoreCase - ) ?? false + parameters.ModelName?.StartsWith(searchQuery, StringComparison.OrdinalIgnoreCase) + ?? false ) ) { @@ -90,6 +84,6 @@ public enum ImageSearchOptions Seed = 1 << 3, Sampler = 1 << 4, ModelName = 1 << 5, - All = int.MaxValue + All = int.MaxValue, } } diff --git a/StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs b/StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs index 2bbbf102d..232e87968 100644 --- a/StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs +++ b/StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs @@ -1,8 +1,4 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; +using System.Text; using System.Text.Json; using Force.Crc32; using StabilityMatrix.Avalonia.Models; diff --git a/StabilityMatrix.Avalonia/Models/TagCompletion/CompletionProvider.cs b/StabilityMatrix.Avalonia/Models/TagCompletion/CompletionProvider.cs index 72ae41cec..64d1d2829 100644 --- a/StabilityMatrix.Avalonia/Models/TagCompletion/CompletionProvider.cs +++ b/StabilityMatrix.Avalonia/Models/TagCompletion/CompletionProvider.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; +using System.Diagnostics; using System.Text.RegularExpressions; -using System.Threading.Tasks; using AsyncAwaitBestPractices; using AutoComplete.Builders; using AutoComplete.Clients.IndexSearchers; @@ -358,12 +354,12 @@ private IEnumerable GetCompletionNetworkTypes(string searchTerm { (PromptExtraNetworkType.Lora, "lora"), (PromptExtraNetworkType.LyCORIS, "lyco"), - (PromptExtraNetworkType.Embedding, "embedding") + (PromptExtraNetworkType.Embedding, "embedding"), }; return availableTypes - .Where( - type => type.Item1.GetStringValue().StartsWith(searchTerm, StringComparison.OrdinalIgnoreCase) + .Where(type => + type.Item1.GetStringValue().StartsWith(searchTerm, StringComparison.OrdinalIgnoreCase) ) .Select(type => new ModelTypeCompletionData(type.Item2, type.Item1)); } @@ -381,7 +377,7 @@ private IEnumerable GetCompletionTags(string searchTerm, int it { Term = searchTerm, MaxItemCount = itemsCount, - SuggestWhenFoundStartsWith = suggest + SuggestWhenFoundStartsWith = suggest, }; var result = searcher.Search(searchOptions); diff --git a/StabilityMatrix.Avalonia/Services/RunningPackageService.cs b/StabilityMatrix.Avalonia/Services/RunningPackageService.cs index 6aba7ec7a..b204d0a13 100644 --- a/StabilityMatrix.Avalonia/Services/RunningPackageService.cs +++ b/StabilityMatrix.Avalonia/Services/RunningPackageService.cs @@ -46,7 +46,7 @@ IPyRunner pyRunner ) { // Get lock - using var @lock = await packageLocks.LockAsync(installedPackage.Id, cancellationToken); + using var _ = await packageLocks.LockAsync(installedPackage.Id, cancellationToken); // Ignore if already running after lock if (RunningPackages.ContainsKey(installedPackage.Id)) @@ -266,7 +266,7 @@ await basePackage.RunPackage( public async Task StopPackage(Guid id, CancellationToken cancellationToken = default) { // Get lock - using var @lock = await packageLocks.LockAsync(id, cancellationToken); + using var _ = await packageLocks.LockAsync(id, cancellationToken); // Ignore if not running after lock if (!RunningPackages.TryGetValue(id, out var vm)) diff --git a/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitDetailsPageViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitDetailsPageViewModel.cs index d308160e8..0e7acb61b 100644 --- a/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitDetailsPageViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitDetailsPageViewModel.cs @@ -1,4 +1,5 @@ -using System.Collections.ObjectModel; +using System.Collections.Frozen; +using System.Collections.ObjectModel; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Globalization; @@ -15,7 +16,6 @@ using FluentAvalonia.UI.Controls; using Injectio.Attributes; using Microsoft.Extensions.Logging; -using Refit; using StabilityMatrix.Avalonia.Animations; using StabilityMatrix.Avalonia.Languages; using StabilityMatrix.Avalonia.Models; @@ -65,7 +65,7 @@ IModelImportService modelImportService [NotifyPropertyChangedFor(nameof(CanGoNext), nameof(CanGoPrevious))] public required partial int CurrentIndex { get; set; } - private List ignoredFileNameFormatVars = + private readonly FrozenSet ignoredFileNameFormatVars = [ "seed", "prompt", @@ -86,17 +86,17 @@ IModelImportService modelImportService .Substitutions.Where(kv => !ignoredFileNameFormatVars.Contains(kv.Key)) .Select(kv => new FileNameFormatVar { Variable = $"{{{kv.Key}}}", Example = kv.Value.Invoke() }); - private SourceCache imageCache = new(x => x.Url); + private readonly SourceCache imageCache = new(x => x.Url); public IObservableCollection ImageSources { get; set; } = new ObservableCollectionExtended(); - private SourceCache modelVersionCache = new(x => x.Id); + private readonly SourceCache modelVersionCache = new(x => x.Id); public IObservableCollection ModelVersions { get; set; } = new ObservableCollectionExtended(); - private SourceCache civitFileCache = new(x => x.Id); + private readonly SourceCache civitFileCache = new(x => x.Id); public IObservableCollection CivitFiles { get; set; } = new ObservableCollectionExtended(); @@ -670,12 +670,15 @@ private async Task DeleteModelVersion(CivitModelVersion modelVersion) if (file is not { Type: CivitFileType.Model, Hashes.BLAKE3: not null }) continue; - var matchingModels = (await modelIndexService.FindByHashAsync(file.Hashes.BLAKE3)).ToList(); + List matchingModels = + [ + .. (await modelIndexService.FindByHashAsync(file.Hashes.BLAKE3)), + ]; if (matchingModels.Count == 0) { await modelIndexService.RefreshIndex(); - matchingModels = (await modelIndexService.FindByHashAsync(file.Hashes.BLAKE3)).ToList(); + matchingModels = [.. (await modelIndexService.FindByHashAsync(file.Hashes.BLAKE3))]; } if (matchingModels.Count == 0) diff --git a/StabilityMatrix.Avalonia/ViewModels/ConsoleViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/ConsoleViewModel.cs index e69b5ae71..844700233 100644 --- a/StabilityMatrix.Avalonia/ViewModels/ConsoleViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/ConsoleViewModel.cs @@ -1,9 +1,5 @@ -using System; -using System.ComponentModel; +using System.ComponentModel; using System.Diagnostics; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using System.Threading.Tasks.Dataflow; using System.Web; using Avalonia.Threading; diff --git a/StabilityMatrix.Core/Helper/HardwareInfo/HardwareHelper.cs b/StabilityMatrix.Core/Helper/HardwareInfo/HardwareHelper.cs index 621049796..369021730 100644 --- a/StabilityMatrix.Core/Helper/HardwareInfo/HardwareHelper.cs +++ b/StabilityMatrix.Core/Helper/HardwareInfo/HardwareHelper.cs @@ -15,7 +15,7 @@ public static partial class HardwareHelper private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static IReadOnlyList? cachedGpuInfos; - private static readonly object cachedGpuInfosLock = new(); + private static readonly Lock cachedGpuInfosLock = new(); private static readonly Lazy HardwareInfoLazy = new(() => new Hardware.Info.HardwareInfo() ); diff --git a/StabilityMatrix/ViewModels/LaunchViewModel.cs b/StabilityMatrix/ViewModels/LaunchViewModel.cs index f0c143734..6daa28c81 100644 --- a/StabilityMatrix/ViewModels/LaunchViewModel.cs +++ b/StabilityMatrix/ViewModels/LaunchViewModel.cs @@ -1,23 +1,4 @@ -using System; -using System.Collections.ObjectModel; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; -using AsyncAwaitBestPractices; -using CommunityToolkit.Mvvm.ComponentModel; -using CommunityToolkit.Mvvm.Input; -using Microsoft.Extensions.Logging; -using Microsoft.Toolkit.Uwp.Notifications; -using StabilityMatrix.Core.Helper; -using StabilityMatrix.Core.Helper.Factory; -using StabilityMatrix.Core.Models; -using StabilityMatrix.Core.Models.Packages; -using StabilityMatrix.Core.Processes; -using StabilityMatrix.Core.Python; -using StabilityMatrix.Core.Services; -using StabilityMatrix.Helper; -using Wpf.Ui.Contracts; -using Wpf.Ui.Controls.ContentDialogControl; +using StabilityMatrix.Helper; using EventManager = StabilityMatrix.Core.Helper.EventManager; using ISnackbarService = StabilityMatrix.Helper.ISnackbarService; @@ -39,17 +20,32 @@ public partial class LaunchViewModel : ObservableObject private bool clearingPackages; private string webUiUrl = string.Empty; - [ObservableProperty] private string consoleInput = ""; - [ObservableProperty] private Visibility launchButtonVisibility; - [ObservableProperty] private Visibility stopButtonVisibility; - [ObservableProperty] private bool isLaunchTeachingTipsOpen = false; - [ObservableProperty] private bool showWebUiButton; - [ObservableProperty] private ObservableCollection? consoleHistory; - - [ObservableProperty] private InstalledPackage? selectedPackage; - [ObservableProperty] private ObservableCollection installedPackages = new(); - - public LaunchViewModel(ISettingsManager settingsManager, + [ObservableProperty] + private string consoleInput = ""; + + [ObservableProperty] + private Visibility launchButtonVisibility; + + [ObservableProperty] + private Visibility stopButtonVisibility; + + [ObservableProperty] + private bool isLaunchTeachingTipsOpen = false; + + [ObservableProperty] + private bool showWebUiButton; + + [ObservableProperty] + private ObservableCollection? consoleHistory; + + [ObservableProperty] + private InstalledPackage? selectedPackage; + + [ObservableProperty] + private ObservableCollection installedPackages = new(); + + public LaunchViewModel( + ISettingsManager settingsManager, IPackageFactory packageFactory, IContentDialogService contentDialogService, LaunchOptionsDialogViewModel launchOptionsDialogViewModel, @@ -57,7 +53,8 @@ public LaunchViewModel(ISettingsManager settingsManager, IPyRunner pyRunner, IDialogFactory dialogFactory, ISnackbarService snackbarService, - ISharedFolders sharedFolders) + ISharedFolders sharedFolders + ) { this.pyRunner = pyRunner; this.dialogFactory = dialogFactory; @@ -75,10 +72,11 @@ public LaunchViewModel(ISettingsManager settingsManager, ToastNotificationManagerCompat.OnActivated += ToastNotificationManagerCompatOnOnActivated; } - + partial void OnSelectedPackageChanged(InstalledPackage? value) { - if (clearingPackages) return; + if (clearingPackages) + return; settingsManager.Transaction(s => s.ActiveInstalledPackageId = value?.Id); } @@ -92,8 +90,7 @@ private void OnInstalledPackagesChanged(object? sender, EventArgs e) OnLoaded(); } - private void ToastNotificationManagerCompatOnOnActivated( - ToastNotificationActivatedEventArgsCompat e) + private void ToastNotificationManagerCompatOnOnActivated(ToastNotificationActivatedEventArgsCompat e) { if (!e.Argument.StartsWith("http")) return; @@ -106,72 +103,80 @@ private void ToastNotificationManagerCompatOnOnActivated( LaunchWebUi(); } - public AsyncRelayCommand LaunchCommand => new(async () => - { - var activeInstall = SelectedPackage; - - if (activeInstall == null) + public AsyncRelayCommand LaunchCommand => + new(async () => { - // No selected package: error snackbar - snackbarService.ShowSnackbarAsync( - "You must install and select a package before launching", - "No package selected").SafeFireAndForget(); - return; - } + var activeInstall = SelectedPackage; + + if (activeInstall == null) + { + // No selected package: error snackbar + snackbarService + .ShowSnackbarAsync( + "You must install and select a package before launching", + "No package selected" + ) + .SafeFireAndForget(); + return; + } - var activeInstallName = activeInstall.PackageName; - var basePackage = string.IsNullOrWhiteSpace(activeInstallName) - ? null - : packageFactory.FindPackageByName(activeInstallName); + var activeInstallName = activeInstall.PackageName; + var basePackage = string.IsNullOrWhiteSpace(activeInstallName) + ? null + : packageFactory.FindPackageByName(activeInstallName); - if (basePackage == null) - { - logger.LogWarning( - "During launch, package name '{PackageName}' did not match a definition", - activeInstallName); - snackbarService.ShowSnackbarAsync( - "Install package name did not match a definition. Please reinstall and let us know about this issue.", - "Package name invalid").SafeFireAndForget(); - return; - } + if (basePackage == null) + { + logger.LogWarning( + "During launch, package name '{PackageName}' did not match a definition", + activeInstallName + ); + snackbarService + .ShowSnackbarAsync( + "Install package name did not match a definition. Please reinstall and let us know about this issue.", + "Package name invalid" + ) + .SafeFireAndForget(); + return; + } - // If this is the first launch (LaunchArgs is null), - // load and save a launch options dialog in background - // so that dynamic initial values are saved. - if (activeInstall.LaunchArgs == null) - { - var definitions = basePackage.LaunchOptions; - // Open a config page and save it - var dialog = dialogFactory.CreateLaunchOptionsDialog(definitions, activeInstall); - var args = dialog.AsLaunchArgs(); - settingsManager.SaveLaunchArgs(activeInstall.Id, args); - } + // If this is the first launch (LaunchArgs is null), + // load and save a launch options dialog in background + // so that dynamic initial values are saved. + if (activeInstall.LaunchArgs == null) + { + var definitions = basePackage.LaunchOptions; + // Open a config page and save it + var dialog = dialogFactory.CreateLaunchOptionsDialog(definitions, activeInstall); + var args = dialog.AsLaunchArgs(); + settingsManager.SaveLaunchArgs(activeInstall.Id, args); + } - // Clear console - ConsoleHistory?.Clear(); + // Clear console + ConsoleHistory?.Clear(); - await pyRunner.Initialize(); + await pyRunner.Initialize(); - // Get path from package - var packagePath = $"{settingsManager.LibraryDir}\\{activeInstall.LibraryPath!}"; + // Get path from package + var packagePath = $"{settingsManager.LibraryDir}\\{activeInstall.LibraryPath!}"; - basePackage.ConsoleOutput += OnConsoleOutput; - basePackage.Exited += OnExit; - basePackage.StartupComplete += RunningPackageOnStartupComplete; + basePackage.ConsoleOutput += OnConsoleOutput; + basePackage.Exited += OnExit; + basePackage.StartupComplete += RunningPackageOnStartupComplete; - // Update shared folder links (in case library paths changed) - await sharedFolders.UpdateLinksForPackage(basePackage, packagePath); + // Update shared folder links (in case library paths changed) + await sharedFolders.UpdateLinksForPackage(basePackage, packagePath); - // Load user launch args from settings and convert to string - var userArgs = settingsManager.GetLaunchArgs(activeInstall.Id); - var userArgsString = string.Join(" ", userArgs.Select(opt => opt.ToArgString())); + // Load user launch args from settings and convert to string + var userArgs = settingsManager.GetLaunchArgs(activeInstall.Id); + var userArgsString = string.Join(" ", userArgs.Select(opt => opt.ToArgString())); - // Join with extras, if any - userArgsString = string.Join(" ", userArgsString, basePackage.ExtraLaunchArguments); - await basePackage.RunPackage(packagePath, userArgsString); - runningPackage = basePackage; - SetProcessRunning(true); - }); + // Join with extras, if any + userArgsString = string.Join(" ", userArgsString, basePackage.ExtraLaunchArguments); + await basePackage.RunPackage(packagePath, userArgsString); + runningPackage = basePackage; + SetProcessRunning(true); + }); [RelayCommand] private async Task ConfigAsync() @@ -257,8 +262,8 @@ public void OnLoaded() var activePackageId = settingsManager.Settings.ActiveInstalledPackageId; if (activePackageId != null) { - SelectedPackage = InstalledPackages.FirstOrDefault( - x => x.Id == activePackageId) ?? InstalledPackages[0]; + SelectedPackage = + InstalledPackages.FirstOrDefault(x => x.Id == activePackageId) ?? InstalledPackages[0]; } } } @@ -281,8 +286,7 @@ private Task Stop() runningPackage?.Shutdown(); runningPackage = null; SetProcessRunning(false); - ConsoleHistory?.Add( - $"Stopped process at {DateTimeOffset.Now}"); + ConsoleHistory?.Add($"Stopped process at {DateTimeOffset.Now}"); ShowWebUiButton = false; return Task.CompletedTask; } @@ -323,7 +327,8 @@ private void SetProcessRunning(bool running) private void OnConsoleOutput(object? sender, ProcessOutput output) { - if (string.IsNullOrWhiteSpace(output.Text)) return; + if (string.IsNullOrWhiteSpace(output.Text)) + return; Application.Current.Dispatcher.Invoke(() => { ConsoleHistory ??= new ObservableCollection(); @@ -332,8 +337,11 @@ private void OnConsoleOutput(object? sender, ProcessOutput output) { ConsoleHistory[^2] = output.Text.TrimEnd('\n'); } - else if ((output.Text.Contains("it/s") || output.Text.Contains("s/it") || output.Text.Contains("B/s")) && - !output.Text.Contains("Total progress") && !output.Text.Contains(" 0%")) + else if ( + (output.Text.Contains("it/s") || output.Text.Contains("s/it") || output.Text.Contains("B/s")) + && !output.Text.Contains("Total progress") + && !output.Text.Contains(" 0%") + ) { ConsoleHistory[^1] = output.Text.TrimEnd('\n'); } @@ -344,10 +352,10 @@ private void OnConsoleOutput(object? sender, ProcessOutput output) ConsoleHistory.Add(output.Text.TrimEnd('\n')); } } - - ConsoleHistory = - new ObservableCollection( - ConsoleHistory.Where(str => !string.IsNullOrWhiteSpace(str))); + + ConsoleHistory = new ObservableCollection( + ConsoleHistory.Where(str => !string.IsNullOrWhiteSpace(str)) + ); }); }