48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Markup.Xaml;
|
|
|
|
using btd_pdf_avalonia.ViewModels;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Input;
|
|
|
|
namespace btd_pdf_avalonia.Views {
|
|
public partial class MainWindow : Window, INotifyPropertyChanged {
|
|
|
|
public MainWindow() {
|
|
InitializeComponent();
|
|
this.DataContext = new MainWindowViewModel();
|
|
|
|
}
|
|
|
|
private void InitializeComponent() {
|
|
AvaloniaXamlLoader.Load(this);
|
|
}
|
|
|
|
|
|
public async Task<string> SetPath() {
|
|
OpenFileDialog dialog = new OpenFileDialog();
|
|
//dialog.Filters.Add(new FileDialogFilter() { Name = "Text", Extensions = { "txt" } });
|
|
|
|
string[]? result = await dialog.ShowAsync(this);
|
|
|
|
if (result != null) {
|
|
return string.Join(" ", result);
|
|
}
|
|
|
|
return "";
|
|
}
|
|
|
|
public async void OpenFile_Click(object sender, RoutedEventArgs args) {
|
|
string filename = await SetPath();
|
|
var context = this.DataContext as MainWindowViewModel;
|
|
context.SourcePath = filename;
|
|
}
|
|
}
|
|
}
|