Skip to content

Commit 52c974f

Browse files
committed
feat(UI): Added confirmation dialog for clearing records and adjusted button layout
Add a confirmation dialog before clearing records on the QR code and barcode pages to prevent accidental operations Move the clear button next to the navigation buttons to optimize the interface layout
1 parent 2f39011 commit 52c974f

7 files changed

Lines changed: 66 additions & 28 deletions

File tree

Pages/BarcodePage.xaml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,32 @@
1616
</Grid.RowDefinitions>
1717

1818
<StackPanel Grid.Row="0" VerticalAlignment="Top" HorizontalAlignment="Left">
19-
<Button Click="Back_Click" HorizontalAlignment="Left" Width="40" Height="40" Margin="0,0,0,8" ToolTip="{x:Static resources:Strings.Back}">
20-
<Button.Template>
21-
<ControlTemplate TargetType="Button">
22-
<Border Background="#4A4A4A" CornerRadius="20" Width="40" Height="40" SnapsToDevicePixels="True">
23-
<TextBlock FontFamily="{StaticResource FontAwesomeSolid}" Text="&#xf060;" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFFFFF" />
24-
</Border>
25-
</ControlTemplate>
26-
</Button.Template>
27-
</Button>
19+
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="0,0,0,8">
20+
<Button Click="Back_Click" HorizontalAlignment="Left" Width="40" Height="40" Margin="0,0,8,0" ToolTip="{x:Static resources:Strings.Back}">
21+
<Button.Template>
22+
<ControlTemplate TargetType="Button">
23+
<Border Background="#4A4A4A" CornerRadius="20" Width="40" Height="40" SnapsToDevicePixels="True">
24+
<TextBlock FontFamily="{StaticResource FontAwesomeSolid}" Text="&#xf060;" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFFFFF" />
25+
</Border>
26+
</ControlTemplate>
27+
</Button.Template>
28+
</Button>
29+
<Button Click="ClearAll_Click" Width="40" Height="40" ToolTip="{x:Static resources:Strings.ClearAll}">
30+
<Button.Template>
31+
<ControlTemplate TargetType="Button">
32+
<Border Background="#4A4A4A" CornerRadius="20" Width="40" Height="40" SnapsToDevicePixels="True">
33+
<TextBlock FontFamily="{StaticResource FontAwesomeSolid}" Text="&#xf2ed;" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFFFFF" />
34+
</Border>
35+
</ControlTemplate>
36+
</Button.Template>
37+
</Button>
38+
</StackPanel>
2839
<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
2940
<TextBlock Text="{x:Static resources:Strings.PageBarcode}" FontSize="18" Margin="10,0" VerticalAlignment="Center" />
3041
<TextBox x:Name="InputText" Height="30" Width="300" Margin="10,0" VerticalAlignment="Center" VerticalContentAlignment="Center" />
3142
<Button Click="Generate_Click" Width="100" Height="32" Margin="8,0" VerticalAlignment="Center" ToolTip="{x:Static resources:Strings.Generate}">
3243
<TextBlock FontFamily="{StaticResource FontAwesomeSolid}" Text="&#xf02a;" FontSize="16" FontWeight="Bold" Foreground="#FFFFFF" />
3344
</Button>
34-
<Button Click="ClearAll_Click" Width="100" Height="32" Margin="8,0" VerticalAlignment="Center" ToolTip="{x:Static resources:Strings.ClearAll}">
35-
<TextBlock FontFamily="{StaticResource FontAwesomeSolid}" Text="&#xf2ed;" FontSize="16" FontWeight="Bold" Foreground="#FFFFFF" />
36-
</Button>
3745
</StackPanel>
3846
</StackPanel>
3947

Pages/BarcodePage.xaml.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,12 @@ private void DeleteLog_Click(object sender, RoutedEventArgs e)
260260

261261
private void ClearAll_Click(object sender, RoutedEventArgs e)
262262
{
263-
foreach (var l in _logs) { try { l.Bitmap?.Dispose(); } catch { } }
264-
_logs.Clear();
263+
var result = MessageBox.Show(Strings.ConfirmClearMessage, Strings.ConfirmClear, MessageBoxButton.YesNo, MessageBoxImage.Question);
264+
if (result == MessageBoxResult.Yes)
265+
{
266+
foreach (var l in _logs) { try { l.Bitmap?.Dispose(); } catch { } }
267+
_logs.Clear();
268+
}
265269
}
266270

267271
private BitmapSource BitmapToImageSource(Bitmap bitmap)

Pages/QrPage.xaml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,32 @@
1616
</Grid.RowDefinitions>
1717

