Show warning if no report title

This commit is contained in:
2026-02-16 18:18:41 +09:00
parent e0b499dd3c
commit 833e97fbea
3 changed files with 28 additions and 14 deletions
+3
View File
@@ -97,6 +97,9 @@
<DataTemplate DataType="{x:Type viewModels:AboutViewModel}"> <DataTemplate DataType="{x:Type viewModels:AboutViewModel}">
<views:AboutView/> <views:AboutView/>
</DataTemplate> </DataTemplate>
<DataTemplate DataType="{x:Type viewModels:WarningViewModel}">
<views:WarningView/>
</DataTemplate>
</Application.DataTemplates> </Application.DataTemplates>
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
+19 -12
View File
@@ -206,23 +206,30 @@ class MainViewModel : BaseViewModel, IFontResolver
public async void BuildPDF() public async void BuildPDF()
{ {
try if (string.IsNullOrWhiteSpace(ReportTitle))
{ {
// TODO: use already found files and information await DialogHost.Show(new WarningViewModel("You must provide a report title!"));
await Task.Run(() => CreatePDF(_workingFolder)); }
} catch (Exception e) else
{ {
LogInfo("PDF process failed! Reason: " + e.Message); try
if (e.StackTrace != null)
{ {
LogInfo(e.StackTrace); // TODO: use already found files and information
} await Task.Run(() => CreatePDF(_workingFolder));
if (e.InnerException != null) } catch (Exception e)
{ {
LogInfo("Inner exception: " + e.InnerException.Message); LogInfo("PDF process failed! Reason: " + e.Message);
if (e.InnerException.StackTrace != null) if (e.StackTrace != null)
{ {
LogInfo(e.InnerException.StackTrace); LogInfo(e.StackTrace);
}
if (e.InnerException != null)
{
LogInfo("Inner exception: " + e.InnerException.Message);
if (e.InnerException.StackTrace != null)
{
LogInfo(e.InnerException.StackTrace);
}
} }
} }
} }
+6 -2
View File
@@ -10,16 +10,20 @@
x:DataType="vm:WarningViewModel"> x:DataType="vm:WarningViewModel">
<StackPanel Orientation="Vertical" <StackPanel Orientation="Vertical"
Spacing="4"> Spacing="4">
<TextBlock TextAlignment="Center"
FontWeight="Bold"
FontSize="18"
Text="Error!"/>
<TextBlock TextAlignment="Center" <TextBlock TextAlignment="Center"
FontWeight="Bold" FontWeight="Bold"
TextWrapping="Wrap" TextWrapping="Wrap"
FontSize="16" FontSize="14"
MaxWidth="350" MaxWidth="350"
Text="{Binding Error}"/> Text="{Binding Error}"/>
<Button Command="{Binding Close}" <Button Command="{Binding Close}"
Classes="accent" Classes="accent"
Content="Close" Content="Close"
HorizontalAlignment="Right" HorizontalAlignment="Right"
Margin="0,0,4,4"/> Margin="0,4,4,4"/>
</StackPanel> </StackPanel>
</UserControl> </UserControl>