Compare commits
2 Commits
095ff99cf9
...
2f56bae044
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f56bae044 | |||
| 7e7ef33155 |
@@ -48,7 +48,7 @@ dotnet run --project src/Sms.TaskTwo.Avalonia/Sms.TaskTwo.Avalonia.csproj
|
|||||||
|
|
||||||
Класс `Sms.TaskTwo.Core.Logging.ConsoleLog` — дублирует записи в консоль и файл.
|
Класс `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`.
|
||||||
|
|
||||||
Пример строки:
|
Пример строки:
|
||||||
|
|
||||||
|
|||||||
@@ -5,25 +5,6 @@
|
|||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml" />
|
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml" />
|
||||||
<FluentTheme />
|
<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">
|
<Style Selector="DataGrid.roundedGrid">
|
||||||
<Setter Property="RowHeight" Value="32" />
|
<Setter Property="RowHeight" Value="32" />
|
||||||
<Setter Property="Background" Value="Transparent" />
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
|||||||
@@ -12,41 +12,16 @@
|
|||||||
Height="600"
|
Height="600"
|
||||||
MinWidth="760"
|
MinWidth="760"
|
||||||
MinHeight="480"
|
MinHeight="480"
|
||||||
Background="#F5F5F5"
|
Background="#F5F5F5">
|
||||||
ExtendClientAreaToDecorationsHint="True"
|
|
||||||
ExtendClientAreaChromeHints="NoChrome"
|
|
||||||
SystemDecorations="None">
|
|
||||||
<Border CornerRadius="12"
|
<Border CornerRadius="12"
|
||||||
Background="White"
|
Background="White"
|
||||||
BorderBrush="#C8C8C8"
|
BorderBrush="#C8C8C8"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
Margin="8"
|
Margin="12"
|
||||||
ClipToBounds="True">
|
ClipToBounds="True">
|
||||||
<Grid RowDefinitions="Auto,Auto,Auto,Auto,*">
|
<Grid RowDefinitions="Auto,Auto,Auto,*">
|
||||||
<Border Grid.Row="0"
|
<Grid Grid.Row="0"
|
||||||
Background="#ECECEC"
|
Margin="12,12,12,0"
|
||||||
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"
|
|
||||||
ColumnDefinitions="*,Auto,Auto"
|
ColumnDefinitions="*,Auto,Auto"
|
||||||
ColumnSpacing="8">
|
ColumnSpacing="8">
|
||||||
<CheckBox Content="Отображать все переменные"
|
<CheckBox Content="Отображать все переменные"
|
||||||
@@ -62,7 +37,7 @@
|
|||||||
MinWidth="140" />
|
MinWidth="140" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid Grid.Row="2"
|
<Grid Grid.Row="1"
|
||||||
Margin="12,8,12,0"
|
Margin="12,8,12,0"
|
||||||
ColumnDefinitions="Auto,2*,3*,Auto"
|
ColumnDefinitions="Auto,2*,3*,Auto"
|
||||||
ColumnSpacing="8">
|
ColumnSpacing="8">
|
||||||
@@ -81,7 +56,7 @@
|
|||||||
MinWidth="100" />
|
MinWidth="100" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<StackPanel Grid.Row="3"
|
<StackPanel Grid.Row="2"
|
||||||
Margin="12,4,12,0"
|
Margin="12,4,12,0"
|
||||||
Spacing="2">
|
Spacing="2">
|
||||||
<TextBlock Foreground="#C62828"
|
<TextBlock Foreground="#C62828"
|
||||||
@@ -93,7 +68,7 @@
|
|||||||
IsVisible="{Binding ReloadEnvironmentMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" />
|
IsVisible="{Binding ReloadEnvironmentMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<Border Grid.Row="4"
|
<Border Grid.Row="3"
|
||||||
Margin="12,4,12,12"
|
Margin="12,4,12,12"
|
||||||
CornerRadius="8"
|
CornerRadius="8"
|
||||||
ClipToBounds="True"
|
ClipToBounds="True"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
|
||||||
using Sms.TaskTwo.ViewModels;
|
using Sms.TaskTwo.ViewModels;
|
||||||
|
|
||||||
namespace Sms.TaskTwo.Avalonia.Views;
|
namespace Sms.TaskTwo.Avalonia.Views;
|
||||||
@@ -92,10 +91,4 @@ public partial class MainWindow : Window
|
|||||||
gridRow.Classes.Add("userStore");
|
gridRow.Classes.Add("userStore");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMinimizeClick(object? sender, RoutedEventArgs e) =>
|
|
||||||
WindowState = WindowState.Minimized;
|
|
||||||
|
|
||||||
private void OnCloseClick(object? sender, RoutedEventArgs e) =>
|
|
||||||
Close();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,13 @@ public static class ServiceCollectionExtensions
|
|||||||
{
|
{
|
||||||
var options = serviceProvider.GetRequiredService<IOptions<LoggingOptions>>().Value;
|
var options = serviceProvider.GetRequiredService<IOptions<LoggingOptions>>().Value;
|
||||||
Directory.CreateDirectory(options.LogDirectory);
|
Directory.CreateDirectory(options.LogDirectory);
|
||||||
var fileName = Path.Combine(
|
var timestamp = DateTime.Now.ToString("yyyyMMdd-hh:mm:ss");
|
||||||
options.LogDirectory,
|
var logFileName = SanitizeFileName($"test-sms-wpf-app-{timestamp}.log");
|
||||||
$"test-sms-wpf-app-{DateTime.Now:yyyyMMdd}.log");
|
var fileName = Path.Combine(options.LogDirectory, logFileName);
|
||||||
return ConsoleLog.Open(fileName);
|
return ConsoleLog.Open(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string SanitizeFileName(string fileName) =>
|
||||||
|
string.Concat(fileName.Select(static c =>
|
||||||
|
Path.GetInvalidFileNameChars().Contains(c) ? '-' : c));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user