1818
<StackPanel Grid.Row="0" VerticalAlignment="Top" HorizontalAlignment="Left">
19-
<Button Click="Back_Click" HorizontalAlignment="Left" Width="40" Height="40" Margin="0,0,0,8" ToolTip="{x:Static resources:Strings.Back}">
20-
<Button.Template>
21-
<ControlTemplate TargetType="Button">
22-
<Border Background="#4A4A4A" CornerRadius="20" Width="40" Height="40" SnapsToDevicePixels="True">
23-
<TextBlock FontFamily="{StaticResource FontAwesomeSolid}" Text="&#xf060;" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFFFFF" />
24-
</Border>
25-
</ControlTemplate>
26-
</Button.Template>
27-
</Button>
19+
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="0,0,0,8">
20+
<Button Click="Back_Click" HorizontalAlignment="Left" Width="40" Height="40" Margin="0,0,8,0" ToolTip="{x:Static resources:Strings.Back}">
21+
<Button.Template>
22+
<ControlTemplate TargetType="Button">
23+
<Border Background="#4A4A4A" CornerRadius="20" Width="40" Height="40" SnapsToDevicePixels="True">
24+
<TextBlock FontFamily="{StaticResource FontAwesomeSolid}" Text="&#xf060;" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFFFFF" />
25+
</Border>
26+
</ControlTemplate>
27+
</Button.Template>
28+
</Button>
29+
<Button Click="ClearAll_Click" Width="40" Height="40" ToolTip="{x:Static resources:Strings.ClearAll}">
30+
<Button.Template>
31+
<ControlTemplate TargetType="Button">
32+
<Border Background="#4A4A4A" CornerRadius="20" Width="40" Height="40" SnapsToDevicePixels="True">
33+
<TextBlock FontFamily="{StaticResource FontAwesomeSolid}" Text="&#xf2ed;" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFFFFF" />
34+
</Border>
35+
</ControlTemplate>
36+
</Button.Template>
37+
</Button>
38+
</StackPanel>
2839
<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
2940
<TextBlock Text="{x:Static resources:Strings.PageQRCode}" FontSize="18" Margin="10,0" VerticalAlignment="Center" />
3041
<TextBox x:Name="InputText" Height="30" Width="300" Margin="10,0" VerticalAlignment="Center" VerticalContentAlignment="Center" />
3142
<Button Click="Generate_Click" Width="100" Height="32" Margin="8,0" VerticalAlignment="Center" ToolTip="{x:Static resources:Strings.Generate}">
3243
<TextBlock FontFamily="{StaticResource FontAwesomeSolid}" Text="&#xf029;" FontSize="16" FontWeight="Bold" Foreground="#FFFFFF" />
3344
</Button>
34-
<Button Click="ClearAll_Click" Width="100" Height="32" Margin="8,0" VerticalAlignment="Center" ToolTip="{x:Static resources:Strings.ClearAll}">
35-
<TextBlock FontFamily="{StaticResource FontAwesomeSolid}" Text="&#xf2ed;" FontSize="16" FontWeight="Bold" Foreground="#FFFFFF" />
36-
</Button>
3745
</StackPanel>
3846
</StackPanel>
3947

Pages/QrPage.xaml.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,12 @@ private void DeleteLog_Click(object sender, RoutedEventArgs e)
250250

251251
private void ClearAll_Click(object sender, RoutedEventArgs e)
252252
{
253-
foreach (var l in _logs) { try { l.Bitmap?.Dispose(); } catch { } }
254-
_logs.Clear();
253+
var result = MessageBox.Show(Strings.ConfirmClearMessage, Strings.ConfirmClear, MessageBoxButton.YesNo, MessageBoxImage.Question);
254+
if (result == MessageBoxResult.Yes)
255+
{
256+
foreach (var l in _logs) { try { l.Bitmap?.Dispose(); } catch { } }
257+
_logs.Clear();
258+
}
255259
}
256260

257261
private BitmapSource BitmapToImageSource(Bitmap bitmap)

Resources/Strings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,7 @@ public static string Get(string key)
126126
public static string InputEmpty => Get("InputEmpty");
127127
public static string OutputEmpty => Get("OutputEmpty");
128128
public static string AppPathEmptyOrNotFound => Get("AppPathEmptyOrNotFound");
129+
public static string ConfirmClear => Get("ConfirmClear");
130+
public static string ConfirmClearMessage => Get("ConfirmClearMessage");
129131
}
130132
}

Resources/Strings.en-US.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,4 +406,10 @@
406406
<data name="AppPathEmptyOrNotFound" xml:space="preserve">
407407
<value>Application path is empty or file not found</value>
408408
</data>
409+
<data name="ConfirmClear" xml:space="preserve">
410+
<value>Confirm Clear</value>
411+
</data>
412+
<data name="ConfirmClearMessage" xml:space="preserve">
413+
<value>Are you sure you want to clear all records? This action cannot be undone.</value>
414+
</data>
409415
</root>

Resources/Strings.zh-CN.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,10 @@
310310
<data name="Processing" xml:space="preserve">
311311
<value>处理中...</value>
312312
</data>
313+
<data name="ConfirmClear" xml:space="preserve">
314+
<value>确认清除</value>
315+
</data>
316+
<data name="ConfirmClearMessage" xml:space="preserve">
317+
<value>确定要清除所有记录吗?此操作不可撤销。</value>
318+
</data>
313319
</root>

0 commit comments

Comments
 (0)