forked from amkovkov/GranuSightSoftware2
feat: results exporting
This commit is contained in:
@@ -184,6 +184,7 @@ public static class UI
|
||||
// builder.Services.AddTemperatureHumidityService("Hardware:TemperatureHumidity");
|
||||
builder.Services.AddIlluminatorService("Hardware:Illuminator");
|
||||
builder.Services.AddCameraService("Hardware:Camera", true);
|
||||
builder.Services.AddUsbService();
|
||||
}
|
||||
builder.Services.AddAmineContentImageCapturerService(mock);
|
||||
builder.Services.AddAmineContentAnalyzerService();
|
||||
|
||||
@@ -43,9 +43,11 @@ public static class DependencyInjectionHelper
|
||||
.AddSingleton<ViewModels.AmineContent.SampleCalibrationViewModel>()
|
||||
.AddSingleton<ViewModels.AmineContent.SeparatorCalibrationViewModel>()
|
||||
.AddSingleton<ViewModels.AmineContent.BrandCalibrationViewModel>()
|
||||
.AddSingleton<ViewModels.AmineContent.ExportViewModel>()
|
||||
.AddSingleton<Views.AmineContent.StartView>()
|
||||
.AddSingleton<Views.AmineContent.AnalysisView>()
|
||||
.AddSingleton<Views.AmineContent.SampleCalibrationView>()
|
||||
.AddSingleton<Views.AmineContent.SeparatorCalibrationView>()
|
||||
.AddSingleton<Views.AmineContent.BrandCalibrationView>();
|
||||
.AddSingleton<Views.AmineContent.BrandCalibrationView>()
|
||||
.AddSingleton<Views.AmineContent.ExportView>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
using Avalonia.Threading;
|
||||
|
||||
using GSS2.Core.Hardware;
|
||||
using GSS2.Core.Analysis.AmineContent;
|
||||
using GSS2.Core.Analysis.AmineContent.Database;
|
||||
|
||||
using GSS2.UI.Core.ViewModels;
|
||||
using GSS2.UI.Core.Services;
|
||||
|
||||
namespace GSS2.ViewModels.AmineContent;
|
||||
|
||||
public partial class ExportViewModel : ViewModelBase
|
||||
{
|
||||
public partial class UsbDiskViewModel : ViewModelBase
|
||||
{
|
||||
[ObservableProperty] public partial string Id { get; set; }
|
||||
[ObservableProperty] public partial string Name { get; set; }
|
||||
[ObservableProperty] public partial bool Mounted { get; set; }
|
||||
[ObservableProperty] public partial string? MountPath { get; set; }
|
||||
|
||||
public UsbDiskViewModel(string id, string name, bool mounted, string mountPath)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
Mounted = mounted;
|
||||
MountPath = mountPath;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class RecordListViewModel : ViewModelBase
|
||||
{
|
||||
[ObservableProperty] public partial int Id { get; set; }
|
||||
[ObservableProperty] public partial string SampleName { get; set; }
|
||||
|
||||
public RecordListViewModel(int id, string sampleName)
|
||||
{
|
||||
Id = id;
|
||||
SampleName = sampleName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Логгер
|
||||
/// </summary>
|
||||
private readonly ILogger<ExportViewModel> _logger;
|
||||
/// <summary>
|
||||
/// Контекст базы данных
|
||||
/// </summary>
|
||||
private readonly Context _context;
|
||||
/// <summary>
|
||||
/// Сервис дисков
|
||||
/// </summary>
|
||||
private readonly UsbService _usb;
|
||||
|
||||
/// <summary>
|
||||
/// Диск смонтирован
|
||||
/// </summary>
|
||||
[ObservableProperty] public partial bool DiskMounted { get; set; } = false;
|
||||
/// <summary>
|
||||
/// Список дисков
|
||||
/// </summary>
|
||||
[ObservableProperty] public partial ObservableCollection<UsbDiskViewModel> Disks { get; set; }
|
||||
/// <summary>
|
||||
/// Индекс выбранного диска
|
||||
/// </summary>
|
||||
[ObservableProperty] public partial int DisksSelectedIndex { get; set; } = -1;
|
||||
/// <summary>
|
||||
/// Записи
|
||||
/// </summary>
|
||||
[ObservableProperty] public partial ObservableCollection<RecordListViewModel> Records { get; set; }
|
||||
/// <summary>
|
||||
/// Выбранные для экспорта записи
|
||||
/// </summary>
|
||||
[ObservableProperty] public partial ObservableCollection<RecordListViewModel> SelectedRecords { get; set; } = new();
|
||||
/// <summary>
|
||||
/// Путь точки монтирования
|
||||
/// </summary>
|
||||
[ObservableProperty] public partial string? DiskMountPath { get; set; } = null;
|
||||
/// <summary>
|
||||
/// Оповещение отображено
|
||||
/// </summary>
|
||||
[ObservableProperty] public partial bool IsNotificationVisible { get; set; } = false;
|
||||
/// <summary>
|
||||
/// Текст оповещения
|
||||
/// </summary>
|
||||
[ObservableProperty] public partial string NotificationMessage { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Оповещение об удаче
|
||||
/// </summary>
|
||||
[ObservableProperty] public partial bool IsSuccessNotification { get; set; } = false;
|
||||
|
||||
public ExportViewModel(
|
||||
ILogger<ExportViewModel> logger,
|
||||
Context context,
|
||||
UsbService usb
|
||||
)
|
||||
{
|
||||
// Устанавливаем readonly поля
|
||||
_logger = logger;
|
||||
_context = context;
|
||||
_usb = usb;
|
||||
_logger.LogInformation("Инициализация");
|
||||
|
||||
// Получаем список дисков
|
||||
Disks = new();
|
||||
RefreshDisks();
|
||||
|
||||
// Получаем список результатов
|
||||
Records = new ObservableCollection<RecordListViewModel>(_context.ResultRecords.Select(r => new RecordListViewModel(r.Id, r.SampleName)));
|
||||
|
||||
// Подписываемся на изменения базы данных для отслеживания изменений списка результатов
|
||||
_context.ChangeTracker.StateChanged += (_, ea) =>
|
||||
{
|
||||
// Обновляем данные в интерфейсе
|
||||
// Dispatcher.UIThread.Invoke нужен потому-что этот метод может (и скорее всего будет) вызван в другом потоке,
|
||||
// а изменения данных в интерфейсе могут быть вызваны только из потока в котором интерфейс был создан
|
||||
_ = Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
// Если запись является ResultRecord
|
||||
if (ea.Entry.Entity is ResultRecord resultRecord)
|
||||
{
|
||||
// Если запись добавлена
|
||||
if (ea.OldState is EntityState.Added && ea.NewState is EntityState.Unchanged)
|
||||
{
|
||||
// Добавляем запись
|
||||
Records.Add(new RecordListViewModel(resultRecord.Id, resultRecord.SampleName));
|
||||
}
|
||||
// Если запись удалена
|
||||
else if (ea.NewState is EntityState.Deleted)
|
||||
{
|
||||
// Ищем удалённую запись в списке
|
||||
var deletedItem = Records.FirstOrDefault(r => r.Id == resultRecord.Id);
|
||||
// Если запись не найдена в списке, то логгируем как ошибку
|
||||
if (deletedItem is null)
|
||||
{
|
||||
_logger.LogError("Не удалось найти элемент с Id({}) в списке {}", resultRecord.Id, nameof(Records));
|
||||
return;
|
||||
}
|
||||
// Если удаляемый элемент выбран, то удаляем его из выбранных
|
||||
if (SelectedRecords.Contains(deletedItem))
|
||||
SelectedRecords.Remove(deletedItem);
|
||||
// Удаляем элемент из списка
|
||||
Records.Remove(deletedItem);
|
||||
}
|
||||
// Если запись изменилась
|
||||
else if (ea.NewState is EntityState.Modified)
|
||||
{
|
||||
// Ищем изменённую запись в списке
|
||||
var editedItem = Records.FirstOrDefault(r => r.Id == resultRecord.Id);
|
||||
// Если запись не найдена в списке, то логгируем как ошибку
|
||||
if (editedItem is null)
|
||||
{
|
||||
_logger.LogError("Не удалось найти элемент с Id({}) в списке {}", resultRecord.Id, nameof(Records));
|
||||
return;
|
||||
}
|
||||
editedItem.SampleName = resultRecord.SampleName;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
_logger.LogInformation("Инициализировано");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обновить список дисков
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
private void RefreshDisks()
|
||||
{
|
||||
Disks.Clear();
|
||||
var disks = _usb.GetDevices();
|
||||
|
||||
disks.ForEach(d => Disks.Add(new UsbDiskViewModel(d.id, d.name, d.mounted, d.mountPath)));
|
||||
if (disks.Count() == 0 ||
|
||||
DisksSelectedIndex >= disks.Count()
|
||||
)
|
||||
DisksSelectedIndex = -1;
|
||||
if (DisksSelectedIndex == -1 &&
|
||||
disks.Count() != 0
|
||||
)
|
||||
DisksSelectedIndex = 0;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Смонтировать диск
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
private void MountDisk()
|
||||
{
|
||||
if (DiskMounted)
|
||||
{
|
||||
_logger.LogError("Диск уже смонтирован");
|
||||
RefreshDisks();
|
||||
return;
|
||||
}
|
||||
if (DisksSelectedIndex < 0 || DisksSelectedIndex >= Disks.Count())
|
||||
{
|
||||
_logger.LogError("Выбранный диск вне дисапзона");
|
||||
RefreshDisks();
|
||||
return;
|
||||
}
|
||||
|
||||
var disk = Disks[DisksSelectedIndex];
|
||||
if (disk.Mounted)
|
||||
{
|
||||
_logger.LogWarning("Выбранный диск уже смонтирован");
|
||||
DiskMountPath = disk.MountPath;
|
||||
DiskMounted = DiskMountPath is not null;
|
||||
disk.Mounted = DiskMountPath is not null;
|
||||
RefreshDisks();
|
||||
}
|
||||
else
|
||||
{
|
||||
DiskMountPath = _usb.MountDevice(disk.Id);
|
||||
DiskMounted = DiskMountPath is not null;
|
||||
disk.Mounted = DiskMountPath is not null;
|
||||
RefreshDisks();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Размонтировать диск
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
private void UnmountDisk()
|
||||
{
|
||||
if (!DiskMounted)
|
||||
{
|
||||
_logger.LogError("Диск не смонтирован");
|
||||
return;
|
||||
}
|
||||
if (DisksSelectedIndex < 0 || DisksSelectedIndex >= Disks.Count())
|
||||
{
|
||||
_logger.LogError("Выбранный диск вне дисапзона");
|
||||
return;
|
||||
}
|
||||
|
||||
var disk = Disks[DisksSelectedIndex];
|
||||
if (!disk.Mounted)
|
||||
{
|
||||
_logger.LogError("Выбранный диск не смонтирован");
|
||||
return;
|
||||
}
|
||||
var result = _usb.UnmountDevice(disk.Id);
|
||||
if (result)
|
||||
{
|
||||
DiskMountPath = null;
|
||||
DiskMounted = false;
|
||||
disk.Mounted = false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Экспортировать выбранные результаты в csv
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
private void ExportCsv()
|
||||
{
|
||||
if (!DiskMounted || DiskMountPath is null)
|
||||
{
|
||||
_logger.LogError("Диск не смонтирован");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var fileName = $"{DateTime.Now:yyyyMMdd_HHmmss}.csv";
|
||||
var exportPath = Path.Join(DiskMountPath, fileName);
|
||||
var exportingRecords = SelectedRecords.Select(r => _context.ResultRecords.Find(r.Id));
|
||||
if (exportingRecords.Count() == 0)
|
||||
{
|
||||
_logger.LogWarning("Не выбраны записи для экспорта");
|
||||
ShowNotification("Не выбраны записи для экспорта", false);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Количество записей для экспорта: {}", exportingRecords.Count());
|
||||
ResultExporter.ExportCsv(exportPath, exportingRecords);
|
||||
_logger.LogInformation("Результаты экспортированны в файл: {}", exportPath);
|
||||
ShowNotification($"Файл успешно экспортирован:\n{fileName}", true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Исключение во время экспорта результатов");
|
||||
ShowNotification("Ошибка при экспорте файла", false);
|
||||
UnmountDisk();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Запкрыть оповещение
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
private void DismissNotification()
|
||||
{
|
||||
IsNotificationVisible = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Экспортировать выбранные результаты в pdf
|
||||
/// </summary>
|
||||
// [RelayCommand]
|
||||
// private void ExportPdf()
|
||||
// {
|
||||
// if (!DiskMounted || MountPath is null)
|
||||
// {
|
||||
// _logger.LogError("Диск не смонтирован");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// try
|
||||
// {
|
||||
// var exportPath = Path.Join(MountPath, $"{DateTime.Now:ddMMyyyy_hhmmss}.csv");
|
||||
// var exportingRecords = SelectedRecords.Select(r => _context.Find(r.Id));
|
||||
// GSS2.Core.RecordsExporter.ExportPdf(exportPath, exportingRecords);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// _logger.LogError(ex, "Исключение во время экспорта результатов");
|
||||
// }
|
||||
// }
|
||||
|
||||
private void ShowNotification(string message, bool isSuccess)
|
||||
{
|
||||
NotificationMessage = message;
|
||||
IsSuccessNotification = isSuccess;
|
||||
IsNotificationVisible = true;
|
||||
Task.Delay(5000).ContinueWith(_ => IsNotificationVisible = false);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ public partial class AmineContentViewModel : ViewModelBase
|
||||
[ObservableProperty] public partial SeparatorCalibrationViewModel SeparatorCalibration { get; set; }
|
||||
// [ObservableProperty] public partial CameraViewModel Camera { get; set; }
|
||||
[ObservableProperty] public partial BrandCalibrationViewModel BrandCalibration { get; set; }
|
||||
[ObservableProperty] public partial ExportViewModel Export { get; set; }
|
||||
// [ObservableProperty] public partial SystemViewModel System { get; set; }
|
||||
|
||||
[ObservableProperty] public partial int CurrentIndex { get; set; } = 0;
|
||||
@@ -31,7 +32,8 @@ public partial class AmineContentViewModel : ViewModelBase
|
||||
AnalysisViewModel analysis,
|
||||
SampleCalibrationViewModel sampleCalibration,
|
||||
SeparatorCalibrationViewModel separatorCalibration,
|
||||
BrandCalibrationViewModel brandCalibration
|
||||
BrandCalibrationViewModel brandCalibration,
|
||||
ExportViewModel export
|
||||
)
|
||||
{
|
||||
_navigationService = navigationService;
|
||||
@@ -39,6 +41,7 @@ public partial class AmineContentViewModel : ViewModelBase
|
||||
SampleCalibration = sampleCalibration;
|
||||
SeparatorCalibration = separatorCalibration;
|
||||
BrandCalibration = brandCalibration;
|
||||
Export = export;
|
||||
|
||||
PropertyChanged += (_, ea) =>
|
||||
{
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
<UserControl
|
||||
x:Class="GSS2.Views.AmineContent.ExportView"
|
||||
x:DataType="vm:ExportViewModel"
|
||||
xmlns:controls="using:GSS2.Controls"
|
||||
xmlns:core="using:GSS2.UI.Core"
|
||||
xmlns:i="using:Avalonia.Xaml.Interactivity"
|
||||
xmlns:ia="using:Avalonia.Xaml.Interactions.Custom"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:GSS2.ViewModels.AmineContent"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
>
|
||||
|
||||
<Grid Background="{StaticResource MainBackground}">
|
||||
<Grid IsVisible="{Binding !DiskMounted}">
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid.ColumnSpacing>5</Grid.ColumnSpacing>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" /> <!-- Подпись -->
|
||||
<RowDefinition Height="Auto" /> <!-- Выбор диска/Кнопка "Обновить список" -->
|
||||
<RowDefinition Height="*" /> <!-- Пустое пространство -->
|
||||
<RowDefinition Height="Auto" /> <!-- Кнопка "Смонтировать диск" -->
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.RowSpacing>5</Grid.RowSpacing>
|
||||
|
||||
<!-- Подпись -->
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Grid.Row="0"
|
||||
Text="Выберите диск:"
|
||||
/>
|
||||
<!-- Выбор диска -->
|
||||
<ComboBox
|
||||
Classes="singleline"
|
||||
Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
IsEditable="False"
|
||||
ItemsSource="{Binding Disks}"
|
||||
PlaceholderText="Диск не выбран"
|
||||
SelectedIndex="{Binding DisksSelectedIndex}"
|
||||
>
|
||||
|
||||
<ComboBox.Styles>
|
||||
|
||||
<Style Selector="ComboBox /template/ ContentPresenter#PART_ContentPresenter">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="ComboBoxItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
</ComboBox.Styles>
|
||||
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:ExportViewModel+UsbDiskViewModel">
|
||||
<TextBlock>
|
||||
<Run Text="{Binding Name}" />
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<!-- Кнопка "Обновить список" -->
|
||||
<Button
|
||||
Command="{Binding RefreshDisksCommand}"
|
||||
Grid.Column="1"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
VerticalContentAlignment="Center"
|
||||
>
|
||||
<TextBlock Text="Обновить список"/>
|
||||
</Button>
|
||||
|
||||
<!-- Кнопка "Смонтировать диск" -->
|
||||
<Button
|
||||
Command="{Binding MountDiskCommand}"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Grid.Row="3"
|
||||
IsEnabled="{Binding Path=DisksSelectedIndex, Converter={StaticResource GreaterThanOrEqualConverter}, ConverterParameter=0}"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
VerticalContentAlignment="Center"
|
||||
>
|
||||
<TextBlock Text="Смонтировать диск"/>
|
||||
</Button>
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid IsVisible="{Binding DiskMounted}">
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid.ColumnSpacing>5</Grid.ColumnSpacing>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" /> <!-- Подпись -->
|
||||
<RowDefinition Height="Auto" /> <!-- Кнопки -->
|
||||
<RowDefinition Height="*" /> <!-- Список -->
|
||||
<RowDefinition Height="Auto" /> <!-- Кнопки -->
|
||||
<RowDefinition Height="Auto" /> <!-- Примечение -->
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.RowSpacing>5</Grid.RowSpacing>
|
||||
|
||||
<!-- Подпись -->
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Grid.Row="0"
|
||||
Text="Выберите результатаы для экспорта:"
|
||||
/>
|
||||
<!-- Список -->
|
||||
<ListBox
|
||||
Background="{StaticResource MenuBackground}"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Grid.Row="2"
|
||||
ItemsSource="{Binding Records}"
|
||||
SelectionMode="Multiple,Toggle"
|
||||
SelectedItems="{Binding SelectedRecords}"
|
||||
>
|
||||
|
||||
<!-- Шаблон списка элементов -->
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<!-- Стили элементов -->
|
||||
<ListBox.Styles>
|
||||
|
||||
<!-- Общий стиль -->
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="Background" Value="{StaticResource ButtonBackground}" />
|
||||
</Style>
|
||||
|
||||
<!-- Стиль выбранного элемента -->
|
||||
<Style Selector="ListBoxItem:selected /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="{StaticResource MainBackground}" />
|
||||
</Style>
|
||||
|
||||
<!-- Стиль элемента над которым находится указатель -->
|
||||
<Style Selector="ListBoxItem:pointerover /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="{StaticResource MainBackground}" />
|
||||
</Style>
|
||||
|
||||
</ListBox.Styles>
|
||||
|
||||
<!-- Шаблон элемента -->
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:ExportViewModel+RecordListViewModel">
|
||||
<Border Margin="3" CornerRadius="5">
|
||||
<TextBlock
|
||||
Classes="mini"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
>
|
||||
<Run Text="{Binding Id, StringFormat='[{0}] '}" />
|
||||
<Run Text="{Binding SampleName}" />
|
||||
</TextBlock>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
|
||||
</ListBox>
|
||||
|
||||
<!-- Кнопка "Экспортировать CSV" -->
|
||||
<Button
|
||||
Command="{Binding ExportCsvCommand}"
|
||||
Grid.Column="0"
|
||||
Grid.Row="3"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
VerticalContentAlignment="Center"
|
||||
>
|
||||
<TextBlock Text="Экспортировать CSV"/>
|
||||
</Button>
|
||||
|
||||
<!-- Кнопка "Размонтировать диск" -->
|
||||
<Button
|
||||
Command="{Binding UnmountDiskCommand}"
|
||||
Grid.Column="1"
|
||||
Grid.Row="3"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
VerticalContentAlignment="Center"
|
||||
>
|
||||
<TextBlock Text="Размонтировать диск"/>
|
||||
</Button>
|
||||
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Grid.Row="4"
|
||||
HorizontalAlignment="Center"
|
||||
Text="Перед извлечением диска обязательно размонтируйте его!"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Stretch"
|
||||
/>
|
||||
|
||||
</Grid>
|
||||
|
||||
<Border
|
||||
Classes.success="{Binding IsSuccessNotification}"
|
||||
Classes.error="{Binding !IsSuccessNotification}"
|
||||
IsVisible="{Binding IsNotificationVisible}"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Stretch"
|
||||
Margin="15"
|
||||
Padding="15,10"
|
||||
CornerRadius="8"
|
||||
BoxShadow="0 4 10 0 #40000000">
|
||||
|
||||
<Border.Styles>
|
||||
<Style Selector="Border.success">
|
||||
<Setter Property="Background" Value="#2E7D32" />
|
||||
</Style>
|
||||
<Style Selector="Border.error">
|
||||
<Setter Property="Background" Value="#C62828" />
|
||||
</Style>
|
||||
</Border.Styles>
|
||||
|
||||
<Grid ColumnDefinitions="*, Auto">
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Text="{Binding NotificationMessage}"
|
||||
Foreground="White"
|
||||
FontSize="16"
|
||||
FontWeight="SemiBold"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Center"/>
|
||||
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
Command="{Binding DismissNotificationCommand}"
|
||||
Margin="10,0,0,0"
|
||||
Padding="12,8"
|
||||
Background="#33FFFFFF"
|
||||
Foreground="White"
|
||||
CornerRadius="5">
|
||||
<TextBlock Text="✕" FontSize="16" FontWeight="Bold"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,11 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace GSS2.Views.AmineContent;
|
||||
|
||||
public partial class ExportView : UserControl
|
||||
{
|
||||
public ExportView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,7 @@
|
||||
<ColumnDefinition Width="*" MinWidth="200"/> <!-- Марки -->
|
||||
<ColumnDefinition Width="*" MinWidth="200"/> <!-- Сепараторы -->
|
||||
<ColumnDefinition Width="*" MinWidth="200"/> <!-- Пробы -->
|
||||
<ColumnDefinition Width="*" MinWidth="200"/> <!-- Экспорт -->
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Анализ -->
|
||||
@@ -81,6 +82,11 @@
|
||||
<Button Grid.Column="3" Classes="menu" Command="{Binding ChangeSectionCommand}" CommandParameter="3">
|
||||
<TextBlock Classes="menu-text" Text="Пробы"/>
|
||||
</Button>
|
||||
|
||||
<!-- Экспорт -->
|
||||
<Button Grid.Column="4" Classes="menu" Command="{Binding ChangeSectionCommand}" CommandParameter="4">
|
||||
<TextBlock Classes="menu-text" Text="Экспорт"/>
|
||||
</Button>
|
||||
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
@@ -91,6 +97,7 @@
|
||||
<ContentControl Content="{Binding BrandCalibration}"/> <!-- Марки -->
|
||||
<ContentControl Content="{Binding SeparatorCalibration}"/> <!-- Сепараторы -->
|
||||
<ContentControl Content="{Binding SampleCalibration}"/> <!-- Пробы -->
|
||||
<ContentControl Content="{Binding Export}"/> <!-- Экспорт -->
|
||||
<!-- <ContentControl Content="{Binding Camera}"/> --> <!-- Камера -->
|
||||
<!-- <ContentControl Content="{Binding System}"/> --> <!-- Система -->
|
||||
</core:SectionPanel>
|
||||
|
||||
Reference in New Issue
Block a user