move calls to viewmodel

This commit is contained in:
Jeremy 2025-05-21 21:30:47 +10:00
parent 9a692a894d
commit 07f77f0077
2 changed files with 22 additions and 5 deletions

View file

@ -32,18 +32,18 @@ namespace Flow.Launcher
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
App.API.OpenUrl(e.Uri.AbsoluteUri);
_viewModel.OpenUrl(e.Uri.AbsoluteUri);
e.Handled = true;
}
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
{
var dlg = new Microsoft.Win32.OpenFileDialog();
var result = dlg.ShowDialog();
if (result == true)
var selectedFilePath = _viewModel.SelectFile();
if (!string.IsNullOrEmpty(selectedFilePath))
{
var path = (TextBox)(((FrameworkElement)sender).Parent as FrameworkElement).FindName("PathTextBox");
path.Text = dlg.FileName;
path.Text = selectedFilePath;
path.Focus();
((Button)sender).Focus();
}

View file

@ -98,6 +98,23 @@ public partial class SelectFileManagerViewModel : BaseModel
}
}
internal void OpenUrl(string absoluteUri)
{
App.API.OpenUrl(absoluteUri);
}
internal string SelectFile()
{
var dlg = new Microsoft.Win32.OpenFileDialog();
var result = dlg.ShowDialog();
if (result == true)
{
return dlg.FileName;
}
return string.Empty;
}
[RelayCommand]
private void Add()
{