Allow opening file location
This commit is contained in:
@@ -214,7 +214,7 @@ class MainViewModel : BaseViewModel, IFontResolver
|
||||
MimeTypes = [ "image/heic" ]
|
||||
},
|
||||
FilePickerFileTypes.Pdf,
|
||||
]
|
||||
],
|
||||
});
|
||||
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()
|
||||
{
|
||||
LogInfo("Sorting report files list...");
|
||||
|
||||
@@ -115,6 +115,22 @@
|
||||
<TextBlock TextWrapping="Wrap" Margin="4,4,4,0">
|
||||
<Run FontWeight="Bold" Text="File Path"/>: <Run Text="{Binding FilePath}"/>
|
||||
<LineBreak/>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Spacing="8">
|
||||
<Button Command="{Binding $parent[DataGrid].((vm:MainViewModel)DataContext).OpenFileLocation}"
|
||||
CommandParameter="{Binding}">
|
||||
<Button.Content>
|
||||
<TextBlock FontSize="12"><Run Text="" 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="" FontFamily="{StaticResource FontAwesomeSolid}"/> Open File</TextBlock>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<LineBreak/>
|
||||
<Run FontWeight="Bold" Text="Notes"/>: <Run Text="{Binding Notes}"/>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
|
||||
Reference in New Issue
Block a user