Allow opening file location

This commit is contained in:
2026-02-16 19:54:14 +09:00
parent f47200d636
commit 480e2317ad
2 changed files with 40 additions and 1 deletions
+24 -1
View File
@@ -214,7 +214,7 @@ class MainViewModel : BaseViewModel, IFontResolver
MimeTypes = [ "image/heic" ] MimeTypes = [ "image/heic" ]
}, },
FilePickerFileTypes.Pdf, FilePickerFileTypes.Pdf,
] ],
}); });
if (files.Count > 0) if (files.Count > 0)
{ {
@@ -260,6 +260,29 @@ class MainViewModel : BaseViewModel, IFontResolver
} }
} }
public void OpenFile(ReportFile file)
{
var topLevel = TopLevelGrabber?.GetTopLevel();
if (topLevel is not null)
{
Console.WriteLine(file.FilePath);
var launcher = topLevel.Launcher;
launcher.LaunchUriAsync(new Uri(file.FilePath));
}
}
public void OpenFileLocation(ReportFile file)
{
var topLevel = TopLevelGrabber?.GetTopLevel();
var dirName = Path.GetDirectoryName(file.FilePath);
if (topLevel is not null && dirName != null)
{
Console.WriteLine(file.FilePath);
var launcher = topLevel.Launcher;
launcher.LaunchUriAsync(new Uri(dirName));
}
}
public void ResortPDFItemsByDate() public void ResortPDFItemsByDate()
{ {
LogInfo("Sorting report files list..."); LogInfo("Sorting report files list...");
+16
View File
@@ -115,6 +115,22 @@
<TextBlock TextWrapping="Wrap" Margin="4,4,4,0"> <TextBlock TextWrapping="Wrap" Margin="4,4,4,0">
<Run FontWeight="Bold" Text="File Path"/>: <Run Text="{Binding FilePath}"/> <Run FontWeight="Bold" Text="File Path"/>: <Run Text="{Binding FilePath}"/>
<LineBreak/> <LineBreak/>
<StackPanel Orientation="Horizontal"
Spacing="8">
<Button Command="{Binding $parent[DataGrid].((vm:MainViewModel)DataContext).OpenFileLocation}"
CommandParameter="{Binding}">
<Button.Content>
<TextBlock FontSize="12"><Run Text="&#xf07c;" FontFamily="{StaticResource FontAwesomeSolid}"/> Open File Location</TextBlock>
</Button.Content>
</Button>
<Button Command="{Binding $parent[DataGrid].((vm:MainViewModel)DataContext).OpenFile}"
CommandParameter="{Binding}">
<Button.Content>
<TextBlock FontSize="12"><Run Text="&#xf07c;" FontFamily="{StaticResource FontAwesomeSolid}"/> Open File</TextBlock>
</Button.Content>
</Button>
</StackPanel>
<LineBreak/>
<Run FontWeight="Bold" Text="Notes"/>: <Run Text="{Binding Notes}"/> <Run FontWeight="Bold" Text="Notes"/>: <Run Text="{Binding Notes}"/>
</TextBlock> </TextBlock>
</DataTemplate> </DataTemplate>