优化弹出框的UI

croire 2 years ago
parent cd4e16022d
commit 0f2e51fe96

@ -18,12 +18,13 @@ namespace DownKyi.Services
/// 显示一个信息弹窗 /// 显示一个信息弹窗
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
/// <param name="buttonNumber"></param>
/// <returns></returns> /// <returns></returns>
public ButtonResult ShowInfo(string message) public ButtonResult ShowInfo(string message, int buttonNumber = 2)
{ {
VectorImage image = SystemIcon.Instance().Info; VectorImage image = SystemIcon.Instance().Info;
string title = DictionaryResource.GetString("Info"); string title = DictionaryResource.GetString("Info");
return ShowMessage(image, title, message); return ShowMessage(image, title, message, buttonNumber);
} }
/// <summary> /// <summary>
@ -35,7 +36,7 @@ namespace DownKyi.Services
{ {
VectorImage image = SystemIcon.Instance().Warning; VectorImage image = SystemIcon.Instance().Warning;
string title = DictionaryResource.GetString("Warning"); string title = DictionaryResource.GetString("Warning");
return ShowMessage(image, title, message); return ShowMessage(image, title, message, 1);
} }
/// <summary> /// <summary>
@ -47,10 +48,10 @@ namespace DownKyi.Services
{ {
VectorImage image = SystemIcon.Instance().Error; VectorImage image = SystemIcon.Instance().Error;
string title = DictionaryResource.GetString("Error"); string title = DictionaryResource.GetString("Error");
return ShowMessage(image, title, message); return ShowMessage(image, title, message, 1);
} }
public ButtonResult ShowMessage(VectorImage image, string type, string message) public ButtonResult ShowMessage(VectorImage image, string type, string message, int buttonNumber)
{ {
ButtonResult result = ButtonResult.None; ButtonResult result = ButtonResult.None;
if (dialogService == null) if (dialogService == null)
@ -62,7 +63,8 @@ namespace DownKyi.Services
{ {
{ "image", image }, { "image", image },
{ "title", type }, { "title", type },
{ "message", message } { "message", message },
{ "button_number", buttonNumber }
}; };
dialogService.ShowDialog(ViewAlertDialogViewModel.Tag, param, buttonResult => dialogService.ShowDialog(ViewAlertDialogViewModel.Tag, param, buttonResult =>
{ {

@ -347,7 +347,8 @@ namespace DownKyi.Services.Download
AlertService alertService = new AlertService(dialogService); AlertService alertService = new AlertService(dialogService);
ButtonResult result = alertService.ShowMessage(SystemIcon.Instance().Error, ButtonResult result = alertService.ShowMessage(SystemIcon.Instance().Error,
$"Aria2 {DictionaryResource.GetString("Error")}", $"Aria2 {DictionaryResource.GetString("Error")}",
errorMessage); errorMessage,
1);
return; return;
} }

@ -73,16 +73,22 @@ namespace DownKyi.ViewModels.Dialogs
Image = parameters.GetValue<VectorImage>("image"); Image = parameters.GetValue<VectorImage>("image");
Title = parameters.GetValue<string>("title"); Title = parameters.GetValue<string>("title");
Message = parameters.GetValue<string>("message"); Message = parameters.GetValue<string>("message");
int number = parameters.GetValue<int>("button_number");
if (Image == SystemIcon.Instance().Error) switch (number)
{ {
AloneButton = Visibility.Visible; case 1:
TwoButton = Visibility.Collapsed; AloneButton = Visibility.Visible;
} TwoButton = Visibility.Collapsed;
else break;
{ case 2:
AloneButton = Visibility.Collapsed; AloneButton = Visibility.Collapsed;
TwoButton = Visibility.Visible; TwoButton = Visibility.Visible;
break;
default:
AloneButton = Visibility.Collapsed;
TwoButton = Visibility.Visible;
break;
} }
} }

@ -90,24 +90,28 @@
</Button> </Button>
</Grid> </Grid>
<Grid Grid.Row="1" Margin="15,10,15,20"> <Grid Grid.Row="1" Margin="0,10,0,20">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition /> <RowDefinition />
<RowDefinition /> <RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock <ScrollViewer
Grid.Row="0" Grid.Row="0"
MaxWidth="500" MaxWidth="500"
MaxHeight="180" MaxHeight="190"
Margin="0,10,0,30" Margin="0,10,0,30"
HorizontalAlignment="Center" Padding="15,0"
VerticalAlignment="Center" VerticalScrollBarVisibility="Auto">
FontSize="14" <TextBlock
Foreground="{DynamicResource BrushTextDark}" HorizontalAlignment="Center"
Text="{Binding Message}" VerticalAlignment="Center"
TextTrimming="CharacterEllipsis" FontSize="14"
TextWrapping="WrapWithOverflow" /> Foreground="{DynamicResource BrushTextDark}"
Text="{Binding Message}"
TextTrimming="CharacterEllipsis"
TextWrapping="WrapWithOverflow" />
</ScrollViewer>
<Button <Button
Grid.Row="1" Grid.Row="1"

Loading…
Cancel
Save