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>
+7
View File
@@ -205,6 +205,12 @@ class MainViewModel : BaseViewModel, IFontResolver
} }
public async void BuildPDF() public async void BuildPDF()
{
if (string.IsNullOrWhiteSpace(ReportTitle))
{
await DialogHost.Show(new WarningViewModel("You must provide a report title!"));
}
else
{ {
try try
{ {
@@ -227,6 +233,7 @@ class MainViewModel : BaseViewModel, IFontResolver
} }
} }
} }
}
public byte[]? GetFont(string faceName) public byte[]? GetFont(string faceName)
{ {
+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>