Merge branch 'master' into AdjustOutOfDateMessages

This commit is contained in:
IsWaffle 2024-06-09 20:17:34 +00:00
commit ccc91b09f6
5 changed files with 59 additions and 11 deletions

View File

@ -20,6 +20,7 @@
<entry key="SPTInstaller/CustomControls/UpdateInfoCard.axaml" value="SPTInstaller/SPTInstaller.csproj" />
<entry key="SPTInstaller/Views/DetailedPreChecksView.axaml" value="SPTInstaller/SPTInstaller.csproj" />
<entry key="SPTInstaller/Views/MainWindow.axaml" value="SPTInstaller/SPTInstaller.csproj" />
<entry key="SPTInstaller/Views/MessageView.axaml" value="SPTInstaller/SPTInstaller.csproj" />
<entry key="SPTInstaller/Views/PreChecksView.axaml" value="SPTInstaller/SPTInstaller.csproj" />
</map>
</option>

View File

@ -12,7 +12,7 @@ namespace SPTInstaller;
public partial class App : Application
{
private readonly string _logPath = Path.Join(Environment.CurrentDirectory, "spt-installer_.log");
public static string LogPath = Path.Join(Environment.CurrentDirectory, "spt-installer.log");
public override void Initialize()
{
@ -21,9 +21,8 @@ public partial class App : Application
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo
.File(path: _logPath,
restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Information,
rollingInterval: RollingInterval.Day)
.File(path: LogPath,
restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Information)
.CreateLogger();
RxApp.DefaultExceptionHandler = Observer.Create<Exception>((exception) =>
@ -42,9 +41,8 @@ public partial class App : Application
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo
.File(path: _logPath,
restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Debug,
rollingInterval: RollingInterval.Day)
.File(path: LogPath,
restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Debug)
.CreateLogger();
System.Diagnostics.Trace.Listeners.Add(new SerilogTraceListener.SerilogTraceListener());

View File

@ -10,8 +10,8 @@
<PackageIcon>icon.ico</PackageIcon>
<ApplicationIcon>Assets\spt_installer.ico</ApplicationIcon>
<Configurations>Debug;Release;TEST</Configurations>
<AssemblyVersion>2.70</AssemblyVersion>
<FileVersion>2.70</FileVersion>
<AssemblyVersion>2.71</AssemblyVersion>
<FileVersion>2.71</FileVersion>
<Company>SPT</Company>
</PropertyGroup>

View File

@ -6,6 +6,9 @@ using SPTInstaller.Helpers;
using SPTInstaller.Interfaces;
using System.Threading.Tasks;
using System.Windows.Input;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Input;
using Avalonia.Platform.Storage;
namespace SPTInstaller.ViewModels;
@ -43,6 +46,47 @@ public class MessageViewModel : ViewModelBase
set => this.RaiseAndSetIfChanged(ref _cacheInfoText, value);
}
private string _clipCommandText;
public string ClipCommandText
{
get => _clipCommandText;
set => this.RaiseAndSetIfChanged(ref _clipCommandText, value);
}
public ICommand CopyLogFileToClipboard => ReactiveCommand.CreateFromTask(async () =>
{
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
try
{
if (desktop.MainWindow?.Clipboard == null)
{
ClipCommandText = "Could not get clipboard :(";
return;
}
var dataObject = new DataObject();
var logFile = await desktop.MainWindow.StorageProvider.TryGetFileFromPathAsync(App.LogPath);
if (logFile == null)
{
ClipCommandText = "Could not get log file :(";
return;
}
dataObject.Set(DataFormats.Files, new[] {logFile});
await desktop.MainWindow.Clipboard.SetDataObjectAsync(dataObject);
ClipCommandText = "Copied!";
}
catch (Exception ex)
{
ClipCommandText = ex.Message;
}
}
});
private StatusSpinner.SpinnerState _cacheCheckState;
public StatusSpinner.SpinnerState CacheCheckState
@ -64,6 +108,7 @@ public class MessageViewModel : ViewModelBase
{
ShowCloseButton = showCloseButton;
Message = result.Message;
ClipCommandText = "Copy installer log to clipboard";
Task.Run(() =>
{

View File

@ -15,7 +15,7 @@
</UserControl.Styles>
<Grid ColumnDefinitions="*,AUTO,*" RowDefinitions="*,AUTO,20,AUTO,*"
<Grid ColumnDefinitions="*,AUTO,*" RowDefinitions="*,AUTO,20,AUTO,20,Auto,*"
Classes.error="{Binding HasErrors}">
<Label Grid.Column="1" Grid.Row="1"
@ -35,7 +35,11 @@
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
Padding="20 10" />
<cc:CacheInfo Grid.Row="4" Grid.ColumnSpan="3" Padding="10" Margin="10 0 0 0"
<Button Grid.Row="5" Grid.Column="1" Classes="link" Content="{Binding ClipCommandText}"
Command="{Binding CopyLogFileToClipboard}" HorizontalAlignment="Center" VerticalAlignment="Center"
/>
<cc:CacheInfo Grid.Row="6" Grid.ColumnSpan="3" Padding="10" Margin="10 0 0 0"
VerticalAlignment="Bottom"
InfoText="{Binding CacheInfoText}" State="{Binding CacheCheckState}" />
</Grid>