mirror of
https://github.com/4sval/FModel.git
synced 2026-06-22 07:50:10 -05:00
84 lines
2.4 KiB
C#
84 lines
2.4 KiB
C#
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Documents;
|
|
using FModel.ViewModels;
|
|
using Ookii.Dialogs.Wpf;
|
|
|
|
namespace FModel.Views;
|
|
|
|
public partial class ExportSessionWindow
|
|
{
|
|
public ExportSessionWindow()
|
|
{
|
|
InitializeComponent();
|
|
DataContext = ExportSessionViewModel.Instance;
|
|
}
|
|
|
|
private async void OnExportClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (sender is Button { DataContext: ExportSessionViewModel { CanExport: true } viewModel })
|
|
await viewModel.ExportAsync();
|
|
}
|
|
|
|
private void OnOkClick(object sender, RoutedEventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void OnCancelClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (sender is Button { DataContext: ExportSessionViewModel viewModel })
|
|
viewModel.CancelExport();
|
|
}
|
|
|
|
private void OnClearQueueClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (sender is Button { DataContext: ExportSessionViewModel viewModel })
|
|
viewModel.ClearQueue();
|
|
}
|
|
|
|
private void OnBrowseOutputDirectory(object sender, RoutedEventArgs e)
|
|
{
|
|
var folderBrowser = new VistaFolderBrowserDialog { ShowNewFolderButton = false };
|
|
if (folderBrowser.ShowDialog() == true)
|
|
ExportSessionViewModel.Instance.Options.OutputDirectory = folderBrowser.SelectedPath;
|
|
}
|
|
|
|
private void OnMakeDefaultOptions(object sender, RoutedEventArgs e)
|
|
{
|
|
if (sender is Button { DataContext: ExportSessionViewModel viewModel })
|
|
viewModel.Options.SaveAsUserDefaults();
|
|
}
|
|
|
|
private void OnResetOptions(object sender, RoutedEventArgs e)
|
|
{
|
|
if (sender is Button { DataContext: ExportSessionViewModel viewModel })
|
|
viewModel.Options.ResetToUserDefaults();
|
|
}
|
|
|
|
private void OnHyperlinkClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (e.OriginalSource is Hyperlink hyperlink)
|
|
Process.Start(new ProcessStartInfo(hyperlink.NavigateUri.AbsoluteUri) { UseShellExecute = true });
|
|
}
|
|
|
|
private void OnOpenInExplorerClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (sender is not Button { Tag: string path }) return;
|
|
|
|
try
|
|
{
|
|
if (File.Exists(path) || Directory.Exists(path))
|
|
{
|
|
Process.Start("explorer.exe", $"/select,\"{path}\"");
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
//
|
|
}
|
|
}
|
|
}
|