2026-02-28 21:48:05 +01:00
|
|
|
using Avalonia.Controls;
|
|
|
|
|
using Avalonia.Interactivity;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace ImageCatalog_2.AvaloniaViews;
|
|
|
|
|
|
|
|
|
|
public partial class AiTabView : Avalonia.Controls.UserControl
|
|
|
|
|
{
|
|
|
|
|
public AiTabView()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OpenModelsFolder_Click(object? sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (DataContext is DataModel model)
|
|
|
|
|
{
|
|
|
|
|
OpenInExplorer(model.ModelsFolderPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OpenCsvOutputFolder_Click(object? sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (DataContext is not DataModel model)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var directory = Path.GetDirectoryName(model.CsvOutputPath);
|
|
|
|
|
OpenInExplorer(string.IsNullOrWhiteSpace(directory) ? model.CsvOutputPath : directory);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-09 17:27:05 +02:00
|
|
|
private void OpenAiDestinationFolder_Click(object? sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (DataContext is DataModel model)
|
|
|
|
|
{
|
|
|
|
|
OpenInExplorer(model.DestinationPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-28 21:48:05 +01:00
|
|
|
private static void OpenInExplorer(string? path)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(path))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var normalizedPath = path.Trim().Trim('"');
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (File.Exists(normalizedPath))
|
|
|
|
|
{
|
|
|
|
|
Process.Start("explorer.exe", $"/select,\"{normalizedPath}\"");
|
|
|
|
|
}
|
|
|
|
|
else if (Directory.Exists(normalizedPath))
|
|
|
|
|
{
|
|
|
|
|
Process.Start(new ProcessStartInfo { FileName = normalizedPath, UseShellExecute = true });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
// Ignore failures when opening Explorer.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|