Compare commits

...

2 Commits

5 changed files with 16 additions and 63 deletions

View File

@@ -48,7 +48,7 @@ dotnet run --project src/Sms.TaskTwo.Avalonia/Sms.TaskTwo.Avalonia.csproj
Класс `Sms.TaskTwo.Core.Logging.ConsoleLog` — дублирует записи в консоль и файл.
По умолчанию для GUI: `logs/test-sms-wpf-app-yyyyMMdd.log`. При вызове `ConsoleLog.Open()` без имени — `test-sms-console-app-yyyyMMdd_HHmmss.log`.
По умолчанию для GUI: `logs/test-sms-wpf-app-yyyyMMdd-hh:mm:ss.log` (на Windows двоеточия во времени заменяются на `-`). При вызове `ConsoleLog.Open()` без имени — `test-sms-console-app-yyyyMMdd_HHmmss.log`.
Пример строки:

View File

@@ -5,25 +5,6 @@
<Application.Styles>
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml" />
<FluentTheme />
<Style Selector="Button.titleButton">
<Setter Property="Width" Value="40" />
<Setter Property="Height" Value="44" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Padding" Value="0" />
<Setter Property="CornerRadius" Value="0" />
</Style>
<Style Selector="Button.titleButton:pointerover">
<Setter Property="Background" Value="#D8D8D8" />
</Style>
<Style Selector="Button.titleButton.close">
<Setter Property="CornerRadius" Value="0,11,0,0" />
</Style>
<Style Selector="Button.titleButton.close:pointerover">
<Setter Property="Background" Value="#E81123" />
<Setter Property="Foreground" Value="White" />
</Style>
<Style Selector="DataGrid.roundedGrid">
<Setter Property="RowHeight" Value="32" />
<Setter Property="Background" Value="Transparent" />

View File

@@ -12,41 +12,16 @@
Height="600"
MinWidth="760"
MinHeight="480"
Background="#F5F5F5"
ExtendClientAreaToDecorationsHint="True"
ExtendClientAreaChromeHints="NoChrome"
SystemDecorations="None">
Background="#F5F5F5">
<Border CornerRadius="12"
Background="White"
BorderBrush="#C8C8C8"
BorderThickness="1"
Margin="8"
Margin="12"
ClipToBounds="True">
<Grid RowDefinitions="Auto,Auto,Auto,Auto,*">
<Border Grid.Row="0"
Background="#ECECEC"
CornerRadius="11,11,0,0"
ClipToBounds="True"
Height="44">
<Grid ColumnDefinitions="*,Auto,Auto">
<TextBlock Grid.Column="0"
Text="{x:Static app:AppResources.WindowTitle}"
VerticalAlignment="Center"
Margin="16,0,8,0"
FontSize="14" />
<Button Grid.Column="1"
Classes="titleButton"
Content=""
Click="OnMinimizeClick" />
<Button Grid.Column="2"
Classes="titleButton close"
Content="×"
Click="OnCloseClick" />
</Grid>
</Border>
<Grid Grid.Row="1"
Margin="12,8,12,0"
<Grid RowDefinitions="Auto,Auto,Auto,*">
<Grid Grid.Row="0"
Margin="12,12,12,0"
ColumnDefinitions="*,Auto,Auto"
ColumnSpacing="8">
<CheckBox Content="Отображать все переменные"
@@ -62,7 +37,7 @@
MinWidth="140" />
</Grid>
<Grid Grid.Row="2"
<Grid Grid.Row="1"
Margin="12,8,12,0"
ColumnDefinitions="Auto,2*,3*,Auto"
ColumnSpacing="8">
@@ -81,7 +56,7 @@
MinWidth="100" />
</Grid>
<StackPanel Grid.Row="3"
<StackPanel Grid.Row="2"
Margin="12,4,12,0"
Spacing="2">
<TextBlock Foreground="#C62828"
@@ -93,7 +68,7 @@
IsVisible="{Binding ReloadEnvironmentMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" />
</StackPanel>
<Border Grid.Row="4"
<Border Grid.Row="3"
Margin="12,4,12,12"
CornerRadius="8"
ClipToBounds="True"

View File

@@ -1,5 +1,4 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using Sms.TaskTwo.ViewModels;
namespace Sms.TaskTwo.Avalonia.Views;
@@ -92,10 +91,4 @@ public partial class MainWindow : Window
gridRow.Classes.Add("userStore");
}
}
private void OnMinimizeClick(object? sender, RoutedEventArgs e) =>
WindowState = WindowState.Minimized;
private void OnCloseClick(object? sender, RoutedEventArgs e) =>
Close();
}

View File

@@ -28,9 +28,13 @@ public static class ServiceCollectionExtensions
{
var options = serviceProvider.GetRequiredService<IOptions<LoggingOptions>>().Value;
Directory.CreateDirectory(options.LogDirectory);
var fileName = Path.Combine(
options.LogDirectory,
$"test-sms-wpf-app-{DateTime.Now:yyyyMMdd}.log");
var timestamp = DateTime.Now.ToString("yyyyMMdd-hh:mm:ss");
var logFileName = SanitizeFileName($"test-sms-wpf-app-{timestamp}.log");
var fileName = Path.Combine(options.LogDirectory, logFileName);
return ConsoleLog.Open(fileName);
}
private static string SanitizeFileName(string fileName) =>
string.Concat(fileName.Select(static c =>
Path.GetInvalidFileNameChars().Contains(c) ? '-' : c));
}