fix: 多语言MessageBox自动调整高度

master
Tongg 5 months ago
parent ba5cfa0c96
commit 74c16f96cb
  1. 2
      Language/en_US.xaml
  2. 13
      Model/Helper/MultilingualHelper.cs
  3. 6
      Views/Dialog/MessageBox.xaml
  4. 12
      Views/Dialog/MessageBox.xaml.cs

@ -149,7 +149,7 @@
<sys:String x:Key="ViewportSelectPath">Select Path</sys:String> <sys:String x:Key="ViewportSelectPath">Select Path</sys:String>
<!-- Login Page --> <!-- Login Page -->
<sys:String x:Key="LoginWindowTitle">Starshine Diamond Detection System</sys:String> <sys:String x:Key="LoginWindowTitle">Spark Diamond Detection System</sys:String>
<sys:String x:Key="LoginWindowAccount">Account</sys:String> <sys:String x:Key="LoginWindowAccount">Account</sys:String>
<sys:String x:Key="LoginWindowPassword">Password</sys:String> <sys:String x:Key="LoginWindowPassword">Password</sys:String>
<sys:String x:Key="LoginWindowRemember">Remember Password</sys:String> <sys:String x:Key="LoginWindowRemember">Remember Password</sys:String>

@ -15,7 +15,7 @@ public class MultilingualHelper
/// <returns>文字</returns> /// <returns>文字</returns>
/// <exception cref="NullReferenceException"></exception> /// <exception cref="NullReferenceException"></exception>
public static string getString(string key) public static string getString(string key)
{ {
var result = Application.Current.TryFindResource(key); var result = Application.Current.TryFindResource(key);
if (result == null) if (result == null)
{ {
@ -23,6 +23,17 @@ public class MultilingualHelper
} }
return (string)result; return (string)result;
} }
/// <summary>
/// 获取多语言字符
/// </summary>
/// <param name="key">KEY</param>
/// <returns>文字</returns>
/// <exception cref="NullReferenceException"></exception>
public static string getLangType()
{
return ConfigHelper.Instance.Lang.ToString();
}
/// <summary> /// <summary>
/// 设置语言 /// 设置语言

@ -37,7 +37,7 @@
<Image Style="{StaticResource CloseHoverImageStyle}" Width="30" Height="30" /> <Image Style="{StaticResource CloseHoverImageStyle}" Width="30" Height="30" />
</Button> </Button>
<TextBlock Grid.Row="1" Width="600" TextWrapping = "Wrap" Padding="30 0" HorizontalAlignment="Center" <TextBlock Grid.Row="1" Width="600" TextWrapping = "Wrap" Padding="30 0" HorizontalAlignment="Center" SizeChanged="TextBlockCenterBox_OnSizeChanged"
VerticalAlignment="Center" TextAlignment="Center" FontSize="18" x:Name="TextBlockCenterBox" Margin="0 20" VerticalAlignment="Center" TextAlignment="Center" FontSize="18" x:Name="TextBlockCenterBox" Margin="0 20"
/> />
<Border Grid.Row="2" Width="500" Height="40" CornerRadius="20" BorderBrush="#ebeef5" <Border Grid.Row="2" Width="500" Height="40" CornerRadius="20" BorderBrush="#ebeef5"
@ -56,7 +56,7 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button x:Name="ConfirmButton" Grid.Column="1" Padding="0" Margin="0" Height="50" Click="ConfirmButton_OnClick" <Button x:Name="ConfirmButton" Grid.Column="1" Padding="0" Margin="0 0 0 20" Height="50" Click="ConfirmButton_OnClick"
BorderThickness="0" Background="Transparent" FocusVisualStyle="{x:Null}"> BorderThickness="0" Background="Transparent" FocusVisualStyle="{x:Null}">
<Border <Border
HorizontalAlignment="Center" HorizontalAlignment="Center"
@ -75,7 +75,7 @@
<TextBlock FontSize="18" x:Name="ConfirmButtonText" TextAlignment="Center" Foreground="#ffffff"></TextBlock> <TextBlock FontSize="18" x:Name="ConfirmButtonText" TextAlignment="Center" Foreground="#ffffff"></TextBlock>
</Border> </Border>
</Button> </Button>
<Button x:Name="CancelButton" Grid.Column="3" Padding="0" Margin="0" Height="50" Click="CancelButton_OnClick" <Button x:Name="CancelButton" Grid.Column="3" Padding="0" Margin="0 0 0 20" Height="50" Click="CancelButton_OnClick"
BorderThickness="0" Background="Transparent" FocusVisualStyle="{x:Null}"> BorderThickness="0" Background="Transparent" FocusVisualStyle="{x:Null}">
<Border <Border
HorizontalAlignment="Center" HorizontalAlignment="Center"

@ -124,4 +124,16 @@ public partial class MessageBox : Window
_result = MessageBoxResult.Cancel; _result = MessageBoxResult.Cancel;
this.Close(); this.Close();
} }
private void TextBlockCenterBox_OnSizeChanged(object sender, SizeChangedEventArgs e)
{
double singleLineHeight = TextBlockCenterBox.FontSize * 1.4;
if (TextBlockCenterBox.ActualHeight > singleLineHeight)
{
// 发生换行
this.Height += 40;
}
}
} }
Loading…
Cancel
Save